Example #1
0
def generate_launch_description():
    # Get the launch directory
    social_bringup_dir = get_package_share_directory('social_nav2_bringup')
    pedsim_dir = get_package_share_directory('pedsim_simulator')

    # nav_bringup_dir = get_package_share_directory('nav2_bringup')

    launch_dir = os.path.join(social_bringup_dir, 'launch')

    # Create the launch configuration variables
    namespace = LaunchConfiguration('namespace')
    frame_id = LaunchConfiguration('frame_id')
    scene_file = LaunchConfiguration('scene_file')
    simulation_factor = LaunchConfiguration('simulation_factor')

    declare_frame_id_cmd = DeclareLaunchArgument('frame_id',
                                                 default_value='map',
                                                 description='Reference frame')

    declare_scene_file_cmd = DeclareLaunchArgument(
        'scene_file',
        default_value=os.path.join(pedsim_dir, 'scenarios',
                                   'tb3_house_demo_crowd.xml'),
        description='')

    declare_simulation_factor_cmd = DeclareLaunchArgument(
        'simulation_factor',
        default_value='0.07',
        description='Simulator factor. 0.0 to get static agents')
    # Specify the actions

    social_nav_bringup_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(launch_dir, 'tb3_house_simulation_launch.py')))

    pedsim_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('pedsim_simulator'), 'launch',
                     'simulator_launch.py')),
                                          launch_arguments={
                                              'scene_file':
                                              scene_file,
                                              'simulation_factor':
                                              simulation_factor
                                          }.items())

    pedsim_visualizer_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('pedsim_visualizer'),
                         'launch', 'visualizer_launch.py')),
        launch_arguments={'frame_id': frame_id}.items())

    #dummy_set_agent_action_cmd = Node(
    #    package='social_nav2_tooling',
    #    executable='dummy_set_agent_action',
    #    name='dummy_set_agent_action',
    #    output='screen'
    #)

    # Create the launch description and populate
    ld = LaunchDescription()

    # Declare the launch options
    ld.add_action(declare_scene_file_cmd)
    ld.add_action(declare_simulation_factor_cmd)
    ld.add_action(declare_frame_id_cmd)
    # ld.add_action(dummy_set_agent_action_cmd)
    # Add any conditioned actions
    ld.add_action(pedsim_cmd)
    ld.add_action(pedsim_visualizer_cmd)
    ld.add_action(social_nav_bringup_cmd)

    return ld
def generate_launch_description():
    # Nav needs TF. Specifically:
    # ros2 run tf2_ros static_transform_publisher
    #   1 2 3 0.5 0.1 -1.0 odom base_link
    # ros2 run tf2_ros static_transform_publisher
    #   1 2 3 0.5 0.1 -1.0 map odom

    # Get the launch directory
    bringup_dir = get_package_share_directory('nav2_bringup')
    launch_dir = os.path.join(bringup_dir, 'launch')

    # Create the launch configuration variables
    slam = LaunchConfiguration('slam')
    namespace = LaunchConfiguration('namespace')
    use_namespace = LaunchConfiguration('use_namespace')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename')
    autostart = LaunchConfiguration('autostart')

    # Launch configuration variables specific to simulation
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    use_rviz = LaunchConfiguration('use_rviz')

    # Declare the launch arguments
    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace', default_value='', description='Top-level namespace')

    declare_use_namespace_cmd = DeclareLaunchArgument(
        'use_namespace',
        default_value='false',
        description='Whether to apply a namespace to the navigation stack')

    declare_slam_cmd = DeclareLaunchArgument('slam',
                                             default_value='False',
                                             description='Whether run a SLAM')

    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map',
        # default_value=os.path.join(
        #    bringup_dir, 'maps', 'hadabot_world.yaml'),
        default_value='./hadabot_world.yaml',
        description='Full path to map file to load')

    declare_use_sim_time_cmd = DeclareLaunchArgument(
        'use_sim_time',
        default_value='false',
        description='Use simulation (Gazebo) clock if true')

    declare_params_file_cmd = DeclareLaunchArgument(
        'params_file',
        #default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
        default_value=os.path.join('/home/dsryzhov/hadabot/hadabot_rds/ros_ws',
                                   'launch', 'nav2_params.yaml'),
        description=('Full path to the ROS2 parameters file to '
                     'use for all launched nodes'))

    declare_bt_xml_cmd = DeclareLaunchArgument(
        'default_bt_xml_filename',
        default_value=os.path.join(
            get_package_share_directory('nav2_bt_navigator'), 'behavior_trees',
            'navigate_w_replanning_and_recovery.xml'),
        description='Full path to the behavior tree xml file to use')

    declare_autostart_cmd = DeclareLaunchArgument(
        'autostart',
        default_value='true',
        description='Automatically startup the nav2 stack')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config_file',
        default_value=os.path.join('.', 'rviz', 'hadabot_nav2_view.rviz'),
        description='Full path to the RVIZ config file to use')

    declare_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='True', description='Whether to start RVIZ')

    # Specify the actions
    rviz_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(launch_dir, 'rviz_launch.py')),
                                        condition=IfCondition(use_rviz),
                                        launch_arguments={
                                            'namespace': '',
                                            'use_namespace': 'False',
                                            'rviz_config': rviz_config_file
                                        }.items())

    nav2_bringup_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(launch_dir, 'bringup_launch.py')),
                                                launch_arguments={
                                                    'namespace': namespace,
                                                    'use_namespace':
                                                    use_namespace,
                                                    'slam': slam,
                                                    'map': map_yaml_file,
                                                    'use_sim_time':
                                                    use_sim_time,
                                                    'params_file': params_file,
                                                    'default_bt_xml_filename':
                                                    default_bt_xml_filename,
                                                    'autostart': autostart
                                                }.items())

    # Create the launch description and populate
    ld = LaunchDescription()

    # Declare the launch options
    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_use_namespace_cmd)
    ld.add_action(declare_slam_cmd)
    ld.add_action(declare_map_yaml_cmd)
    ld.add_action(declare_use_sim_time_cmd)
    ld.add_action(declare_params_file_cmd)
    ld.add_action(declare_bt_xml_cmd)
    ld.add_action(declare_autostart_cmd)

    #ld.add_action(declare_rviz_config_file_cmd)
    #ld.add_action(declare_use_rviz_cmd)

    # Add the actions to launch all of the navigation nodes
    #ld.add_action(rviz_cmd)
    ld.add_action(nav2_bringup_cmd)

    return ld
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('nav2_bringup')
    mod_bringup_dir = get_package_share_directory('rsb_nav2')
    launch_dir = os.path.join(bringup_dir, 'launch')

    # Create the launch configuration variables
    slam = LaunchConfiguration('slam')
    namespace_1 = LaunchConfiguration('namespace_1')
    namespace_2 = LaunchConfiguration('namespace_2')
    use_namespace = LaunchConfiguration('use_namespace')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file_1 = LaunchConfiguration('params_file_1')
    params_file_2 = LaunchConfiguration('params_file_2')
    default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename')
    autostart = LaunchConfiguration('autostart')

    # Launch configuration variables specific to simulation
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    use_simulator = LaunchConfiguration('use_simulator')
    use_robot_state_pub = LaunchConfiguration('use_robot_state_pub')
    use_rviz = LaunchConfiguration('use_rviz')
    headless = LaunchConfiguration('headless')
    world = LaunchConfiguration('world')

    # Map fully qualified names to relative ones so the node's namespace can be prepended.
    # In case of the transforms (tf), currently, there doesn't seem to be a better alternative
    # https://github.com/ros/geometry2/issues/32
    # https://github.com/ros/robot_state_publisher/pull/30
    # TODO(orduno) Substitute with `PushNodeRemapping`
    #              https://github.com/ros2/launch_ros/issues/56
    remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')]

    # Declare the launch arguments
    declare_namespace_cmd_1 = DeclareLaunchArgument(
        'namespace_1',
        default_value='robot1',
        description='Top-level namespace')

    declare_namespace_cmd_2 = DeclareLaunchArgument(
        'namespace_2',
        default_value='robot2',
        description='Top-level namespace')

    declare_use_namespace_cmd = DeclareLaunchArgument(
        'use_namespace',
        default_value='True',
        description='Whether to apply a namespace to the navigation stack')

    declare_slam_cmd = DeclareLaunchArgument('slam',
                                             default_value='False',
                                             description='Whether run a SLAM')

    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map',
        default_value=os.path.join(bringup_dir, 'maps',
                                   'turtlebot3_world.yaml'),
        description='Full path to map file to load')

    declare_use_sim_time_cmd = DeclareLaunchArgument(
        'use_sim_time',
        default_value='true',
        description='Use simulation (Gazebo) clock if true')

    declare_params_file_1_cmd = DeclareLaunchArgument(
        'params_file_1',
        default_value=os.path.join(mod_bringup_dir, 'params',
                                   'nav2_multirobot_params_1.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

    declare_params_file_2_cmd = DeclareLaunchArgument(
        'params_file_2',
        default_value=os.path.join(mod_bringup_dir, 'params',
                                   'nav2_multirobot_params_2.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

    declare_bt_xml_cmd = DeclareLaunchArgument(
        'default_bt_xml_filename',
        default_value=os.path.join(
            get_package_share_directory('nav2_bt_navigator'), 'behavior_trees',
            'navigate_w_replanning_and_recovery.xml'),
        description='Full path to the behavior tree xml file to use')

    declare_autostart_cmd = DeclareLaunchArgument(
        'autostart',
        default_value='true',
        description='Automatically startup the nav2 stack')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config_file',
        default_value=os.path.join(bringup_dir, 'rviz',
                                   'nav2_namespaced_view.rviz'),
        description='Full path to the RVIZ config file to use')

    declare_use_simulator_cmd = DeclareLaunchArgument(
        'use_simulator',
        default_value='True',
        description='Whether to start the simulator')

    declare_use_robot_state_pub_cmd = DeclareLaunchArgument(
        'use_robot_state_pub',
        default_value='True',
        description='Whether to start the robot state publisher')

    declare_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='True', description='Whether to start RVIZ')

    declare_simulator_cmd = DeclareLaunchArgument(
        'headless',
        default_value='False',
        description='Whether to execute gzclient)')

    declare_world_cmd = DeclareLaunchArgument(
        'world',
        # TODO(orduno) Switch back once ROS argument passing has been fixed upstream
        #              https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91
        # default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'),
        #                            'worlds/turtlebot3_worlds/waffle.model'),
        default_value=os.path.join(mod_bringup_dir, 'worlds',
                                   '2_tb3_world.model'),
        description='Full path to world model file to load')

    # Specify the actions
    start_gazebo_server_cmd = ExecuteProcess(
        condition=IfCondition(use_simulator),
        cmd=['gzserver', '-s', 'libgazebo_ros_init.so', world],
        cwd=[launch_dir],
        output='screen')

    start_gazebo_client_cmd = ExecuteProcess(condition=IfCondition(
        PythonExpression([use_simulator, ' and not ', headless])),
                                             cmd=['gzclient'],
                                             cwd=[launch_dir],
                                             output='screen')

    urdf = os.path.join(bringup_dir, 'urdf', 'turtlebot3_waffle.urdf')

    start_robot_state_publisher_1_cmd = Node(
        condition=IfCondition(use_robot_state_pub),
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher_1',
        namespace=namespace_1,
        output='screen',
        parameters=[{
            'use_sim_time': use_sim_time
        }],
        remappings=remappings,
        arguments=[urdf])

    start_robot_state_publisher_2_cmd = Node(
        condition=IfCondition(use_robot_state_pub),
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher_2',
        namespace=namespace_2,
        output='screen',
        parameters=[{
            'use_sim_time': use_sim_time
        }],
        remappings=remappings,
        arguments=[urdf])

    rviz_cmd_1 = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(launch_dir, 'rviz_launch.py')),
                                          condition=IfCondition(use_rviz),
                                          launch_arguments={
                                              'namespace': 'robot1',
                                              'use_namespace': 'True',
                                              'rviz_config': rviz_config_file
                                          }.items())

    rviz_cmd_2 = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(launch_dir, 'rviz_launch.py')),
                                          condition=IfCondition(use_rviz),
                                          launch_arguments={
                                              'namespace': 'robot2',
                                              'use_namespace': 'True',
                                              'rviz_config': rviz_config_file
                                          }.items())

    bringup_cmd_1 = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(launch_dir, 'bringup_launch.py')),
                                             launch_arguments={
                                                 'namespace': namespace_1,
                                                 'use_namespace':
                                                 use_namespace,
                                                 'slam': slam,
                                                 'map': map_yaml_file,
                                                 'use_sim_time': use_sim_time,
                                                 'params_file': params_file_1,
                                                 'default_bt_xml_filename':
                                                 default_bt_xml_filename,
                                                 'autostart': autostart
                                             }.items())

    bringup_cmd_2 = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(launch_dir, 'bringup_launch.py')),
                                             launch_arguments={
                                                 'namespace': namespace_2,
                                                 'use_namespace':
                                                 use_namespace,
                                                 'slam': slam,
                                                 'map': map_yaml_file,
                                                 'use_sim_time': use_sim_time,
                                                 'params_file': params_file_2,
                                                 'default_bt_xml_filename':
                                                 default_bt_xml_filename,
                                                 'autostart': autostart
                                             }.items())

    # Create the launch description and populate
    ld = LaunchDescription()

    # Declare the launch options
    ld.add_action(declare_namespace_cmd_1)
    ld.add_action(declare_namespace_cmd_2)
    ld.add_action(declare_use_namespace_cmd)
    ld.add_action(declare_use_namespace_cmd)
    ld.add_action(declare_slam_cmd)
    ld.add_action(declare_map_yaml_cmd)
    ld.add_action(declare_use_sim_time_cmd)
    ld.add_action(declare_params_file_1_cmd)
    ld.add_action(declare_params_file_2_cmd)
    ld.add_action(declare_bt_xml_cmd)
    ld.add_action(declare_autostart_cmd)

    ld.add_action(declare_rviz_config_file_cmd)
    ld.add_action(declare_use_simulator_cmd)
    ld.add_action(declare_use_robot_state_pub_cmd)
    ld.add_action(declare_use_rviz_cmd)
    ld.add_action(declare_simulator_cmd)
    ld.add_action(declare_world_cmd)

    # Add any conditioned actions
    ld.add_action(start_gazebo_server_cmd)
    ld.add_action(start_gazebo_client_cmd)

    # Add the actions to launch all of the navigation nodes
    ld.add_action(start_robot_state_publisher_1_cmd)
    ld.add_action(start_robot_state_publisher_2_cmd)

    ld.add_action(rviz_cmd_1)
    ld.add_action(rviz_cmd_2)

    ld.add_action(bringup_cmd_1)
    ld.add_action(bringup_cmd_2)

    return ld
Example #4
0
def generate_launch_description():
    m = launch.LaunchDescription()

    use_sim_time = LaunchConfiguration('use_sim_time', default='false')
    m.add_entity(use_sim_time)

    param_file_name = TURTLEBOT3_MODEL + '.yaml'
    # Declare the launc parameter
    n = DeclareLaunchArgument('params',
                              default_value='c:\home',
                              description='Argument for child launch file')
    m.add_entity(n)

    run_rqt_arg = DeclareLaunchArgument(name="run_rqt",
                                        default_value="True",
                                        description="Launch RQT?")
    m.add_entity(run_rqt_arg)

    run_rviz_arg = DeclareLaunchArgument(name="run_rviz",
                                         default_value="False",
                                         description="Launch RVIZ?")
    m.add_entity(run_rviz_arg)
    #run_rqt_arg.default_value
    param_dir = LaunchConfiguration(
        'params',
        default=os.path.join(
            get_package_share_directory('turtlebot3_navigation2'), 'param',
            param_file_name))
    m.add_entity(param_dir)
    print('param_file_name', param_file_name)
    #e = param_dir.variable_name
    # f=param_dir.perform(self)
    l = launch.substitutions.LaunchConfiguration('params')
    m.add_entity(l)
    #b=e[0]
    #c=b.describe()
    print("zz")
    print("params ", l)
    b = run_rviz_arg.default_value[0].describe()
    print("run_rviz_arg.default_value", b)

    #print(run_rqt_arg.name," default ", run_rqt_arg.default_value[0].describe())
    #print(" ")
    #print("globals", globals())
    #print(" ")
    #print("locals",locals())
    #print(" ")
    #print("dir launchdescription ", dir(LaunchDescription))
    #print(" ")
    #print("dir launch ", dir(launch))
    #c=run_rqt_arg.visit()
    #print(c)
    #print(" ")
    print("dir m ", dir(m))
    print(" ")
    o = m.get_launch_arguments(False)
    print("o ", o[0], o.count)
    print(" zzzzz")
    #d=run_rqt_arg.name
    #print(d)
    #    d=param_dir.__format__
    #print(launch.substitution.LaunchConfiguration('params')   )
    #print(h)

    return m
Example #5
0
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('lesson_urdf')
    launch_dir = os.path.join(bringup_dir, 'launch')

    # Launch configuration variables specific to simulation
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    use_robot_state_pub = LaunchConfiguration('use_robot_state_pub')
    use_joint_state_pub = LaunchConfiguration('use_joint_state_pub')
    use_rviz = LaunchConfiguration('use_rviz')
    urdf_file = LaunchConfiguration('urdf_file')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config_file',
        default_value=os.path.join(bringup_dir, 'rviz', 'view.rviz'),
        description='Full path to the RVIZ config file to use')
    declare_use_robot_state_pub_cmd = DeclareLaunchArgument(
        'use_robot_state_pub',
        default_value='True',
        description='Whether to start the robot state publisher')
    declare_use_joint_state_pub_cmd = DeclareLaunchArgument(
        'use_joint_state_pub',
        default_value='True',
        description='Whether to start the joint state publisher')
    declare_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='True', description='Whether to start RVIZ')

    declare_urdf_cmd = DeclareLaunchArgument(
        'urdf_file',
        default_value=os.path.join(bringup_dir, 'urdf', 'planar_3dof.urdf'),
        description='Whether to start RVIZ')

    start_robot_state_publisher_cmd = Node(
        condition=IfCondition(use_robot_state_pub),
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher',
        output='screen',
        #parameters=[{'use_sim_time': use_sim_time}],
        arguments=[urdf_file])

    start_joint_state_publisher_cmd = Node(
        condition=IfCondition(use_joint_state_pub),
        package='joint_state_publisher_gui',
        executable='joint_state_publisher_gui',
        name='joint_state_publisher_gui',
        output='screen',
        arguments=[urdf_file])

    rviz_cmd = Node(condition=IfCondition(use_rviz),
                    package='rviz2',
                    executable='rviz2',
                    name='rviz2',
                    arguments=['-d', rviz_config_file],
                    output='screen')

    # Create the launch description and populate
    ld = LaunchDescription()

    # Declare the launch options
    ld.add_action(declare_rviz_config_file_cmd)
    ld.add_action(declare_urdf_cmd)
    ld.add_action(declare_use_robot_state_pub_cmd)
    ld.add_action(declare_use_joint_state_pub_cmd)
    ld.add_action(declare_use_rviz_cmd)

    # Add any conditioned actions
    ld.add_action(start_joint_state_publisher_cmd)
    ld.add_action(start_robot_state_publisher_cmd)
    ld.add_action(rviz_cmd)

    return ld
Example #6
0
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('amazon_robot_bringup')

    namespace = LaunchConfiguration('namespace')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    autostart = LaunchConfiguration('autostart')
    params_file = LaunchConfiguration('params_file')
    lifecycle_nodes = ['map_server', 'amcl']
    amazon_bringup_package_dir = get_package_share_directory(
        'amazon_robot_bringup')

    # Map fully qualified names to relative ones so the node's namespace can be prepended.
    # In case of the transforms (tf), currently, there doesn't seem to be a better alternative
    # https://github.com/ros/geometry2/issues/32
    # https://github.com/ros/robot_state_publisher/pull/30
    # TODO(orduno) Substitute with `PushNodeRemapping`
    #              https://github.com/ros2/launch_ros/issues/56
    remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')]

    # Create our own temporary YAML files that include substitutions
    param_substitutions = {
        'use_sim_time': use_sim_time,
        'yaml_filename': map_yaml_file
    }

    configured_params = RewrittenYaml(source_file=params_file,
                                      root_key=namespace,
                                      param_rewrites=param_substitutions,
                                      convert_types=True)

    return LaunchDescription([
        # Set env var to print messages to stdout immediately
        SetEnvironmentVariable('RCUTILS_LOGGING_BUFFERED_STREAM', '1'),
        DeclareLaunchArgument('namespace',
                              default_value='',
                              description='Top-level namespace'),
        DeclareLaunchArgument(
            'map',
            default_value=os.path.join(amazon_bringup_package_dir, 'maps',
                                       'amazon_warehouse.yaml'),
            description='Full path to map yaml file to load'),
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='true',
            description='Use simulation (Gazebo) clock if true'),
        DeclareLaunchArgument(
            'autostart',
            default_value='true',
            description='Automatically startup the nav2 stack'),
        DeclareLaunchArgument(
            'params_file',
            default_value=os.path.join(bringup_dir, 'params',
                                       'nav2_params_with_controller.yaml'),
            description='Full path to the ROS2 parameters file to use'),
        Node(package='nav2_map_server',
             executable='map_server',
             name='map_server',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_amcl',
             executable='amcl',
             name='amcl',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_lifecycle_manager',
             executable='lifecycle_manager',
             name='lifecycle_manager_localization',
             output='screen',
             parameters=[{
                 'use_sim_time': use_sim_time
             }, {
                 'autostart': autostart
             }, {
                 'node_names': lifecycle_nodes
             }])
    ])
def generate_launch_description():
    """Launch example instrumented nodes."""
    launch_description = LaunchDescription()

    launch_description.add_action(DeclareLaunchArgument(
        MEASUREMENT_PERIOD,
        default_value=DEFAULT_MEASUREMENT_PERIOD_IN_MS,
        description='The period (in ms) between each subsequent metrics measurement made'
                    ' by the collector nodes'))
    launch_description.add_action(DeclareLaunchArgument(
        PUBLISH_PERIOD,
        default_value=DEFAULT_PUBLISH_PERIOD_IN_MS,
        description='The period (in ms) between each subsequent metrics message published'
                    ' by the collector nodes'))
    node_parameters = [
        {MEASUREMENT_PERIOD: LaunchConfiguration(MEASUREMENT_PERIOD)},
        {PUBLISH_PERIOD: LaunchConfiguration(PUBLISH_PERIOD)}]

    # Collect, aggregate, and measure system CPU % used
    system_cpu_node = LifecycleNode(
        executable='linux_cpu_collector',
        package='system_metrics_collector',
        name='linux_system_cpu_collector',
        namespace='',
        output='screen',
        parameters=node_parameters,
    )

    # Collect, aggregate, and measure system memory % used
    system_memory_node = LifecycleNode(
        executable='linux_memory_collector',
        package='system_metrics_collector',
        name='linux_system_memory_collector',
        namespace='',
        output='screen',
        parameters=node_parameters,
    )

    # Instrument the listener demo to collect, aggregate, and publish it's CPU % + memory % used
    listener_container = ComposableNodeContainer(
        name='listener_container',
        namespace='',
        package='rclcpp_components',
        executable='component_container',
        composable_node_descriptions=[
            ComposableNode(
                package='demo_nodes_cpp',
                plugin='demo_nodes_cpp::Listener',
                name='listener'),
            ComposableNode(
                package='system_metrics_collector',
                plugin='system_metrics_collector::LinuxProcessCpuMeasurementNode',
                name='listener_process_cpu_node',
                parameters=node_parameters,
            ),
            ComposableNode(
                package='system_metrics_collector',
                plugin='system_metrics_collector::LinuxProcessMemoryMeasurementNode',
                name='listener_process_memory_node',
                parameters=node_parameters,
            )
        ],
        output='screen',
    )

    # Instrument the talker demo to collect, aggregate, and publish it's CPU % + memory % used
    talker_container = ComposableNodeContainer(
        name='talker_container',
        namespace='',
        package='rclcpp_components',
        executable='component_container',
        composable_node_descriptions=[
            ComposableNode(
                package='demo_nodes_cpp',
                plugin='demo_nodes_cpp::Talker',
                name='talker'),
            ComposableNode(
                package='system_metrics_collector',
                plugin='system_metrics_collector::LinuxProcessCpuMeasurementNode',
                name='talker_process_cpu_node',
                parameters=node_parameters,
            ),
            ComposableNode(
                package='system_metrics_collector',
                plugin='system_metrics_collector::LinuxProcessMemoryMeasurementNode',
                name='talker_process_memory_node',
                parameters=node_parameters,
            )
        ],
        output='screen',
    )

    launch_description.add_action(system_memory_node)
    launch_description.add_action(system_cpu_node)
    launch_description.add_action(listener_container)
    launch_description.add_action(talker_container)

    return launch_description
Example #8
0
def generate_launch_description():
    use_sim_time = LaunchConfiguration('use_sim_time')

    package_dir = get_package_share_directory('webots_ros2_epuck')

    webots = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('webots_ros2_core'),
                         'launch', 'robot_launch.py')),
        launch_arguments=[
            ('package', 'webots_ros2_epuck'),
            ('executable', 'driver'),
            ('world',
             os.path.join(package_dir, 'worlds', 'rats_life_benchmark.wbt')),
        ],
        condition=launch.conditions.IfCondition(use_sim_time))

    # Launch Navigation2 without localization and without costmaps.
    # As the launch file is intended for mapping comparison only (real vs. physical) we want strictly to follow the waypoints
    # (without obstacle avoidance).
    # This way, mapping quality is not compromised by different paths.
    nav2 = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('nav2_bringup'), 'launch',
                         'navigation_launch.py')),
        launch_arguments=[('use_sim_time', use_sim_time),
                          ('params_file',
                           os.path.join(package_dir, 'resource',
                                        'nav2_rats_life_waypoints.yaml'))])

    rviz = Node(
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        arguments=['-d',
                   os.path.join(package_dir, 'resource', 'all.rviz')],
        parameters=[{
            'use_sim_time': use_sim_time
        }],
        output='screen')

    mapper = Node(
        package='webots_ros2_epuck',
        executable='simple_mapper',
        output='screen',
        parameters=[{
            'use_sim_time': use_sim_time,
            'fill_map': True
        }],
    )

    # Send the waypoints to Navigation2 package once the corresponding node is ready.
    send_waypoints = ExecuteProcess(
        # The goal has to be sent once the simulation is up and running.
        # Therefore, we keep sending the goal until it is accepted.
        cmd=[
            'sleep 5;'
            'while [ -z '
            f'`ros2 action send_goal /FollowWaypoints nav2_msgs/action/FollowWaypoints \'{get_waypoints()}\' | grep accepted`'
            ']; do'
            '  sleep 3;'
            'done'
        ],
        shell=True)

    return LaunchDescription([
        webots, nav2, rviz, mapper, send_waypoints,
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='true',
            description='Use simulation (Webots) clock if true')
    ])
def generate_launch_description():
    relay_components = []

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="route_relay",
            namespace="awapi",
            parameters=[{
                "input_topic": LaunchConfiguration("input_route"),
                "output_topic": LaunchConfiguration("get_route"),
                "type": "autoware_planning_msgs/msg/Route",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="predict_object_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("input_object"),
                "output_topic":
                LaunchConfiguration("get_predicted_object"),
                "type":
                "autoware_perception_msgs/msg/DynamicObjectArray",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="nearest_traffic_light_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("input_nearest_traffic_light_state"),
                "output_topic":
                LaunchConfiguration("get_nearest_traffic_light_status"),
                "type":
                "autoware_perception_msgs/msg/LookingTrafficLightState",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="ready_module_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("input_path_change_ready"),
                "output_topic":
                LaunchConfiguration("get_path_change_ready"),
                "type":
                "autoware_planning_msgs/msg/PathChangeModule",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="force_available_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("input_path_change_force_available"),
                "output_topic":
                LaunchConfiguration("get_path_change_force_available"),
                "type":
                "autoware_planning_msgs/msg/PathChangeModuleArray",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="running_modules_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("input_path_change_running"),
                "output_topic":
                LaunchConfiguration("get_path_change_running"),
                "type":
                "autoware_planning_msgs/msg/PathChangeModuleArray",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="autoware_engage_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_engage"),
                "output_topic":
                LaunchConfiguration("output_autoware_engage"),
                "type":
                "autoware_vehicle_msgs/msg/Engage",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="vehicle_engage_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_engage"),
                "output_topic":
                LaunchConfiguration("output_vehicle_engage"),
                "type":
                "autoware_vehicle_msgs/msg/Engage",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="put_route_relay",
            namespace="awapi",
            parameters=[{
                "input_topic": LaunchConfiguration("set_route"),
                "output_topic": LaunchConfiguration("output_route"),
                "type": "autoware_planning_msgs/msg/Route",
                "durability": "transient_local",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="put_goal_relay",
            namespace="awapi",
            parameters=[{
                "input_topic": LaunchConfiguration("set_goal"),
                "output_topic": LaunchConfiguration("output_goal"),
                "type": "geometry_msgs/msg/PoseStamped",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="lane_change_approval_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_lane_change_approval"),
                "output_topic":
                LaunchConfiguration("output_lane_change_approval"),
                "type":
                "autoware_planning_msgs/msg/LaneChangeCommand",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="force_lane_change_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_force_lane_change"),
                "output_topic":
                LaunchConfiguration("output_force_lane_change"),
                "type":
                "autoware_planning_msgs/msg/LaneChangeCommand",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="external_approval_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_path_change_approval"),
                "output_topic":
                LaunchConfiguration("output_path_change_approval"),
                "type":
                "autoware_planning_msgs/msg/Approval",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="force_approval_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_path_change_force"),
                "output_topic":
                LaunchConfiguration("output_path_change_force"),
                "type":
                "autoware_planning_msgs/msg/PathChangeModule",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="obstacle_avoid_approval_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_obstacle_avoid_approval"),
                "output_topic":
                LaunchConfiguration("output_obstacle_avoid_approval"),
                "type":
                "autoware_planning_msgs/msg/EnableAvoidance",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="traffic_light_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("input_traffic_light_state"),
                "output_topic":
                LaunchConfiguration("get_traffic_light_status"),
                "type":
                "autoware_perception_msgs/msg/TrafficLightStateArray",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="overwrite_traffic_light_state_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_overwrite_traffic_light_state"),
                "output_topic":
                LaunchConfiguration("output_overwrite_traffic_light_state"),
                "type":
                "autoware_perception_msgs/msg/TrafficLightStateArray",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="speed_exceeded_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("input_stop_speed_exceeded"),
                "output_topic":
                LaunchConfiguration("get_stop_speed_exceeded"),
                "type":
                "autoware_planning_msgs/msg/StopSpeedExceeded",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="crosswalk_status_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_crosswalk_status"),
                "output_topic":
                LaunchConfiguration("input_external_crosswalk_status"),
                "type":
                "autoware_api_msgs/msg/CrosswalkStatus",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="intersection_status_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_intersection_status"),
                "output_topic":
                LaunchConfiguration("input_external_intersection_status"),
                "type":
                "autoware_api_msgs/msg/IntersectionStatus",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="expand_stop_range_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_expand_stop_range"),
                "output_topic":
                LaunchConfiguration("input_expand_stop_range"),
                "type":
                "autoware_planning_msgs/msg/ExpandStopRange",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    relay_components.append(
        ComposableNode(
            package="topic_tools",
            plugin="topic_tools::RelayNode",
            name="pose_initialization_request_relay",
            namespace="awapi",
            parameters=[{
                "input_topic":
                LaunchConfiguration("set_pose_initialization_request"),
                "output_topic":
                LaunchConfiguration("input_pose_initialization_request"),
                "type":
                "autoware_localization_msgs/msg/PoseInitializationRequest",
            }],
            extra_arguments=[{
                "use_intra_process_comms":
                LaunchConfiguration("use_intra_process")
            }],
        ))

    container = ComposableNodeContainer(
        name="awapi_relay_container",
        namespace="awapi",
        package="rclcpp_components",
        executable=LaunchConfiguration("container_executable"),
        composable_node_descriptions=relay_components,
        output="screen",
    )

    set_container_executable = SetLaunchConfiguration(
        "container_executable",
        "component_container",
        condition=UnlessCondition(LaunchConfiguration("use_multithread")),
    )

    set_container_mt_executable = SetLaunchConfiguration(
        "container_executable",
        "component_container_mt",
        condition=IfCondition(LaunchConfiguration("use_multithread")),
    )

    return launch.LaunchDescription(
        [set_container_executable, set_container_mt_executable] + [container])
Example #10
0
def generate_launch_description():
    use_sim_time = LaunchConfiguration("use_sim_time")
    robot_description = LaunchConfiguration("robot_description")
    ground_gait = LaunchConfiguration("ground_gait")
    realsense_simulation = LaunchConfiguration("realsense_simulation")
    jointless = LaunchConfiguration("jointless")

    xacro_path = PathJoinSubstitution([
        get_package_share_directory("march_description"), "urdf",
        robot_description
    ])
    use_imu_data = LaunchConfiguration("use_imu_data")
    imu_topic = LaunchConfiguration("imu_topic")
    to_world_transform = LaunchConfiguration("to_world_transform")
    simulation = LaunchConfiguration("simulation")

    return LaunchDescription([
        DeclareLaunchArgument(
            "use_sim_time",
            default_value="false",
            description="Use simulation (Gazebo) clock if true",
        ),
        DeclareLaunchArgument(
            name="robot_description",
            default_value="march4",
            description="Which <robot_description>.xacro file to use. "
            "This file must be available in the march_desrciption/urdf/ folder",
        ),
        DeclareLaunchArgument(
            name="use_imu_data",
            default_value="False",
            description=
            "Whether the data from the physical imu should be used to"
            "publish the rotation of the exoskeleton.",
        ),
        DeclareLaunchArgument(
            name="imu_topic",
            default_value="/camera_front/imu/data",
            description=
            "The topic that should be used to determine the orientation",
        ),
        DeclareLaunchArgument(
            name="to_world_transform",
            default_value="False",
            description="Whether a transform from the world to base_link is "
            "necessary, this is the case when you are "
            "groundgaiting in rviz.",
        ),
        DeclareLaunchArgument(
            name="simulation",
            default_value="False",
            description="Whether the exoskeleton is ran physically or in "
            "simulation.",
        ),
        DeclareLaunchArgument(
            name="realsense_simulation",
            default_value="False",
            description=
            "Whether the simulation camera or the physical camera should be used",
        ),
        DeclareLaunchArgument(
            name="ground_gait",
            default_value="False",
            description="Whether the simulation should be simulating "
            "ground_gaiting instead of airgaiting.",
        ),
        DeclareLaunchArgument(
            "balance",
            default_value="False",
            description="Whether balance is being used.",
        ),
        DeclareLaunchArgument(
            "jointless",
            default_value="False",
            description="If true, no joints will be actuated",
        ),
        Node(
            package="march_robot_state_publisher",
            executable="march_robot_state_publisher_node",
            name="robot_state_publisher",
            namespace="march",
            output="screen",
            parameters=[{
                "use_sim_time":
                use_sim_time,
                "robot_description":
                Command([
                    "xacro ",
                    xacro_path,
                    ".xacro",
                    " ground_gait:=",
                    ground_gait,
                    " realsense_simulation:=",
                    realsense_simulation,
                    " configuration:=",
                    ("exoskeleton" if not simulation else "simulation"),
                    " jointless:=",
                    jointless,
                ]),
                "use_imu_data":
                use_imu_data,
                "to_world_transform":
                to_world_transform,
                "imu_topic":
                imu_topic,
                "simulation":
                simulation,
            }],
        ),
    ])
Example #11
0
def generate_launch_description():
    pkg_bringup = get_package_share_directory('nanosaur_bringup')
    pkg_description = get_package_share_directory('nanosaur_description')
    pkg_control = get_package_share_directory('nanosaur_control')

    # Load nanosaur configuration and check if are included extra parameters
    # This feature is used to avoid pass configuration from docker
    conf = load_config(os.path.join(pkg_bringup, 'param', 'robot.yml'))

    # Load namespace from robot.yml
    namespace_conf = os.getenv("HOSTNAME") if conf.get("multirobot",
                                                       False) else "nanosaur"
    # Load cover_type
    if "cover_type" in conf:
        cover_type_conf = conf.get("cover_type", 'fisheye')
        print(f"Load cover_type from robot.xml: {cover_type_conf}")
    else:
        cover_type_conf = os.getenv("NANOSAUR_COVER_TYPE", 'fisheye')
        print(f"Load cover_type from ENV: {cover_type_conf}")

    config_common_path = LaunchConfiguration('config_common_path')
    namespace = LaunchConfiguration('namespace')
    cover_type = LaunchConfiguration('cover_type')

    declare_config_common_path_cmd = DeclareLaunchArgument(
        'config_common_path',
        default_value=os.path.join(pkg_bringup, 'param', 'nanosaur.yml'),
        description='Path to the `nanosaur.yml` file.')

    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace',
        default_value=namespace_conf,
        description=
        'Enable a namespace for multiple robot. This namespace group all nodes and topics.'
    )

    declare_cover_type_cmd = DeclareLaunchArgument(
        name='cover_type',
        default_value=cover_type_conf,
        description=
        'Cover type to use. Options: pi, fisheye, realsense, zedmini.')

    jtop_node = Node(package='jetson_stats_wrapper',
                     namespace=namespace,
                     executable='jtop',
                     name='jtop',
                     remappings=[('diagnostics', '/diagnostics')])

    # System manager
    system_manager = Node(package='ros2_system_manager',
                          namespace=namespace,
                          executable='system_manager',
                          name='system_manager')

    nanosaur_base_node = Node(package='nanosaur_base',
                              namespace=namespace,
                              executable='nanosaur_base',
                              name='nanosaur_base',
                              respawn=True,
                              respawn_delay=5,
                              parameters=[config_common_path],
                              output='screen')

    # include another launch file in nanosaur namespace
    # https://docs.ros.org/en/foxy/How-To-Guides/Launch-file-different-formats.html
    description_launch = GroupAction(actions=[
        # push-ros-namespace to set namespace of included nodes
        PushRosNamespace(namespace),
        # Nanosaur description
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            [pkg_description, '/launch/description.launch.py']),
                                 launch_arguments={'cover_type': cover_type
                                                   }.items())
    ])

    # include another launch file in nanosaur namespace
    twist_control_launch = GroupAction(actions=[
        # push-ros-namespace to set namespace of included nodes
        PushRosNamespace(namespace),
        # nanosaur twist launch
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                [pkg_control, '/launch/twist_control.launch.py']))
    ])

    joy2eyes_node = Node(package='nanosaur_base',
                         namespace="teleop",
                         executable='joy2eyes',
                         name='joy2eyes',
                         remappings=[('eyes', f'/{namespace_conf}/eyes')],
                         output='screen')

    system_manager_node = Node(package='ros2_system_manager',
                               namespace="teleop",
                               executable='joy2sm',
                               name='joy2sm',
                               parameters=[config_common_path],
                               remappings=[('shutdown',
                                            f'/{namespace_conf}/shutdown')],
                               output='screen')

    teleop_extra_node_actions = [
        # push-ros-namespace to set namespace of included nodes
        PushRosNamespace(namespace),
        # nanosaur twist launch
        system_manager_node
    ]

    # Extra Debug packages
    # - Eyes bridge
    if conf.get("debug", False):
        print("DEBUG variable exist - Load extra nodes")
        teleop_extra_node_actions += [joy2eyes_node]

    # include another launch file in nanosaur namespace
    teleop_extra_nodes_launch = GroupAction(actions=teleop_extra_node_actions)

    # https://answers.ros.org/question/306935/ros2-include-a-launch-file-from-a-launch-file/
    # include another launch file in the chatter_ns namespace
    teleop_launch = GroupAction(actions=[
        # push-ros-namespace to set namespace of included nodes
        PushRosNamespace(namespace),
        # teleoperation launcher
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            [pkg_control, '/launch/teleop.launch.py']),
                                 launch_arguments={
                                     'joy_vel':
                                     f"/{namespace_conf}/joy_vel",
                                     'config_filepath':
                                     os.path.join(pkg_control, 'config',
                                                  'ps3.nanosaur.yml')
                                 }.items())
    ])

    print(f"----- cover_type: {cover_type} -----")
    # Define LaunchDescription variable and return it
    ld = LaunchDescription()

    # Namespace nanosaur
    ld.add_action(declare_namespace_cmd)
    # cover_type
    ld.add_action(declare_cover_type_cmd)
    # Nanosaur parameter yml file path
    ld.add_action(declare_config_common_path_cmd)
    # Nanosaur description launch
    ld.add_action(description_launch)
    # jtop node
    ld.add_action(jtop_node)
    # System manager
    ld.add_action(system_manager)
    # Nanusaur driver motors and display
    ld.add_action(nanosaur_base_node)

    # Twist control launcher
    if conf.get("no_twist_mux", False):
        print("Disable twist-mux")
    else:
        ld.add_action(twist_control_launch)

    # teleoperation joystick nanosaur
    # only if joystick is connected
    if os.path.exists("/dev/input/js0"):
        print("Enable Joystick")
        # Teleoperation control
        ld.add_action(teleop_launch)
        # Run Joystick to system_manager node
        ld.add_action(teleop_extra_nodes_launch)

    return ld
Example #12
0
def generate_launch_description(argv=sys.argv[1:]):

    # Can be anything to fit your desired method of naming. Must match with client.
    name1 = 'robot1'
    name2 = 'robot2'
    name3 = 'robot3'
    name4 = 'robot4'

    server_port1 = '13001'
    server_port2 = '13002'
    server_port3 = '13003'
    server_port4 = '13004'

    # Whether or not to use name as a prefix for incoming topics
    use_name = 'true'

    # Whether or not to encrypt and decrypt incoming and outgoing messages
    use_encryption = 'true'
    
    # Any 32 url-safe base64-encoded bytes object passed in as a string.
    # This can be generated using the generate_key.py script in the main folder.
    # Must match with client key.
    encryption_key = 'VdzT2kwMacThZWkBigjbtte9iRjW8djEJ10JiemVwLM='


    param_dir = LaunchConfiguration(
        'param_dir',
        default=os.path.join(
            get_package_share_directory('rsb_server'),
            'config',
            'bringup.yaml'))

    return LaunchDescription([
        DeclareLaunchArgument(
            'param_dir',
            default_value=param_dir,
            description='Full path to parameter file to load'),

        launch_ros.actions.Node(
            package="rsb_server",
            executable="server",
            name="server_node",
            output="screen",
            emulate_tty=True,
            arguments=['-name', name1, '-p', server_port1, '-key', encryption_key, '-usename', use_name, '-encrypt', use_encryption],
            parameters=[param_dir]),

        launch_ros.actions.Node(
            package="rsb_server",
            executable="server",
            name="server_node",
            output="screen",
            emulate_tty=True,
            arguments=['-name', name2, '-p', server_port2, '-key', encryption_key, '-usename', use_name, '-encrypt', use_encryption],
            parameters=[param_dir]),

        launch_ros.actions.Node(
            package="rsb_server",
            executable="server",
            name="server_node",
            output="screen",
            emulate_tty=True,
            arguments=['-name', name3, '-p', server_port3, '-key', encryption_key, '-usename', use_name, '-encrypt', use_encryption],
            parameters=[param_dir]),

        launch_ros.actions.Node(
            package="rsb_server",
            executable="server",
            name="server_node",
            output="screen",
            emulate_tty=True,
            arguments=['-name', name4, '-p', server_port4, '-key', encryption_key, '-usename', use_name, '-encrypt', use_encryption],
            parameters=[param_dir]),
 ])
def generate_launch_description():

    xacro_path = os.path.join(get_package_share_directory('dsr_description2'),
                              'xacro')
    drcf_path = os.path.join(get_package_share_directory('common2'),
                             'bin/DRCF')

    # RViz2
    rviz_config_file = get_package_share_directory(
        'dsr_description2') + "/rviz/default.rviz"
    rviz_node = Node(package='rviz2',
                     executable='rviz2',
                     name='rviz2',
                     output='log',
                     arguments=['-d', rviz_config_file])

    #change_permission = ExecuteProcess(
    #    cmd=['chmod', '-R', '775', drcf_path],
    #    output='screen'
    #)

    # Run DRCF Emulator
    DRCF_node = ExecuteProcess(cmd=['sh', [drcf_path, '/run_drcf.sh']],
                               output='screen',
                               condition=IfCondition(
                                   PythonExpression([
                                       "'",
                                       LaunchConfiguration('mode'),
                                       "' == 'virtual'"
                                   ])))

    # Static TF
    static_tf = Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        name='static_transform_publisher',
        output='log',
        arguments=['0.0', '0.0', '0.0', '0.0', '0.0', '0.0', 'base', 'base_0'])

    # robot_state_publisher
    robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher',
        #output='both',
        output='screen',
        parameters=[{
            'robot_description':
            Command([
                'xacro', ' ', xacro_path, '/',
                LaunchConfiguration('model'), '.urdf.xacro color:=',
                LaunchConfiguration('color')
            ])
        }])

    # dsr_control2
    dsr_control2 = Node(
        package='dsr_control2',
        executable='dsr_control_node2',
        name='dsr_control_node2',
        output='screen',
        parameters=[
            {
                "name": LaunchConfiguration('name')
            },
            {
                "rate": 100
            },
            {
                "standby": 5000
            },
            {
                "command": True
            },
            {
                "host": LaunchConfiguration('host')
            },
            {
                "port": LaunchConfiguration('port')
            },
            {
                "mode": LaunchConfiguration('mode')
            },
            {
                "model": LaunchConfiguration('model')
            },
            {
                "gripper": "none"
            },
            {
                "mobile": "none"
            },
            #parameters_file_path       # 파라미터 설정을 동일이름으로 launch 파일과 yaml 파일에서 할 경우 yaml 파일로 셋팅된다.
        ])

    # gazebo2
    gazebo = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            os.path.join(get_package_share_directory('gazebo_ros'), 'launch'),
            '/gazebo.launch.py'
        ]), )
    spawn_entity = Node(
        package='gazebo_ros',
        executable='spawn_entity.py',
        arguments=['-topic', 'robot_description', '-entity', 'm1013'],
        output='screen')

    return LaunchDescription(args + [
        #change_permission,
        DRCF_node,
        static_tf,
        robot_state_publisher,
        rviz_node,
        gazebo,
        spawn_entity,
        dsr_control2,
    ])
def generate_launch_description():

    use_sim_time = LaunchConfiguration('use_sim_time', default='true')
    resolution = LaunchConfiguration('resolution', default='0.05')
    publish_period_sec = LaunchConfiguration('publish_period_sec',
                                             default='1.0')

    pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
    pkg_working_gazebo = get_package_share_directory('urdf2')

    # cartographer_config_dir = LaunchConfiguration('cartographer_config_dir',default=os.path.join('urdf_tutorial','config'))

    # print("caerographer_config_dir:{}".format(cartographer_config_dir))

    # configuration_basename = LaunchConfiguration('configuration_basename',default='myrobot_lds_4wd.lua')
    # print("configuration_basename:{}".format(configuration_basename))

    urdf_file_name = 'urdf/bot.urdf.xml'
    print("urdf_file_name : {}".format(urdf_file_name))

    urdf = os.path.join(get_package_share_directory('urdf2'), urdf_file_name)

    # Gazebo launch
    gazebo = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(pkg_gazebo_ros, 'launch', 'gazebo.launch.py'), ))

    with open(urdf, 'r') as infp:
        robot_desc = infp.read()

    return LaunchDescription([
        DeclareLaunchArgument(
            'world',
            #   default_value='false',
            default_value=[
                os.path.join(pkg_working_gazebo, 'worlds', 'emptyworld.world'),
                ''
            ],
            description='Use simulation (Gazebo) clock if true'),
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='true',
            description='se simulation (Gazebo) clock if true'),
        gazebo,
        Node(package='robot_state_publisher',
             executable='robot_state_publisher',
             name='robot_state_publisher',
             output='screen',
             parameters=[{
                 'use_sim_time': use_sim_time,
                 'robot_description': robot_desc
             }],
             arguments=[urdf]),
        Node(package='joint_state_publisher',
             executable='joint_state_publisher',
             name='joint_state_publisher',
             parameters=[{
                 'use_sim_time': use_sim_time
             }],
             output='screen'),
        Node(package='gazebo_ros',
             executable='spawn_entity.py',
             parameters=[{
                 'use_sim_time': use_sim_time
             }],
             arguments=['-topic', '/robot_description', '-entity', 'myrobot'],
             output='screen'),
        Node(package='cartographer_ros',
             executable='cartographer_node',
             name='cartographer_node',
             output='screen',
             parameters=[{
                 'use_sim_time': use_sim_time
             }],
             arguments=[
                 '-configuration_directory',
                 get_package_share_directory('urdf2') + '/config',
                 '-configuration_basename', 'myrobot_lds_4wd.lua'
             ]),
        Node(package='cartographer_ros',
             executable='occupancy_grid_node',
             name='occupancy_grid_node',
             output='screen',
             parameters=[{
                 'use_sim_time': use_sim_time
             }],
             arguments=['-resolution', '0.05', '-publish_period_sec', '1.0']),
    ])
Example #15
0
def generate_launch_description():
    # Use a simpler urdf file: no forward camera, no barometer, no thrust, no drag
    # Does contain a motion plugin, so the AUV will be pushed around in a repeating pattern
    orca_description_dir = get_package_share_directory('orca_description')
    urdf_file = os.path.join(orca_description_dir, 'urdf', 'slam_test.urdf')

    # No fiducial markers
    orca_gazebo_dir = get_package_share_directory('orca_gazebo')
    world_file = os.path.join(orca_gazebo_dir, 'worlds', 'empty.world')

    # ORB features vocabulary file
    # This works well in simulation, but I'm sure how it will do in a marine environment
    orb_slam_dir = get_package_share_directory('orb_slam2_ros')
    orb_voc_file = os.path.join(orb_slam_dir, 'orb_slam2', 'Vocabulary', 'ORBvoc.txt')

    # Orb-slam2 params
    orca_bringup_dir = get_package_share_directory('orca_bringup')
    slam_params_file = os.path.join(orca_bringup_dir, 'params', 'slam_test_params.yaml')

    # Rviz config
    rviz_cfg_file = os.path.join(orca_bringup_dir, 'cfg', 'slam_test_launch.rviz')

    left_components = [
        ComposableNode(
            package='image_proc',
            plugin='image_proc::RectifyNode',
            name='left_rectify_node',
            remappings=[
                ('image', '/stereo/left/image_raw'),
                ('camera_info', '/stereo/left/camera_info'),
                ('image_rect', '/stereo/left/image_rect')
            ],
        ),
    ]

    right_components = [
        ComposableNode(
            package='image_proc',
            plugin='image_proc::RectifyNode',
            name='right_rectify_node',
            remappings=[
                ('image', '/stereo/right/image_raw'),
                ('camera_info', '/stereo/right/camera_info'),
                ('image_rect', '/stereo/right/image_rect')
            ],
        ),
    ]

    return LaunchDescription([
        DeclareLaunchArgument(
            'gzclient',
            default_value='False',
            description='Launch Gazebo UI?',
        ),

        DeclareLaunchArgument(
            'rviz',
            default_value='True',
            description='Launch rviz?',
        ),

        DeclareLaunchArgument(
            'rectify',
            default_value='False',
            description='Rectify nodes?',
        ),

        # Launch gzserver
        ExecuteProcess(
            cmd=['gzserver',
                 '-s', 'libgazebo_ros_init.so',  # Publish /clock
                 '-s', 'libgazebo_ros_factory.so',  # Injection endpoint
                 world_file],
            output='screen',
        ),

        # Launch gzclient
        ExecuteProcess(
            cmd=['gzclient'],
            output='screen',
            condition=IfCondition(LaunchConfiguration('gzclient')),
        ),

        # Launch rviz
        ExecuteProcess(
            cmd=['rviz2', '-d', rviz_cfg_file],
            output='screen',
            condition=IfCondition(LaunchConfiguration('rviz')),
        ),

        # Replacement for base_controller: odom->base_link is static
        ExecuteProcess(
            cmd=['/opt/ros/foxy/lib/tf2_ros/static_transform_publisher',
                 '0', '0', '0', '0', '0', '0', 'odom', 'base_link',
                 '--ros-args', '-p', 'use_sim_time:=true'],
            output='screen',
        ),

        # Inject the urdf file
        Node(
            package='sim_fiducial',
            executable='inject_entity.py',
            output='screen',
            arguments=[urdf_file, '0', '0', '0', '0', '0', '0'],
            parameters=[{'use_sim_time': True}],
        ),

        # Publish static transforms from the urdf
        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            output='screen',
            name='robot_state_publisher',
            arguments=[urdf_file],
            parameters=[{'use_sim_time': True}],
        ),

        ComposableNodeContainer(
            name='left_container',
            package='rclcpp_components',
            executable='component_container',
            namespace='',
            composable_node_descriptions=left_components,
            output='screen',
            condition=IfCondition(LaunchConfiguration('rectify')),
        ),

        ComposableNodeContainer(
            name='right_container',
            package='rclcpp_components',
            executable='component_container',
            namespace='',
            composable_node_descriptions=right_components,
            output='screen',
            condition=IfCondition(LaunchConfiguration('rectify')),
        ),

        # Run orb_slam2_ros_stereo (sans rectification)
        Node(
            package='orb_slam2_ros',
            executable='orb_slam2_ros_stereo',
            output='screen',
            name='orb_slam2_stereo',
            parameters=[slam_params_file, {
                'voc_file': orb_voc_file,
            }],
            remappings=[
                ('/image_left/image_color_rect', '/stereo/left/image_raw'),
                ('/image_right/image_color_rect', '/stereo/right/image_raw'),
                ('/camera/camera_info', '/stereo/left/camera_info'),
            ],
            condition=UnlessCondition(LaunchConfiguration('rectify')),
        ),

        # Run orb_slam2_ros_stereo (mit rectification)
        Node(
            package='orb_slam2_ros',
            executable='orb_slam2_ros_stereo',
            output='screen',
            name='orb_slam2_stereo',
            parameters=[slam_params_file, {
                'voc_file': orb_voc_file,
            }],
            remappings=[
                ('/image_left/image_color_rect', '/stereo/left/image_rect'),
                ('/image_right/image_color_rect', '/stereo/right/image_rect'),
                ('/camera/camera_info', '/stereo/left/camera_info'),
            ],
            condition=IfCondition(LaunchConfiguration('rectify')),
        ),

        # Run orb_slam2_localizer, a shim that publishes tf map->odom
        Node(
            package='orca_localize',
            executable='orb_slam2_localizer',
            output='screen',
            name='orb_slam2_localizer',
            parameters=[slam_params_file],
            remappings=[
                ('/camera_pose', '/orb_slam2_stereo_node/pose'),
            ]),
    ])
Example #16
0
def generate_launch_description():
    ROBOT_MODEL = os.getenv('ROBOT_MODEL', 'lunar.1')

    descriptions = [
        DeclareLaunchArgument('imu', default_value='false'),
        Node(package='imu',
             executable='node',
             parameters=[
                 LaunchConfiguration('imu_param_file',
                                     default=os.path.join(
                                         get_package_share_directory('imu'),
                                         'param', ROBOT_MODEL + '.yaml'))
             ],
             condition=IfCondition(LaunchConfiguration('imu'))),
        DeclareLaunchArgument('motor', default_value='false'),
        Node(package='motor',
             executable='node',
             parameters=[
                 LaunchConfiguration('motor_param_file',
                                     default=os.path.join(
                                         get_package_share_directory('motor'),
                                         'param', ROBOT_MODEL + '.yaml'))
             ],
             condition=IfCondition(LaunchConfiguration('motor'))),
        DeclareLaunchArgument('lidar', default_value='false'),
        Node(package='lidar',
             executable='delta_lidar_node',
             parameters=[
                 LaunchConfiguration('lidar_param_file',
                                     default=os.path.join(
                                         get_package_share_directory('lidar'),
                                         'param', ROBOT_MODEL + '.yaml'))
             ],
             condition=IfCondition(LaunchConfiguration('lidar'))),
        DeclareLaunchArgument('joystick', default_value='false'),
        Node(package='joystick_controller',
             executable='node',
             parameters=[
                 LaunchConfiguration(
                     'joystick_param_file',
                     default=os.path.join(
                         get_package_share_directory('joystick_controller'),
                         'param', ROBOT_MODEL + '.yaml'))
             ],
             condition=IfCondition(LaunchConfiguration('joystick'))),
        DeclareLaunchArgument('camera', default_value='false'),
        Node(package='camera',
             executable='node',
             condition=IfCondition(LaunchConfiguration('camera'))),
        DeclareLaunchArgument('localization', default_value='false'),
        Node(package='robot_localization',
             executable='ekf_node',
             name='ekf_filter_node',
             parameters=[
                 os.path.join(get_package_share_directory('robot'), 'param',
                              'robot_localization.yaml')
             ],
             condition=IfCondition(LaunchConfiguration('localization')))
    ]

    bridge_launch_dir = LaunchConfiguration(
        'bridge_launch_dir',
        default=os.path.join(get_package_share_directory('rosbridge_server'),
                             'launch'))

    descriptions.append(
        IncludeLaunchDescription(FrontendLaunchDescriptionSource(
            [bridge_launch_dir, '/rosbridge_websocket_launch.xml']),
                                 launch_arguments=[('max_message_size',
                                                    '10000000')]))

    return LaunchDescription(descriptions)
def generate_launch_description():
    # Get the launch directory
    nav2_bringup_dir = get_package_share_directory('nav2_bringup')
    cooking_dir = get_package_share_directory('plansys2_cooking_example')
    cooking_launch_dir = os.path.join(cooking_dir, 'launch')

    # Create the launch configuration variables
    namespace = LaunchConfiguration('namespace')
    use_namespace = LaunchConfiguration('use_namespace')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    default_bt_xml_file = LaunchConfiguration('default_bt_xml_file')
    autostart = LaunchConfiguration('autostart')
    cmd_vel_topic = LaunchConfiguration('cmd_vel_topic')

    # Launch configuration variables specific to simulation
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    use_rviz = LaunchConfiguration('use_rviz')

    # Declare the launch arguments
    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace', default_value='', description='Top-level namespace')
    declare_use_namespace_cmd = DeclareLaunchArgument(
        'use_namespace',
        default_value='false',
        description='Whether to apply a namespace to the navigation stack')
    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map',
        default_value=os.path.join(cooking_dir, 'maps', 'map.yaml'),
        description='Full path to map file to load')

    declare_use_sim_time_cmd = DeclareLaunchArgument(
        'use_sim_time',
        default_value='false',
        description='Use simulation (Gazebo) clock if true')

    declare_params_file_cmd = DeclareLaunchArgument(
        'params_file',
        default_value=os.path.join(cooking_dir, 'params',
                                   'nav2_cooking_tiago_params.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

    # declare_params_file_cmd = DeclareLaunchArgument(
    #    'params_file',
    #    default_value=os.path.join(nav2_bringup_dir, 'params', 'nav2_params.yaml'),
    #    description='Full path to the ROS2 parameters file to use for all launched nodes')

    declare_bt_xml_cmd = DeclareLaunchArgument(
        'default_bt_xml_file',
        default_value=os.path.join(
            get_package_share_directory('nav2_bt_navigator'), 'behavior_trees',
            'navigate_w_replanning_and_recovery.xml'),
        description='Full path to the behavior tree xml file to use')

    declare_autostart_cmd = DeclareLaunchArgument(
        'autostart',
        default_value='true',
        description='Automatically startup the nav2 stack')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config_file',
        default_value=os.path.join(nav2_bringup_dir, 'rviz',
                                   'nav2_default_view.rviz'),
        description='Full path to the RVIZ config file to use')

    declare_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='True', description='Whether to start RVIZ')
    declare_cmd_vel_topic_cmd = DeclareLaunchArgument(
        'cmd_vel_topic',
        default_value='nav_vel',
        description='Command velocity topic')

    start_rviz_cmd = Node(condition=IfCondition(use_rviz),
                          package='rviz2',
                          executable='rviz2',
                          arguments=['-d', rviz_config_file],
                          output='log',
                          remappings=[('/tf', 'tf'),
                                      ('/tf_static', 'tf_static'),
                                      ('goal_pose', 'goal_pose'),
                                      ('/clicked_point', 'clicked_point'),
                                      ('/initialpose', 'initialpose')])

    exit_event_handler = RegisterEventHandler(
        event_handler=OnProcessExit(target_action=start_rviz_cmd,
                                    on_exit=EmitEvent(event=Shutdown(
                                        reason='rviz exited'))))

    bringup_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(cooking_launch_dir, 'nav2_bringup_launch.py')),
                                           launch_arguments={
                                               'namespace': namespace,
                                               'use_namespace': use_namespace,
                                               'map': map_yaml_file,
                                               'use_sim_time': use_sim_time,
                                               'params_file': params_file,
                                               'bt_xml_file':
                                               default_bt_xml_file,
                                               'autostart': autostart,
                                               'cmd_vel_topic': cmd_vel_topic
                                           }.items())

    # contextual_cmd = IncludeLaunchDescription(
    #     PythonLaunchDescriptionSource(os.path.join(cooking_launch_dir, 'nav2_contextual_launch.py')),
    #     launch_arguments={'next_wp': '0'}.items())

    # Create the launch description and populate
    ld = LaunchDescription()

    # Declare the launch options
    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_use_namespace_cmd)
    ld.add_action(declare_map_yaml_cmd)
    ld.add_action(declare_use_sim_time_cmd)
    ld.add_action(declare_params_file_cmd)
    ld.add_action(declare_bt_xml_cmd)
    ld.add_action(declare_autostart_cmd)

    ld.add_action(declare_rviz_config_file_cmd)
    ld.add_action(declare_use_rviz_cmd)
    ld.add_action(declare_cmd_vel_topic_cmd)

    # Add any conditioned actions
    ld.add_action(start_rviz_cmd)

    # Add other nodes and processes we need
    ld.add_action(exit_event_handler)

    # ld.add_action(contextual_cmd)

    # Add the actions to launch all of the navigation nodes
    ld.add_action(bringup_cmd)

    return ld
def generate_launch_description():
    composable_nodes = [
        ComposableNode(
            package='stereo_image_proc',
            plugin='stereo_image_proc::DisparityNode',
            parameters=[{
                'approximate_sync':
                LaunchConfiguration('approximate_sync'),
                'use_system_default_qos':
                LaunchConfiguration('use_system_default_qos'),
                'stereo_algorithm':
                LaunchConfiguration('stereo_algorithm'),
                'prefilter_size':
                LaunchConfiguration('prefilter_size'),
                'prefilter_cap':
                LaunchConfiguration('prefilter_cap'),
                'correlation_window_size':
                LaunchConfiguration('correlation_window_size'),
                'min_disparity':
                LaunchConfiguration('min_disparity'),
                'disparity_range':
                LaunchConfiguration('disparity_range'),
                'texture_threshold':
                LaunchConfiguration('texture_threshold'),
                'speckle_size':
                LaunchConfiguration('speckle_size'),
                'speckle_range':
                LaunchConfiguration('speckle_range'),
                'disp12_max_diff':
                LaunchConfiguration('disp12_max_diff'),
                'uniqueness_ratio':
                LaunchConfiguration('uniqueness_ratio'),
                'P1':
                LaunchConfiguration('P1'),
                'P2':
                LaunchConfiguration('P2'),
                'full_dp':
                LaunchConfiguration('full_dp'),
            }],
            remappings=[
                ('left/image_rect',
                 [LaunchConfiguration('left_namespace'), '/image_rect']),
                ('left/camera_info',
                 [LaunchConfiguration('left_namespace'), '/camera_info']),
                ('right/image_rect',
                 [LaunchConfiguration('right_namespace'), '/image_rect']),
                ('right/camera_info',
                 [LaunchConfiguration('right_namespace'), '/camera_info']),
            ]),
        ComposableNode(
            package='stereo_image_proc',
            plugin='stereo_image_proc::PointCloudNode',
            parameters=[{
                'approximate_sync':
                LaunchConfiguration('approximate_sync'),
                'avoid_point_cloud_padding':
                LaunchConfiguration('avoid_point_cloud_padding'),
                'use_color':
                LaunchConfiguration('use_color'),
                'use_system_default_qos':
                LaunchConfiguration('use_system_default_qos'),
            }],
            remappings=[
                ('left/camera_info',
                 [LaunchConfiguration('left_namespace'), '/camera_info']),
                ('right/camera_info',
                 [LaunchConfiguration('right_namespace'), '/camera_info']),
                ('left/image_rect_color',
                 [LaunchConfiguration('left_namespace'), '/image_rect_color']),
            ]),
    ]

    return LaunchDescription([
        DeclareLaunchArgument(
            name='approximate_sync',
            default_value='False',
            description=
            'Whether to use approximate synchronization of topics. Set to true if '
            'the left and right cameras do not produce exactly synced timestamps.'
        ),
        DeclareLaunchArgument(
            name='avoid_point_cloud_padding',
            default_value='False',
            description='Avoid alignment padding in the generated point cloud.'
            'This reduces bandwidth requirements, as the point cloud size is halved.'
            'Using point clouds without alignment padding might degrade performance '
            'for some algorithms.'),
        DeclareLaunchArgument(
            name='use_color',
            default_value='True',
            description='Generate point cloud with rgb data.'),
        DeclareLaunchArgument(
            name='use_system_default_qos',
            default_value='False',
            description=
            'Use the RMW QoS settings for the image and camera info subscriptions.'
        ),
        DeclareLaunchArgument(
            name='launch_image_proc',
            default_value='True',
            description=
            'Whether to launch debayer and rectify nodes from image_proc.'),
        DeclareLaunchArgument(name='left_namespace',
                              default_value='left',
                              description='Namespace for the left camera'),
        DeclareLaunchArgument(name='right_namespace',
                              default_value='right',
                              description='Namespace for the right camera'),
        DeclareLaunchArgument(
            name='container',
            default_value='',
            description=
            ('Name of an existing node container to load launched nodes into. '
             'If unset, a new container will be created.')),
        # Stereo algorithm parameters
        DeclareLaunchArgument(
            name='stereo_algorithm',
            default_value='0',
            description=
            'Stereo algorithm: Block Matching (0) or Semi-Global Block Matching (1)'
        ),
        DeclareLaunchArgument(
            name='prefilter_size',
            default_value='9',
            description='Normalization window size in pixels (must be odd)'),
        DeclareLaunchArgument(name='prefilter_cap',
                              default_value='31',
                              description='Bound on normalized pixel values'),
        DeclareLaunchArgument(
            name='correlation_window_size',
            default_value='15',
            description='SAD correlation window width in pixels (must be odd)'
        ),
        DeclareLaunchArgument(
            name='min_disparity',
            default_value='0',
            description='Disparity to begin search at in pixels'),
        DeclareLaunchArgument(
            name='disparity_range',
            default_value='64',
            description=
            'Number of disparities to search in pixels (must be a multiple of 16)'
        ),
        DeclareLaunchArgument(
            name='texture_threshold',
            default_value='10',
            description=
            'Filter out if SAD window response does not exceed texture threshold'
        ),
        DeclareLaunchArgument(
            name='speckle_size',
            default_value='100',
            description='Reject regions smaller than this size in pixels'),
        DeclareLaunchArgument(
            name='speckle_range',
            default_value='4',
            description=
            'Maximum allowed difference between detected disparities'),
        DeclareLaunchArgument(
            name='disp12_max_diff',
            default_value='0',
            description=
            'Maximum allowed difference in the left-right disparity check in pixels '
            '(Semi-Global Block Matching only)'),
        DeclareLaunchArgument(
            name='uniqueness_ratio',
            default_value='15.0',
            description=
            'Filter out if best match does not sufficiently exceed the next-best match'
        ),
        DeclareLaunchArgument(
            name='P1',
            default_value='200.0',
            description=
            'The first parameter ccontrolling the disparity smoothness '
            '(Semi-Global Block Matching only)'),
        DeclareLaunchArgument(
            name='P2',
            default_value='400.0',
            description=
            'The second parameter ccontrolling the disparity smoothness '
            '(Semi-Global Block Matching only)'),
        DeclareLaunchArgument(
            name='full_dp',
            default_value='False',
            description=
            'Run the full variant of the algorithm (Semi-Global Block Matching only)'
        ),
        ComposableNodeContainer(
            condition=LaunchConfigurationEquals('container', ''),
            package='rclcpp_components',
            executable='component_container',
            name='stereo_image_proc_container',
            namespace='',
            composable_node_descriptions=composable_nodes,
        ),
        LoadComposableNodes(
            condition=LaunchConfigurationNotEquals('container', ''),
            composable_node_descriptions=composable_nodes,
            target_container=LaunchConfiguration('container'),
        ),
        # If a container name is not provided,
        # set the name of the container launched above for image_proc nodes
        SetLaunchConfiguration(condition=LaunchConfigurationEquals(
            'container', ''),
                               name='container',
                               value='stereo_image_proc_container'),
        GroupAction(
            [
                PushRosNamespace(LaunchConfiguration('left_namespace')),
                IncludeLaunchDescription(PythonLaunchDescriptionSource([
                    FindPackageShare('image_proc'),
                    '/launch/image_proc.launch.py'
                ]),
                                         launch_arguments={
                                             'container':
                                             LaunchConfiguration('container')
                                         }.items()),
            ],
            condition=IfCondition(LaunchConfiguration('launch_image_proc')),
        ),
        GroupAction(
            [
                PushRosNamespace(LaunchConfiguration('right_namespace')),
                IncludeLaunchDescription(PythonLaunchDescriptionSource([
                    FindPackageShare('image_proc'),
                    '/launch/image_proc.launch.py'
                ]),
                                         launch_arguments={
                                             'container':
                                             LaunchConfiguration('container')
                                         }.items()),
            ],
            condition=IfCondition(LaunchConfiguration('launch_image_proc')),
        )
    ])
Example #19
0
def generate_launch_description():
    """
    Launch all nodes defined in the architecture for Milestone 3 of the AVP 2020 Demo.

    More details about what is included can
    be found at https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto/-/milestones/25.
    """
    avp_demo_pkg_prefix = get_package_share_directory('autoware_auto_avp_demo')
    euclidean_cluster_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/euclidean_cluster.param.yaml')
    ray_ground_classifier_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/ray_ground_classifier.param.yaml')
    rviz_cfg_path = os.path.join(avp_demo_pkg_prefix, 'config/ms3.rviz')
    scan_downsampler_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/scan_downsampler_ms3.param.yaml')
    recordreplay_planner_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/recordreplay_planner.param.yaml')
    lanelet2_map_provider_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/lanelet2_map_provider.param.yaml')
    lane_planner_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/lane_planner.param.yaml')
    parking_planner_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/parking_planner.param.yaml')
    object_collision_estimator_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/object_collision_estimator.param.yaml')
    behavior_planner_param_file = os.path.join(
        avp_demo_pkg_prefix, 'param/behavior_planner.param.yaml')

    point_cloud_fusion_pkg_prefix = get_package_share_directory(
        'point_cloud_fusion')

    avp_web_interface_pkg_prefix = get_package_share_directory(
        'avp_web_interface')
    web_files_root = os.path.join(avp_web_interface_pkg_prefix, 'web')

    # Arguments

    euclidean_cluster_param = DeclareLaunchArgument(
        'euclidean_cluster_param_file',
        default_value=euclidean_cluster_param_file,
        description='Path to config file for Euclidean Clustering'
    )
    ray_ground_classifier_param = DeclareLaunchArgument(
        'ray_ground_classifier_param_file',
        default_value=ray_ground_classifier_param_file,
        description='Path to config file for Ray Ground Classifier'
    )
    with_rviz_param = DeclareLaunchArgument(
        'with_rviz',
        default_value='True',
        description='Launch RVIZ2 in addition to other nodes'
    )
    scan_downsampler_param = DeclareLaunchArgument(
        'scan_downsampler_param_file',
        default_value=scan_downsampler_param_file,
        description='Path to config file for lidar scan downsampler'
    )
    recordreplay_planner_param = DeclareLaunchArgument(
        'recordreplay_planner_param_file',
        default_value=recordreplay_planner_param_file,
        description='Path to config file for record/replay planner'
    )
    lanelet2_map_provider_param = DeclareLaunchArgument(
        'lanelet2_map_provider_param_file',
        default_value=lanelet2_map_provider_param_file,
        description='Path to parameter file for Lanelet2 Map Provider'
    )
    lane_planner_param = DeclareLaunchArgument(
        'lane_planner_param_file',
        default_value=lane_planner_param_file,
        description='Path to parameter file for lane planner'
    )
    parking_planner_param = DeclareLaunchArgument(
        'parking_planner_param_file',
        default_value=parking_planner_param_file,
        description='Path to paramter file for parking planner'
    )
    object_collision_estimator_param = DeclareLaunchArgument(
        'object_collision_estimator_param_file',
        default_value=object_collision_estimator_param_file,
        description='Path to paramter file for object collision estimator'
    )
    behavior_planner_param = DeclareLaunchArgument(
        'behavior_planner_param_file',
        default_value=behavior_planner_param_file,
        description='Path to paramter file for behavior planner'
    )

    # Nodes

    euclidean_clustering = Node(
        package='euclidean_cluster_nodes',
        node_executable='euclidean_cluster_node_exe',
        node_namespace='perception',
        parameters=[LaunchConfiguration('euclidean_cluster_param_file')],
        remappings=[
            ("points_in", "points_nonground")
        ]
    )
    # point cloud fusion runner to fuse front and rear lidar

    point_cloud_fusion = IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                os.path.join(point_cloud_fusion_pkg_prefix,
                             'launch/vlp16_sim_lexus_pc_fusion.launch.py'))
    )
    ray_ground_classifier = Node(
        package='ray_ground_classifier_nodes',
        node_executable='ray_ground_classifier_cloud_node_exe',
        node_namespace='perception',
        parameters=[LaunchConfiguration('ray_ground_classifier_param_file')],
        remappings=[("points_in", "/lidars/points_fused")]
    )
    rviz2 = Node(
        package='rviz2',
        node_executable='rviz2',
        node_name='rviz2',
        arguments=['-d', str(rviz_cfg_path)],
        condition=IfCondition(LaunchConfiguration('with_rviz')),
        remappings=[("initialpose", "/localization/initialpose"),
                    ("goal_pose", "/planning/goal_pose")],
    )
    scan_downsampler = Node(
        package='voxel_grid_nodes',
        node_executable='voxel_grid_node_exe',
        node_namespace='lidars',
        node_name='voxel_grid_cloud_node',
        parameters=[LaunchConfiguration('scan_downsampler_param_file')],
        remappings=[
            ("points_in", "points_fused"),
            ("points_downsampled", "points_fused_downsampled")
        ]
    )
    recordreplay_planner = Node(
        package='recordreplay_planner_node',
        node_executable='recordreplay_planner_node_exe',
        node_name='recordreplay_planner',
        node_namespace='planning',
        parameters=[LaunchConfiguration('recordreplay_planner_param_file')],
        remappings=[
            ('vehicle_state', '/vehicle/vehicle_kinematic_state'),
            ('planned_trajectory', '/planning/trajectory'),
            ('obstacle_bounding_boxes', '/perception/lidar_bounding_boxes'),
        ]
    )
    lanelet2_map_provider = Node(
        package='lanelet2_map_provider',
        node_executable='lanelet2_map_provider_exe',
        node_namespace='had_maps',
        parameters=[LaunchConfiguration('lanelet2_map_provider_param_file')]
    )
    lanelet2_map_visualizer = Node(
        package='lanelet2_map_provider',
        node_executable='lanelet2_map_visualizer_exe',
        node_namespace='had_maps'
    )
    global_planner = Node(
        package='lanelet2_global_planner_node',
        node_name='lanelet2_global_planner_node',
        node_namespace='planning',
        node_executable='lanelet2_global_planner_node_exe',
        remappings=[('HAD_Map_Client', '/had_maps/HAD_Map_Service'),
                    ('vehicle_kinematic_state', '/vehicle/vehicle_kinematic_state')]
    )
    lane_planner = Node(
        package='lane_planner_node',
        node_name='lane_planner_node',
        node_namespace='planning',
        node_executable='lane_planner_node_exe',
        parameters=[LaunchConfiguration('lane_planner_param_file')],
        remappings=[('HAD_Map_Service', '/had_maps/HAD_Map_Service')]
    )
    parking_planner = Node(
        package='parking_planner_node',
        node_name='parking_planner_node',
        node_namespace='planning',
        node_executable='parking_planner_node_exe',
        parameters=[LaunchConfiguration('parking_planner_param_file')],
        remappings=[('HAD_Map_Service', '/had_maps/HAD_Map_Service')]
    )
    object_collision_estimator = Node(
        package='object_collision_estimator_node',
        node_name='object_collision_estimator_node',
        node_namespace='planning',
        node_executable='object_collision_estimator_node_exe',
        parameters=[LaunchConfiguration('object_collision_estimator_param_file')],
        remappings=[
            ('obstacle_topic', '/perception/lidar_bounding_boxes'),
        ]
    )
    behavior_planner = Node(
        package='behavior_planner_node',
        node_name='behavior_planner_node',
        node_namespace='planning',
        node_executable='behavior_planner_node_exe',
        parameters=[LaunchConfiguration('behavior_planner_param_file')],
        output='screen',
        remappings=[
            ('HAD_Map_Service', '/had_maps/HAD_Map_Service'),
            ('vehicle_state', '/vehicle/vehicle_kinematic_state'),
            ('route', 'global_path'),
            ('vehicle_state_report', '/vehicle/state_report'),
            ('vehicle_state_command', '/vehicle/state_command')
        ]
    )

    web_bridge = Node(
        package='rosbridge_server',
        node_name='rosbridge_server_node',
        node_namespace='gui',
        node_executable='rosbridge_websocket'
    )

    web_server = ExecuteProcess(
      cmd=["python3", "-m", "http.server", "8000"],
      cwd=web_files_root
    )

    return LaunchDescription([
        euclidean_cluster_param,
        ray_ground_classifier_param,
        scan_downsampler_param,
        with_rviz_param,
        recordreplay_planner_param,
        lanelet2_map_provider_param,
        lane_planner_param,
        parking_planner_param,
        object_collision_estimator_param,
        behavior_planner_param,
        euclidean_clustering,
        ray_ground_classifier,
        scan_downsampler,
        recordreplay_planner,
        point_cloud_fusion,
        lanelet2_map_provider,
        lanelet2_map_visualizer,
        global_planner,
        lane_planner,
        parking_planner,
        object_collision_estimator,
        behavior_planner,
        rviz2,
        web_server,
        web_bridge,
    ])
Example #20
0
def generate_launch_description():
    # Get the launch directory
    exp_bringup_dir = get_package_share_directory('social_nav2_exp_bringup')
    social_bringup_dir = get_package_share_directory('social_nav2_bringup')
    launch_dir = os.path.join(social_bringup_dir, 'launch')

    # Declare the launch options
    scene_file = LaunchConfiguration('scene_file')
    simulation_factor = LaunchConfiguration('simulation_factor')
    frame_id = LaunchConfiguration('frame_id')

    # Create the launch configuration variables
    namespace = LaunchConfiguration('namespace')
    frame_id_cmd = DeclareLaunchArgument('frame_id',
                                         default_value='map',
                                         description='Reference frame')
    social_nav_bringup_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(launch_dir, 'tb3_house_simulation_launch.py')))

    social_goal_updater_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(
                get_package_share_directory('social_nav2_goal_updaters'),
                'launch', 'social_goal_updaters_launch.py')))

    distance_to_agent_cmd = Node(package='measuring_tools',
                                 executable='distance_to_agent_node',
                                 name='distance_to_agent_node',
                                 output='screen',
                                 arguments=["agent_3"])

    robot_cost_cmd = Node(package='measuring_tools',
                          executable='robot_cost_node',
                          name='robot_cost_node',
                          output='screen')

    path_cmd = Node(package='measuring_tools',
                    executable='path_pub_node',
                    name='path_pub_node',
                    output='screen')

    topics_2_csv_cmd = Node(package='social_nav2_csv',
                            executable='topics_2_csv',
                            name='topics_2_csv',
                            output='screen')

    social_nav_bringup_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(launch_dir, 'social_nav_launch.py')))

    approach_sim = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(exp_bringup_dir, 'launch', 'approach_sim_launch.py')))

    # Create the launch description and populate
    ld = LaunchDescription()
    ld.add_action(frame_id_cmd)

    ld.add_action(robot_cost_cmd)
    ld.add_action(distance_to_agent_cmd)
    ld.add_action(path_cmd)
    ld.add_action(topics_2_csv_cmd)

    ld.add_action(social_goal_updater_cmd)
    ld.add_action(approach_sim)
    ld.add_action(social_nav_bringup_cmd)
    return ld
Example #21
0
def generate_launch_description():
    share_dir_path = os.path.join(get_package_share_directory('dynamixel_hardware_interface'))
    xacro_path = os.path.join(
        share_dir_path,
        'config',
        'urdf',
        '2dof_robot_arm_robot.urdf.xacro')

    doc = xacro.process_file(xacro_path)
    robot_description = {"robot_description": doc.toxml()}
    robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='both',
        parameters=[robot_description])
    view_model = LaunchConfiguration('view_model', default=False)
    view_model_arg = DeclareLaunchArgument(
                'view_model', default_value=view_model,
                description="if true, launch Autoware with given rviz configuration.")
    rviz = Node(
                package='rviz2',
                executable='rviz2',
                name='rviz2',
                output={
                    'stderr': 'log',
                    'stdout': 'log',
                    },
                condition=IfCondition(view_model),
                arguments=[
                    '-d', str(
                        Path(get_package_share_directory('dynamixel_hardware_interface')) /
                        'config' /
                        '2dof_robot_arm.rviz')])
    controller_config = os.path.join(
        get_package_share_directory("dynamixel_hardware_interface"),
        "config",
        "controllers",
        "controllers_2dof_robot_arm.yaml"
    )
    control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        parameters=[robot_description, controller_config],
        output={
            "stdout": "screen",
            "stderr": "screen",
        },
    )

    return launch.LaunchDescription(
        [
            robot_state_publisher,
            view_model_arg,
            rviz,
            control_node,
            ExecuteProcess(
                cmd=[
                    "ros2",
                    "control",
                    "load_start_controller",
                    "joint_state_controller"],
                output="screen",
                shell=True,
            ),
            ExecuteProcess(
                cmd=[
                    "ros2",
                    "control",
                    "load_configure_controller",
                    "velocity_controller"],
                output="screen",
                shell=True,
            ),
            ExecuteProcess(
                cmd=[
                    "ros2",
                    "control",
                    "load_configure_controller",
                    "joint_trajectory_controller"],
                output="screen",
                shell=True,
            )
        ]
    )
def generate_launch_description():
    nav2_bringup_dir = get_package_share_directory('nav2_bringup')
    nav2_launch_dir = os.path.join(nav2_bringup_dir, 'launch')
    package_dir = get_package_share_directory('robots')

    slam = LaunchConfiguration('slam')
    namespace = LaunchConfiguration('namespace')
    use_namespace = LaunchConfiguration('use_namespace')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename')
    autostart = LaunchConfiguration('autostart')

    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace', default_value='', description='Top-level namespace')

    declare_use_namespace_cmd = DeclareLaunchArgument(
        'use_namespace',
        default_value='false',
        description='Whether to apply a namespace to the navigation stack')

    declare_slam_cmd = DeclareLaunchArgument('slam',
                                             default_value='False',
                                             description='Whether run a SLAM')

    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map',
        default_value=os.path.join(package_dir, 'worlds', 'apartment.yaml'),
        description='Full path to map file to load')

    declare_use_sim_time_cmd = DeclareLaunchArgument(
        'use_sim_time',
        default_value='true',
        description='Use simulation (Gazebo) clock if true')

    declare_params_file_cmd = DeclareLaunchArgument(
        'params_file',
        default_value=os.path.join(package_dir, 'params', 'nav2_params.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

    declare_bt_xml_cmd = DeclareLaunchArgument(
        'default_bt_xml_filename',
        default_value=os.path.join(
            get_package_share_directory('nav2_bt_navigator'), 'behavior_trees',
            'navigate_w_replanning_and_recovery.xml'),
        description='Full path to the behavior tree xml file to use')

    declare_autostart_cmd = DeclareLaunchArgument(
        'autostart',
        default_value='true',
        description='Automatically startup the nav2 stack')

    webots = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('webots_ros2_core'), 'launch',
                     'robot_launch.py')),
                                      launch_arguments={
                                          'executable':
                                          'webots_differential_drive_node',
                                          'world':
                                          os.path.join(
                                              package_dir, 'worlds',
                                              'complete_apartment.wbt'),
                                          'node_parameters':
                                          os.path.join(package_dir, 'resource',
                                                       'tiago.yaml'),
                                          'use_sim_time':
                                          use_sim_time
                                      }.items())

    head2camera = launch_ros.actions.Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        arguments=[
            '0.0', '0.0', '0.00', '.0', '0.0', '3.1415', 'head_2_link',
            'camera'
        ],
        parameters=[{
            'use_sim_time': use_sim_time
        }],
    )
    head2rangefinder = launch_ros.actions.Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        arguments=[
            '0.0', '0.0', '0.00', '0.0', '0.0', '3.1415', 'head_2_link',
            'range-finder'
        ],
        parameters=[{
            'use_sim_time': use_sim_time
        }])
    baselink2bf = launch_ros.actions.Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        arguments=[
            '0.0', '0.0', '0.00', '0.0', '0.0', '0.0', 'base_link',
            'base_footprint'
        ],
        parameters=[{
            'use_sim_time': use_sim_time
        }])

    # Rviz node
    use_rviz = launch.substitutions.LaunchConfiguration('rviz', default=False)
    rviz_config = os.path.join(get_package_share_directory('robots'),
                               'resource', 'odometry.rviz')
    rviz = launch_ros.actions.Node(
        package='rviz2',
        executable='rviz2',
        output='screen',
        arguments=['--display-config=' + rviz_config],
        condition=launch.conditions.IfCondition(use_rviz),
        parameters=[{
            'use_sim_time': use_sim_time
        }])

    pointcloud_xyz = launch_ros.actions.ComposableNodeContainer(
        name='container',
        namespace='',
        package='rclcpp_components',
        executable='component_container',
        composable_node_descriptions=[
            # Driver itself
            launch_ros.descriptions.ComposableNode(
                package='depth_image_proc',
                plugin='depth_image_proc::PointCloudXyzrgbNode',
                name='point_cloud_xyz_node',
                remappings=[('rgb/camera_info', '/camera/camera_info'),
                            ('rgb/image_rect_color', '/camera/image_raw'),
                            ('depth_registered/image_rect',
                             '/range_finder/image_depth'),
                            ('points', '/depth_registered/points')],
                parameters=[{
                    'use_sim_time': use_sim_time
                }]),
        ],
        parameters=[{
            'use_sim_time': use_sim_time
        }],
        output='screen',
    )

    nav2_bringup_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(nav2_launch_dir, 'bringup_launch.py')),
                                                launch_arguments={
                                                    'namespace': namespace,
                                                    'use_namespace':
                                                    use_namespace,
                                                    'slam': slam,
                                                    'map': map_yaml_file,
                                                    'use_sim_time':
                                                    use_sim_time,
                                                    'params_file': params_file,
                                                    'default_bt_xml_filename':
                                                    default_bt_xml_filename,
                                                    'autostart': autostart
                                                }.items())

    ld = LaunchDescription()

    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_use_namespace_cmd)
    ld.add_action(declare_slam_cmd)
    ld.add_action(declare_map_yaml_cmd)
    ld.add_action(declare_use_sim_time_cmd)
    ld.add_action(declare_params_file_cmd)
    ld.add_action(declare_bt_xml_cmd)
    ld.add_action(declare_autostart_cmd)

    ld.add_action(baselink2bf)

    ld.add_action(webots)
    ld.add_action(nav2_bringup_cmd)

    return ld
Example #23
0
def generate_launch_description():
    # Get the launch directory
    bringup_dir = '.'

    # Create the launch configuration variables
    namespace = LaunchConfiguration('namespace')
    use_namespace = LaunchConfiguration('use_namespace')
    rviz_config_file = LaunchConfiguration('rviz_config')

    # Declare the launch arguments
    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace',
        default_value='navigation',
        description=(
            'Top-level namespace. The value will be used to replace the '
            '<robot_namespace> keyword on the rviz config file.'))

    declare_use_namespace_cmd = DeclareLaunchArgument(
        'use_namespace',
        default_value='false',
        description='Whether to apply a namespace to the navigation stack')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config',
        default_value=os.path.join(bringup_dir, 'rviz',
                                   'nav2_default_view.rviz'),
        description='Full path to the RVIZ config file to use')

    # Launch rviz
    start_rviz_cmd = Node(condition=UnlessCondition(use_namespace),
                          package='rviz2',
                          executable='rviz2',
                          name='rviz2',
                          arguments=['-d', rviz_config_file],
                          output='screen')

    namespaced_rviz_config_file = rviz_config_file

    start_namespaced_rviz_cmd = Node(
        condition=IfCondition(use_namespace),
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        namespace=namespace,
        arguments=['-d', namespaced_rviz_config_file],
        output='screen',
        remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static'),
                    ('/goal_pose', 'goal_pose'),
                    ('/clicked_point', 'clicked_point'),
                    ('/initialpose', 'initialpose')])

    exit_event_handler = RegisterEventHandler(
        condition=UnlessCondition(use_namespace),
        event_handler=OnProcessExit(
            target_action=start_rviz_cmd,
            on_exit=EmitEvent(event=Shutdown(reason='rviz exited'))))

    exit_event_handler_namespaced = RegisterEventHandler(
        condition=IfCondition(use_namespace),
        event_handler=OnProcessExit(
            target_action=start_namespaced_rviz_cmd,
            on_exit=EmitEvent(event=Shutdown(reason='rviz exited'))))

    # Create the launch description and populate
    ld = LaunchDescription()

    # Declare the launch options
    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_use_namespace_cmd)
    ld.add_action(declare_rviz_config_file_cmd)

    # Add any conditioned actions
    ld.add_action(start_rviz_cmd)
    ld.add_action(start_namespaced_rviz_cmd)

    # Add other nodes and processes we need
    ld.add_action(exit_event_handler)
    ld.add_action(exit_event_handler_namespaced)

    return ld
Example #24
0
def generate_launch_description():
    namespace = LaunchConfiguration('namespace')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    use_remappings = LaunchConfiguration('use_remappings')

    # TODO(orduno) Remove once `PushNodeRemapping` is resolved
    #              https://github.com/ros2/launch_ros/issues/56
    remappings = [((namespace, '/tf'), '/tf'),
                  ((namespace, '/tf_static'), '/tf_static'),
                  ('/tf', 'tf'),
                  ('/tf_static', 'tf_static')]

    # Create our own temporary YAML files that include substitutions
    param_substitutions = {
        'use_sim_time': use_sim_time,
        'yaml_filename': map_yaml_file}

    configured_params = RewrittenYaml(
        source_file=params_file,
        root_key=namespace,
        param_rewrites=param_substitutions,
        convert_types=True)

    return LaunchDescription([
        # Set env var to print messages to stdout immediately
        SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'),

        DeclareLaunchArgument(
            'namespace',
            default_value='',
            description='Top-level namespace'),

        DeclareLaunchArgument(
            'map',
            description='Full path to map yaml file to load'),

        DeclareLaunchArgument(
            'use_sim_time', default_value='false',
            description='Use simulation (Gazebo) clock if true'),

        DeclareLaunchArgument(
            'params_file',
            description='Full path to the ROS2 parameters file to use'),

        DeclareLaunchArgument(
            'use_remappings',
            default_value='false',
            description='Arguments to pass to all nodes launched by the file'),

        Node(
            package='nav2_map_server',
            node_executable='map_server',
            node_name='map_server',
            output='screen',
            parameters=[configured_params],
            use_remappings=IfCondition(use_remappings),
            remappings=remappings),

        Node(
            package='nav2_amcl',
            node_executable='amcl',
            node_name='amcl',
            output='screen',
            parameters=[configured_params],
            use_remappings=IfCondition(use_remappings),
            remappings=remappings),

    ])
def generate_launch_description():
    tf_exchange_dir = get_package_share_directory('tf_exchange')
    #rviz_config_file = LaunchConfiguration('rviz_config')
    #map_yaml_file = LaunchConfiguration('map')
    bringup_dir = get_package_share_directory('nav2_bringup')
    slam = LaunchConfiguration('slam')

    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map',
        default_value=os.path.join(bringup_dir, 'maps',
                                   'turtlebot3_world.yaml'),
        description='Full path to map file to load')

    declare_robot_name = DeclareLaunchArgument('robot_name',
                                               default_value='robot1')
    declare_base_frame = DeclareLaunchArgument('base_frame',
                                               default_value='base_link')
    declare_x_pose = DeclareLaunchArgument(
        'x_pose',
        default_value=launch.substitutions.TextSubstitution(text='0.0'))
    declare_y_pose = DeclareLaunchArgument(
        'y_pose',
        default_value=launch.substitutions.TextSubstitution(text='0.0'))
    declare_z_pose = DeclareLaunchArgument(
        'z_pose',
        default_value=launch.substitutions.TextSubstitution(text='0.0'))
    declare_yaw_pose = DeclareLaunchArgument(
        'yaw_pose',
        default_value=launch.substitutions.TextSubstitution(text='0.0'))
    declare_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='True', description='Whether to start RVIZ')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config',
        default_value=os.path.join(
            get_package_share_directory('robot_spawner_pkg'), 'custom.rviz'),
        description='Full path to the RVIZ config file to use.')

    declare_slam_cmd = DeclareLaunchArgument('slam',
                                             default_value='False',
                                             description='Whether run a SLAM')

    declare_behaviour_cmd = DeclareLaunchArgument(
        'behaviour',
        default_value='True',
        description='Whether run the default behaviour.')

    tf_exchange = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(tf_exchange_dir, 'tf_exchange.launch.py')),
        launch_arguments={
            'namespace': LaunchConfiguration('robot_name'),
            'robot_name': LaunchConfiguration('robot_name'),
            'base_frame': LaunchConfiguration('base_frame')
            #'params_file': [LaunchConfiguration('robot_name'), launch.substitutions.TextSubstitution(text='_params_file')]
        }.items())

    spawner = launch_ros.actions.Node(
        package='robot_spawner_pkg',
        executable='nav2_gazebo_spawner',
        output='screen',
        arguments=[
            '--robot_name',
            LaunchConfiguration('robot_name'),
            '--robot_namespace',
            LaunchConfiguration('robot_name'),
            '--turtlebot_type',
            launch.substitutions.EnvironmentVariable('TURTLEBOT3_MODEL'),
            '-x',
            LaunchConfiguration('x_pose'),
            '-y',
            LaunchConfiguration('y_pose'),
            '-z',
            LaunchConfiguration('z_pose'),
            '-yaw',
            LaunchConfiguration('yaw_pose'),
        ])

    rviz = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(bringup_dir, 'launch', 'rviz_launch.py')),
                                    condition=IfCondition(
                                        LaunchConfiguration('use_rviz')),
                                    launch_arguments={
                                        'namespace':
                                        LaunchConfiguration('robot_name'),
                                        'use_namespace':
                                        'true',
                                        'use_sim_time':
                                        'true'
                                    }.items())  #,
    #'rviz_config': rviz_config_file}.items())

    namespace = LaunchConfiguration('robot_name')
    use_sim_time = TextSubstitution(text='True')
    autostart = 'True'
    params_file = os.path.join(
        get_package_share_directory('robot_spawner_pkg'),
        'nav2_multirobot_params_1.yaml')
    urdf = os.path.join(get_package_share_directory('turtlebot3_description'),
                        'urdf', 'turtlebot3_burger.urdf')

    bringup_cmd_group = GroupAction([
        launch_ros.actions.PushRosNamespace(namespace=namespace),
        launch_ros.actions.Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            name='robot_state_publisher',
            #namespace=namespace,
            output='screen',
            parameters=[{
                'use_sim_time': use_sim_time
            }],
            arguments=[urdf],
            remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static')]),
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            os.path.join(bringup_dir, 'launch', 'slam_launch.py')),
                                 condition=IfCondition(slam),
                                 launch_arguments={
                                     'namespace': namespace,
                                     'use_sim_time': use_sim_time,
                                     'autostart': autostart,
                                     'params_file': params_file
                                 }.items()),
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            os.path.join(bringup_dir, 'launch', 'localization_launch.py')),
                                 condition=IfCondition(
                                     PythonExpression(['not ', slam])),
                                 launch_arguments={
                                     'namespace': namespace,
                                     'map': LaunchConfiguration('map'),
                                     'use_sim_time': use_sim_time,
                                     'autostart': autostart,
                                     'params_file': params_file,
                                     'use_lifecycle_mgr': 'false'
                                 }.items())
    ])

    drive = launch_ros.actions.Node(
        executable='turtlebot3_drive',
        condition=IfCondition(LaunchConfiguration('behaviour')),
        package='turtlebot3_gazebo',
        namespace=LaunchConfiguration('robot_name'),
    )

    ld = LaunchDescription()
    ld.add_action(declare_map_yaml_cmd)
    ld.add_action(declare_robot_name)
    ld.add_action(declare_base_frame)
    ld.add_action(declare_x_pose)
    ld.add_action(declare_y_pose)
    ld.add_action(declare_z_pose)
    ld.add_action(declare_yaw_pose)
    ld.add_action(declare_use_rviz_cmd)
    ld.add_action(declare_slam_cmd)
    ld.add_action(declare_behaviour_cmd)
    ld.add_action(declare_rviz_config_file_cmd)
    ld.add_action(spawner)
    ld.add_action(rviz)
    ld.add_action(bringup_cmd_group)
    ld.add_action(tf_exchange)
    ld.add_action(drive)
    return ld
Example #26
0
def set_configurable_parameters(parameters):
    return dict([(param['name'], LaunchConfiguration(param['name']))
                 for param in parameters])
def generate_launch_description():
    """
    Launch a minimal joystick + LGSVL demo.

    The joystick_vehicle_interface and the lgsvl_interface
    are modified via parameter remapping to use VehicleControlCommand as an output.
    The vehicle can be controlled by manipulating the left joystick of the gamepad.
    """
    # --------------------------------- Params -------------------------------

    # In combination 'raw', 'basic' and 'high_level' control
    # in what mode of control comands to operate in,
    # only one of them can be active at a time with a value
    control_command_param = DeclareLaunchArgument(
        'control_command',
        default_value="raw",  # use "raw", "basic" or "high_level"
        description='command control mode topic name')

    # Default joystick translator params
    joy_translator_param = DeclareLaunchArgument(
        'joy_translator_param',
        default_value=[
            get_share_file('joystick_vehicle_interface',
                           'param/logitech_f310.default.param.yaml')
        ],
        description='Path to config file for joystick translator')

    # Default lgsvl_interface params
    lgsvl_interface_param = DeclareLaunchArgument(
        'lgsvl_interface_param',
        default_value=[
            get_share_file('lgsvl_interface', 'param/lgsvl.param.yaml')
        ],
        description='Path to config file for lgsvl interface')

    # -------------------------------- Nodes-----------------------------------
    # Include Joystick launch
    joystick_launch_file_path = get_share_file(
        'joystick_vehicle_interface',
        'launch/joystick_vehicle_interface.launch.py')
    joystick = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(joystick_launch_file_path),
        launch_arguments={
            "joy_translator_param":
            LaunchConfiguration("joy_translator_param"),
            "control_command": LaunchConfiguration('control_command')
        }.items())

    # Include LGSVL interface launch
    lgsvl_launch_file_path = get_share_file('lgsvl_interface',
                                            'launch/lgsvl.launch.py')
    lgsvl = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(lgsvl_launch_file_path),
        launch_arguments={
            "lgsvl_interface_param":
            LaunchConfiguration("lgsvl_interface_param"),
            "control_command": LaunchConfiguration('control_command')
        }.items())

    return LaunchDescription([
        control_command_param, joy_translator_param, lgsvl_interface_param,
        joystick, lgsvl
    ])
Example #28
0
def generate_launch_description():
    if (os.getenv('ROS_DISTRO') == "dashing") or (os.getenv('ROS_DISTRO')
                                                  == "eloquent"):
        return LaunchDescription(
            declare_configurable_parameters(configurable_parameters) + [
                # Realsense
                launch_ros.actions.Node(
                    condition=IfCondition(
                        PythonExpression(
                            [LaunchConfiguration('config_file'), " == ''"])),
                    package='realsense2_camera',
                    node_namespace=LaunchConfiguration("camera_name"),
                    node_name=LaunchConfiguration("camera_name"),
                    node_executable='realsense2_camera_node',
                    prefix=['stdbuf -o L'],
                    parameters=[
                        set_configurable_parameters(configurable_parameters)
                    ],
                    output='screen',
                    arguments=[
                        '--ros-args', '--log-level',
                        LaunchConfiguration('log_level')
                    ],
                ),
                launch_ros.actions.Node(
                    condition=IfCondition(
                        PythonExpression(
                            [LaunchConfiguration('config_file'), " != ''"])),
                    package='realsense2_camera',
                    node_namespace=LaunchConfiguration("camera_name"),
                    node_name=LaunchConfiguration("camera_name"),
                    node_executable='realsense2_camera_node',
                    prefix=['stdbuf -o L'],
                    parameters=[
                        set_configurable_parameters(configurable_parameters),
                        PythonExpression([LaunchConfiguration("config_file")])
                    ],
                    output='screen',
                    arguments=[
                        '--ros-args', '--log-level',
                        LaunchConfiguration('log_level')
                    ],
                ),
            ])
    else:
        return LaunchDescription(
            declare_configurable_parameters(configurable_parameters) + [
                # Realsense
                launch_ros.actions.Node(
                    condition=IfCondition(
                        PythonExpression(
                            [LaunchConfiguration('config_file'), " == ''"])),
                    package='realsense2_camera',
                    namespace=LaunchConfiguration("camera_name"),
                    name=LaunchConfiguration("camera_name"),
                    executable='realsense2_camera_node',
                    parameters=[
                        set_configurable_parameters(configurable_parameters)
                    ],
                    remappings=[
                        ('/camera/odom/sample', '/mammoth/odom'),
                    ],
                    output='screen',
                    arguments=[
                        '--ros-args', '--log-level',
                        LaunchConfiguration('log_level')
                    ],
                    emulate_tty=True,
                ),
                launch_ros.actions.Node(
                    condition=IfCondition(
                        PythonExpression(
                            [LaunchConfiguration('config_file'), " != ''"])),
                    package='realsense2_camera',
                    namespace=LaunchConfiguration("camera_name"),
                    name=LaunchConfiguration("camera_name"),
                    executable='realsense2_camera_node',
                    parameters=[
                        set_configurable_parameters(configurable_parameters),
                        PythonExpression([LaunchConfiguration("config_file")])
                    ],
                    remappings=[
                        ('/camera/odom/sample', '/mammoth/odom'),
                    ],
                    output='screen',
                    arguments=[
                        '--ros-args', '--log-level',
                        LaunchConfiguration('log_level')
                    ],
                    emulate_tty=True,
                ),
            ])
Example #29
0
def generate_launch_description():
    # Declare arguments
    declared_arguments = []
    declared_arguments.append(
        DeclareLaunchArgument(
            "runtime_config_package",
            default_value="ros2_control_demo_bringup",
            description=
            'Package with the controller\'s configuration in "config" folder. \
        Usually the argument is not set, it enables use of a custom setup.',
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "controllers_file",
            default_value="rrbot_controllers.yaml",
            description="YAML file with the controllers configuration.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "description_package",
            default_value="rrbot_description",
            description=
            "Description package with robot URDF/xacro files. Usually the argument \
        is not set, it enables use of a custom description.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "description_file",
            description="URDF/XACRO description file with the robot.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "prefix",
            default_value='""',
            description="Prefix of the joint names, useful for \
        multi-robot setup. If changed than also joint names in the controllers' configuration \
        have to be updated.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "use_sim",
            default_value="false",
            description="Start robot in Gazebo simulation.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "use_fake_hardware",
            default_value="true",
            description=
            "Start robot with fake hardware mirroring command to its states.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "fake_sensor_commands",
            default_value="false",
            description=
            "Enable fake command interfaces for sensors used for simple simulations. \
            Used only if 'use_fake_hardware' parameter is true.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument("slowdown",
                              default_value="3.0",
                              description="Slowdown factor of the RRbot."))
    declared_arguments.append(
        DeclareLaunchArgument(
            "robot_controller",
            default_value="forward_position_controller",
            description="Robot controller to start.",
        ))
    declared_arguments.append(
        DeclareLaunchArgument(
            "start_rviz",
            default_value="true",
            description="Start RViz2 automatically with this launch file.",
        ))

    # Initialize Arguments
    runtime_config_package = LaunchConfiguration("runtime_config_package")
    controllers_file = LaunchConfiguration("controllers_file")
    description_package = LaunchConfiguration("description_package")
    description_file = LaunchConfiguration("description_file")
    prefix = LaunchConfiguration("prefix")
    use_sim = LaunchConfiguration("use_sim")
    use_fake_hardware = LaunchConfiguration("use_fake_hardware")
    fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
    slowdown = LaunchConfiguration("slowdown")
    robot_controller = LaunchConfiguration("robot_controller")
    start_rviz = LaunchConfiguration("start_rviz")

    # Get URDF via xacro
    robot_description_content = Command([
        PathJoinSubstitution([FindExecutable(name="xacro")]),
        " ",
        PathJoinSubstitution(
            [FindPackageShare(description_package), "urdf", description_file]),
        " ",
        "prefix:=",
        prefix,
        " ",
        "use_sim:=",
        use_sim,
        " ",
        "use_fake_hardware:=",
        use_fake_hardware,
        " ",
        "fake_sensor_commands:=",
        fake_sensor_commands,
        " ",
        "slowdown:=",
        slowdown,
    ])
    robot_description = {"robot_description": robot_description_content}

    robot_controllers = PathJoinSubstitution([
        FindPackageShare(runtime_config_package),
        "config",
        controllers_file,
    ])
    rviz_config_file = PathJoinSubstitution(
        [FindPackageShare(description_package), "config", "rrbot.rviz"])

    control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        parameters=[robot_description, robot_controllers],
        output={
            "stdout": "screen",
            "stderr": "screen",
        },
    )
    robot_state_pub_node = Node(
        package="robot_state_publisher",
        executable="robot_state_publisher",
        output="both",
        parameters=[robot_description],
    )
    rviz_node = Node(
        package="rviz2",
        executable="rviz2",
        name="rviz2",
        output="log",
        arguments=["-d", rviz_config_file],
        condition=IfCondition(start_rviz),
    )

    joint_state_broadcaster_spawner = Node(
        package="controller_manager",
        executable="spawner.py",
        arguments=[
            "joint_state_broadcaster", "--controller-manager",
            "/controller_manager"
        ],
    )

    robot_controller_spawner = Node(
        package="controller_manager",
        executable="spawner.py",
        arguments=[robot_controller, "-c", "/controller_manager"],
    )

    nodes = [
        control_node,
        robot_state_pub_node,
        rviz_node,
        joint_state_broadcaster_spawner,
        robot_controller_spawner,
    ]

    return LaunchDescription(declared_arguments + nodes)
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('nav2_bringup')
    tb3_dir = get_package_share_directory('workshop_ros2_navigation')
    launch_dir = os.path.join(bringup_dir, 'launch')

    # Create the launch configuration variables
    namespace = LaunchConfiguration('namespace')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    bt_xml_file = LaunchConfiguration('bt_xml_file')
    autostart = LaunchConfiguration('autostart')
    use_remappings = LaunchConfiguration('use_remappings')

    # Launch configuration variables specific to simulation
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    use_simulator = LaunchConfiguration('use_simulator')
    use_robot_state_pub = LaunchConfiguration('use_robot_state_pub')
    use_rviz = LaunchConfiguration('use_rviz')
    headless = LaunchConfiguration('headless')
    world = LaunchConfiguration('world')

    # TODO(orduno) Remove once `PushNodeRemapping` is resolved
    #              https://github.com/ros2/launch_ros/issues/56
    remappings = [((namespace, '/tf'), '/tf'),
                  ((namespace, '/tf_static'), '/tf_static'), ('/tf', 'tf'),
                  ('/tf_static', 'tf_static')]

    # Declare the launch arguments
    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace', default_value='', description='Top-level namespace')

    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map',
        default_value=os.path.join(tb3_dir, 'map', 'map.yaml'),
        #default_value=os.path.join(bringup_dir, 'maps', 'turtlebot3_world.yaml'),
        description='Full path to map file to load')

    declare_use_sim_time_cmd = DeclareLaunchArgument(
        'use_sim_time',
        default_value='false',
        description='Use simulation (Gazebo) clock if true')

    declare_params_file_cmd = DeclareLaunchArgument(
        'params_file',
        default_value=os.path.join(tb3_dir, 'param', 'burger.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

    declare_bt_xml_cmd = DeclareLaunchArgument(
        'bt_xml_file',
        default_value=os.path.join(
            get_package_share_directory('nav2_bt_navigator'), 'behavior_trees',
            'navigate_w_replanning_and_recovery.xml'),
        description='Full path to the behavior tree xml file to use')

    declare_autostart_cmd = DeclareLaunchArgument(
        'autostart',
        default_value='false',
        description='Automatically startup the nav2 stack')

    declare_use_remappings_cmd = DeclareLaunchArgument(
        'use_remappings',
        default_value='false',
        description='Arguments to pass to all nodes launched by the file')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config_file',
        default_value=os.path.join(bringup_dir, 'rviz',
                                   'nav2_default_view.rviz'),
        description='Full path to the RVIZ config file to use')

    declare_use_simulator_cmd = DeclareLaunchArgument(
        'use_simulator',
        default_value='False',
        description='Whether to start the simulator')

    declare_use_robot_state_pub_cmd = DeclareLaunchArgument(
        'use_robot_state_pub',
        default_value='False',
        description='Whether to start the robot state publisher')

    declare_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='True', description='Whether to start RVIZ')

    declare_simulator_cmd = DeclareLaunchArgument(
        'headless',
        default_value='False',
        description='Whether to execute gzclient)')

    declare_world_cmd = DeclareLaunchArgument(
        'world',
        # TODO(orduno) Switch back once ROS argument passing has been fixed upstream
        #              https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91
        # default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'),
        #                            'worlds/turtlebot3_worlds/waffle.model'),
        default_value=os.path.join(bringup_dir, 'worlds', 'waffle.model'),
        description='Full path to world model file to load')

    # Specify the actions
    start_gazebo_server_cmd = ExecuteProcess(
        condition=IfCondition(use_simulator),
        cmd=['gzserver', '-s', 'libgazebo_ros_init.so', world],
        cwd=[launch_dir],
        output='screen')

    start_gazebo_client_cmd = ExecuteProcess(condition=IfCondition(
        PythonExpression([use_simulator, ' and not ', headless])),
                                             cmd=['gzclient'],
                                             cwd=[launch_dir],
                                             output='screen')

    urdf = os.path.join(get_package_share_directory('turtlebot3_description'),
                        'urdf', 'turtlebot3_waffle.urdf')

    start_robot_state_publisher_cmd = Node(
        condition=IfCondition(use_robot_state_pub),
        package='robot_state_publisher',
        node_executable='robot_state_publisher',
        node_name='robot_state_publisher',
        output='screen',
        parameters=[{
            'use_sim_time': use_sim_time
        }],
        use_remappings=IfCondition(use_remappings),
        remappings=remappings,
        arguments=[urdf])

    start_rviz_cmd = Node(condition=IfCondition(use_rviz),
                          package='rviz2',
                          node_executable='rviz2',
                          node_name='rviz2',
                          arguments=['-d', rviz_config_file],
                          output='screen',
                          use_remappings=IfCondition(use_remappings),
                          remappings=[('/tf', 'tf'),
                                      ('/tf_static', 'tf_static'),
                                      ('goal_pose', 'goal_pose'),
                                      ('/clicked_point', 'clicked_point'),
                                      ('/initialpose', 'initialpose')])

    exit_event_handler = RegisterEventHandler(
        event_handler=OnProcessExit(target_action=start_rviz_cmd,
                                    on_exit=EmitEvent(event=Shutdown(
                                        reason='rviz exited'))))

    bringup_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(launch_dir, 'nav2_bringup_launch.py')),
                                           launch_arguments={
                                               'namespace': namespace,
                                               'map': map_yaml_file,
                                               'use_sim_time': use_sim_time,
                                               'params_file': params_file,
                                               'bt_xml_file': bt_xml_file,
                                               'autostart': autostart,
                                               'use_remappings': use_remappings
                                           }.items())

    # Create the launch description and populate
    ld = LaunchDescription()

    # Declare the launch options
    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_map_yaml_cmd)
    ld.add_action(declare_use_sim_time_cmd)
    ld.add_action(declare_params_file_cmd)
    ld.add_action(declare_bt_xml_cmd)
    ld.add_action(declare_autostart_cmd)
    ld.add_action(declare_use_remappings_cmd)

    ld.add_action(declare_rviz_config_file_cmd)
    ld.add_action(declare_use_simulator_cmd)
    ld.add_action(declare_use_robot_state_pub_cmd)
    ld.add_action(declare_use_rviz_cmd)
    ld.add_action(declare_simulator_cmd)
    ld.add_action(declare_world_cmd)

    # Add any conditioned actions
    ld.add_action(start_gazebo_server_cmd)
    ld.add_action(start_gazebo_client_cmd)
    ld.add_action(start_rviz_cmd)

    # Add other nodes and processes we need
    ld.add_action(exit_event_handler)

    # Add the actions to launch all of the navigation nodes
    ld.add_action(start_robot_state_publisher_cmd)
    ld.add_action(bringup_cmd)

    return ld