Example #1
0
def generate_launch_description():
    # Get the launch directory
    pkg_dir = get_package_share_directory('go_get_it')
    nav_dir = get_package_share_directory('gb_navigation')
    manipulation_dir = get_package_share_directory('gb_manipulation')
    gb_world_model_dir = get_package_share_directory('gb_world_model')
    world_config_dir = os.path.join(gb_world_model_dir, 'config')

    namespace = LaunchConfiguration('namespace')
    dope_params_file = LaunchConfiguration('dope_params_file')

    declare_dope_params_cmd = DeclareLaunchArgument(
        'dope_params_file',
        default_value=os.path.join(get_package_share_directory('dope_launch'), 'config', 'config_pose.yaml'),
        description='Full path to the TF Pose Estimation parameters file to use')

    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace',
        default_value='',
        description='Namespace')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')
    
    gb_manipulation_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(
            get_package_share_directory('gb_manipulation'),
            'launch',
            'gb_manipulation_launch.py')))
    
    gb_navigation_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(
            get_package_share_directory('gb_navigation'),
            'launch',
            'nav2_tiago_launch.py')))

    plansys2_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(
            get_package_share_directory('plansys2_bringup'),
            'launch',
            'plansys2_bringup_launch_monolithic.py')),
        launch_arguments={'model_file': pkg_dir + '/pddl/domain.pddl:' +
                                        nav_dir + '/pddl/domain.pddl' 
                                        }.items()
        )
    
    dope_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(
            get_package_share_directory('dope_launch'),
            'launch',
            'dope_launch.py')),
        launch_arguments={'dope_params_file': dope_params_file}.items()
    )

    # Specify the actions
    go_get_it_executor_cmd = LifecycleNode(
        package='go_get_it',
        executable='gogetit_executor_node',
        name='gogetit_executor_node')
        
    emit_event_to_request_that_go_get_it_executor_configure_transition = EmitEvent(
        event=ChangeState(
            lifecycle_node_matcher=launch.events.matches_action(go_get_it_executor_cmd),
            transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE,
        )
    )

    emit_event_to_request_that_go_get_it_executor_activate_transition = EmitEvent(
        event=ChangeState(
            lifecycle_node_matcher=launch.events.matches_action(go_get_it_executor_cmd),
            transition_id=lifecycle_msgs.msg.Transition.TRANSITION_ACTIVATE,
        )
    )

    on_configure_go_get_it_executor_handler = RegisterEventHandler(
        OnStateTransition(
            target_lifecycle_node=go_get_it_executor_cmd, goal_state='inactive',
            entities=[emit_event_to_request_that_go_get_it_executor_activate_transition]))

 
    # Specify the dependencies
    vision_cmd = LifecycleNode(
      package='clean_up',
      executable='vision_sim_node',
      name='vision')

    emit_event_to_request_that_vision_configure_transition = EmitEvent(
        event=ChangeState(
            lifecycle_node_matcher=launch.events.matches_action(vision_cmd),
            transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE,
        )
    )

    attention_manager_cmd = Node(
        package='gb_attention',
        executable='attention_server',
        output='screen')

    wm_cmd = Node(
        package='gb_world_model',
        executable='world_model_main',
        output='screen',
        parameters=[
          world_config_dir + '/world.yml'
        ])

    ld = LaunchDescription()

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)
    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_dope_params_cmd)

    # Declare the launch options

    # Event handlers
    ld.add_action(on_configure_go_get_it_executor_handler)

    ld.add_action(gb_manipulation_cmd)
    ld.add_action(gb_navigation_cmd)
    ld.add_action(plansys2_cmd)
    ld.add_action(go_get_it_executor_cmd)
    ld.add_action(vision_cmd)

    ld.add_action(emit_event_to_request_that_vision_configure_transition)
    ld.add_action(emit_event_to_request_that_go_get_it_executor_configure_transition)

    ld.add_action(attention_manager_cmd)
    ld.add_action(wm_cmd)
    ld.add_action(dope_cmd)

    return ld
def generate_launch_description():
    map_yaml_file = os.getenv('TEST_MAP')
    filter_mask_file = os.getenv('TEST_MASK')
    world = os.getenv('TEST_WORLD')

    bt_navigator_xml = os.path.join(get_package_share_directory('nav2_bt_navigator'),
                                    'behavior_trees',
                                    os.getenv('BT_NAVIGATOR_XML'))

    bringup_dir = get_package_share_directory('nav2_bringup')
    script_dir = os.path.dirname(os.path.realpath(__file__))
    params_file = os.path.join(script_dir, 'keepout_params.yaml')

    # Replace the `use_astar` setting on the params file
    param_substitutions = {
        'planner_server.ros__parameters.GridBased.use_astar': os.getenv('ASTAR'),
        'filter_mask_server.ros__parameters.yaml_filename': filter_mask_file,
        'yaml_filename': filter_mask_file}
    configured_params = RewrittenYaml(
        source_file=params_file,
        root_key='',
        param_rewrites=param_substitutions,
        convert_types=True)

    context = LaunchContext()
    new_yaml = configured_params.perform(context)
    return LaunchDescription([
        SetEnvironmentVariable('RCUTILS_LOGGING_BUFFERED_STREAM', '1'),
        SetEnvironmentVariable('RCUTILS_LOGGING_USE_STDOUT', '1'),

        # Launch gazebo server for simulation
        ExecuteProcess(
            cmd=['gzserver', '-s', 'libgazebo_ros_init.so',
                 '--minimal_comms', world],
            output='screen'),

        # TODO(orduno) Launch the robot state publisher instead
        #              using a local copy of TB3 urdf file
        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            output='screen',
            arguments=['0', '0', '0', '0', '0', '0', 'base_footprint', 'base_link']),

        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            output='screen',
            arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'base_scan']),

        Node(
            package='nav2_lifecycle_manager',
            executable='lifecycle_manager',
            name='lifecycle_manager_filters',
            output='screen',
            parameters=[{'node_names': ['filter_mask_server', 'costmap_filter_info_server']},
                        {'autostart': True}]),

        # Nodes required for Costmap Filters configuration
        Node(
            package='nav2_map_server',
            executable='map_server',
            name='filter_mask_server',
            output='screen',
            parameters=[new_yaml]),

        Node(
            package='nav2_map_server',
            executable='costmap_filter_info_server',
            name='costmap_filter_info_server',
            output='screen',
            parameters=[new_yaml]),

        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                os.path.join(bringup_dir, 'launch', 'bringup_launch.py')),
            launch_arguments={'namespace': '',
                              'use_namespace': 'False',
                              'map': map_yaml_file,
                              'use_sim_time': 'True',
                              'params_file': new_yaml,
                              'bt_xml_file': bt_navigator_xml,
                              'autostart': 'True'}.items()),
    ])
Example #3
0
def generate_launch_description():
    use_sim_time = LaunchConfiguration('use_sim_time', default='false')

    parameters=[{
          'queue_size':20,
          'frame_id':'camera_link_d435',
          'use_sim_time':use_sim_time,
          'subscribe_depth':True}]

    remappings=[
          ('odom', 'rs_t265/odom'),
          ('rgb/image', '/rs_d435/image_raw'),
          ('rgb/camera_info', 'rs_d435/image_raw/camera_info'),
          ('depth/image', '/rs_d435/aligned_depth/image_raw')]

    return LaunchDescription([
        #         Node(
        #     package='realsense_ros2',
        #     node_executable='rs_t265_node',
        #     node_name='rs_t265',
        #     output='screen'
        # ),
        # Node(
        #     package='realsense_ros2',
        #     node_executable='rs_d435_node',
        #     node_name='rs_d435',
        #     output='screen',
        #     parameters=[
        #         {"publish_depth": True},
        #         {"publish_pointcloud": False},
        #         {"is_color": False},
        #         {"publish_image_raw_": True},
        #         {"fps": 15}      # Can only take values of 6,15,30 or 60
        #     ]
        # ),
        # Node(
        #     ## Configure the TF of the robot to the origin of the map coordinates
        #     package='tf2_ros',
        #     node_executable='static_transform_publisher',
        #     output='screen',
        #     arguments=['0.0', '0.025', '0.03', '-1.5708', '0.0', '-1.5708', 'camera_link_t265', 'camera_link_d435']
        #     ),

        # Node(
        #     ## Configure the TF of the robot to the origin of the map coordinates
        #     package='tf2_ros',
        #     node_executable='static_transform_publisher',
        #     output='screen',
        #     arguments=['0.0', '0.025', '0.03', '0.0', '0.0', '0.0', 'camera_link_t265', 'camera_link_d435b']
        #     ),

        # Node(
        #     ## Configure the TF of the robot to the origin of the map coordinates
        #     package='tf2_ros',
        #     node_executable='static_transform_publisher',
        #     output='screen',
        #     arguments=['-0.15', '0.0', '0.0', '0.0', '0.0', '0.0', 'camera_link_t265', 'base_link']
        # ),

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

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

        # Nodes to launch
        Node(
            package='rtabmap_ros', node_executable='rtabmap', output='screen',
            parameters=parameters,
            remappings=remappings,
            arguments=['-d']),

        # Node(
        #     package='rtabmap_ros', node_executable='rtabmapviz', output='screen',
        #     parameters=parameters,
        #     remappings=remappings),

    ])
Example #4
0
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('nav2_bringup')

    namespace = LaunchConfiguration('namespace')
    use_sim_time = LaunchConfiguration('use_sim_time')
    autostart = LaunchConfiguration('autostart')
    params_file = LaunchConfiguration('params_file')
    bt_xml_file = LaunchConfiguration('bt_xml_file')
    map_subscribe_transient_local = LaunchConfiguration('map_subscribe_transient_local')

    lifecycle_nodes = ['controller_server',
                       'planner_server',
                       'recoveries_server',
                       'bt_navigator',
                       'waypoint_follower']

    # 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,
        'bt_xml_filename': bt_xml_file,
        'autostart': autostart,
        'map_subscribe_transient_local': map_subscribe_transient_local}

    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(
            'use_sim_time', default_value='false',
            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.yaml'),
            description='Full path to the ROS2 parameters file to use'),

        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'),

        DeclareLaunchArgument(
            'map_subscribe_transient_local', default_value='false',
            description='Whether to set the map subscriber QoS to transient local'),

        Node(
            package='nav2_controller',
            executable='controller_server',
            output='screen',
            parameters=[configured_params],
            remappings=remappings),

        Node(
            package='nav2_planner',
            executable='planner_server',
            name='planner_server',
            output='screen',
            parameters=[configured_params],
            remappings=remappings),

        Node(
            package='nav2_recoveries',
            executable='recoveries_server',
            name='recoveries_server',
            output='screen',
            parameters=[configured_params],
            remappings=remappings),

        Node(
            package='nav2_bt_navigator',
            executable='bt_navigator',
            name='bt_navigator',
            output='screen',
            parameters=[configured_params],
            remappings=remappings),

        Node(
            package='nav2_waypoint_follower',
            executable='waypoint_follower',
            name='waypoint_follower',
            output='screen',
            parameters=[configured_params],
            remappings=remappings),

        Node(
            package='nav2_lifecycle_manager',
            executable='lifecycle_manager',
            name='lifecycle_manager_navigation',
            output='screen',
            parameters=[{'use_sim_time': use_sim_time},
                        {'autostart': autostart},
                        {'node_names': lifecycle_nodes}]),

    ])
Example #5
0
def test_set_and_unset_environment_variable_constructors():
    """Test the constructor for SetEnvironmentVariable and UnsetEnvironmentVariable classes."""
    SetEnvironmentVariable('name', 'value')
    UnsetEnvironmentVariable('name')
def generate_launch_description():
    # 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
    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')

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

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

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

    # Declare the launch arguments
    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map', description='Full path to map yaml 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'),
        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_prefix('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_use_remappings_cmd = DeclareLaunchArgument(
        'use_remappings',
        default_value='false',
        description='Arguments to pass to all nodes launched by the file')

    # Specify the actions
    start_localization_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(launch_dir, 'nav2_localization_launch.py')),
        launch_arguments={
            'namespace': namespace,
            'map': map_yaml_file,
            'use_sim_time': use_sim_time,
            'autostart': autostart,
            'params_file': params_file,
            'use_lifecycle_mgr': 'false',
            'use_remappings': use_remappings
        }.items())

    start_navigation_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(launch_dir, 'nav2_navigation_launch.py')),
        launch_arguments={
            'namespace': namespace,
            'use_sim_time': use_sim_time,
            'autostart': autostart,
            'params_file': params_file,
            'bt_xml_file': bt_xml_file,
            'use_lifecycle_mgr': 'false',
            'use_remappings': use_remappings,
            'map_subscribe_transient_local': 'true'
        }.items())

    start_lifecycle_manager_cmd = Node(package='nav2_lifecycle_manager',
                                       node_executable='lifecycle_manager',
                                       node_name='lifecycle_manager',
                                       output='screen',
                                       parameters=[{
                                           'use_sim_time': use_sim_time
                                       }, {
                                           'autostart': autostart
                                       }, {
                                           'node_names': [
                                               'map_server', 'amcl',
                                               'controller_server',
                                               'planner_server',
                                               'recoveries_server',
                                               'bt_navigator'
                                           ]
                                       }])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)

    # 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_autostart_cmd)
    ld.add_action(declare_bt_xml_cmd)
    ld.add_action(declare_use_remappings_cmd)

    # Add the actions to launch all of the navigation nodes
    ld.add_action(start_lifecycle_manager_cmd)
    ld.add_action(start_localization_cmd)
    ld.add_action(start_navigation_cmd)

    return ld
def generate_launch_description():
    # Get the launch directory
    example_dir = get_package_share_directory('plansys2_simple_example')
    namespace = LaunchConfiguration('namespace')

    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace',
        default_value='',
        description='Namespace')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    plansys2_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(
            get_package_share_directory('plansys2_bringup'),
            'launch',
            'plansys2_bringup_launch_monolithic.py')),
        launch_arguments={
          'model_file': example_dir + '/pddl/simple_example.pddl',
          'namespace': namespace
          }.items())

    # Specify the actions
    move_cmd = Node(
        package='plansys2_simple_example',
        executable='move_action_node',
        name='move_action_node',
        namespace=namespace,
        output='screen',
        parameters=[])

    charge_cmd = Node(
        package='plansys2_simple_example',
        executable='charge_action_node',
        name='charge_action_node',
        namespace=namespace,
        output='screen',
        parameters=[])

    ask_charge_cmd = Node(
        package='plansys2_simple_example',
        executable='ask_charge_action_node',
        name='ask_charge_action_node',
        namespace=namespace,
        output='screen',
        parameters=[])   # Create the launch description and populate
    ld = LaunchDescription()

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)
    ld.add_action(declare_namespace_cmd)

    # Declare the launch options
    ld.add_action(plansys2_cmd)

    ld.add_action(move_cmd)
    ld.add_action(charge_cmd)
    ld.add_action(ask_charge_cmd)

    return ld
Example #8
0
def generate_launch_description():
    # Get the launch directory
    example_dir = get_package_share_directory('plansys_multirobot')
    namespace = LaunchConfiguration('namespace')

    declare_namespace_cmd = DeclareLaunchArgument('namespace',
                                                  default_value='',
                                                  description='Namespace')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    plansys2_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('plansys2_bringup'), 'launch',
                     'plansys2_bringup_launch_monolithic.py')),
                                            launch_arguments={
                                                'model_file': example_dir +
                                                '/pddl/multirobot.pddl',
                                                'namespace': namespace
                                            }.items())

    # Specify the actions
    move_1_cmd = Node(package='plansys2_bt_actions',
                      executable='bt_action_node',
                      name='move_1',
                      namespace=namespace,
                      output='screen',
                      parameters=[
                          example_dir + '/config/params.yaml', {
                              'action_name':
                              'move',
                              'publisher_port':
                              1668,
                              'server_port':
                              1669,
                              'bt_xml_file':
                              example_dir + '/behavior_trees_xml/move.xml'
                          }
                      ])

    move_2_cmd = Node(package='plansys2_bt_actions',
                      executable='bt_action_node',
                      name='move_2',
                      namespace=namespace,
                      output='screen',
                      parameters=[
                          example_dir + '/config/params.yaml', {
                              'action_name':
                              'move',
                              'publisher_port':
                              1670,
                              'server_port':
                              1671,
                              'bt_xml_file':
                              example_dir + '/behavior_trees_xml/move.xml'
                          }
                      ])

    move_3_cmd = Node(package='plansys2_bt_actions',
                      executable='bt_action_node',
                      name='move_3',
                      namespace=namespace,
                      output='screen',
                      parameters=[
                          example_dir + '/config/params.yaml', {
                              'action_name':
                              'move',
                              'publisher_port':
                              1672,
                              'server_port':
                              1673,
                              'bt_xml_file':
                              example_dir + '/behavior_trees_xml/move.xml'
                          }
                      ])

    transport_1_cmd = Node(package='plansys2_bt_actions',
                           executable='bt_action_node',
                           name='transport_1',
                           namespace=namespace,
                           output='screen',
                           parameters=[
                               example_dir + '/config/params.yaml', {
                                   'action_name':
                                   'transport',
                                   'publisher_port':
                                   1674,
                                   'server_port':
                                   1675,
                                   'bt_xml_file':
                                   example_dir +
                                   '/behavior_trees_xml/transport.xml'
                               }
                           ])

    transport_2_cmd = Node(package='plansys2_bt_actions',
                           executable='bt_action_node',
                           name='transport_2',
                           namespace=namespace,
                           output='screen',
                           parameters=[
                               example_dir + '/config/params.yaml', {
                                   'action_name':
                                   'transport',
                                   'publisher_port':
                                   1676,
                                   'server_port':
                                   1677,
                                   'bt_xml_file':
                                   example_dir +
                                   '/behavior_trees_xml/transport.xml'
                               }
                           ])

    transport_3_cmd = Node(package='plansys2_bt_actions',
                           executable='bt_action_node',
                           name='transport_3',
                           namespace=namespace,
                           output='screen',
                           parameters=[
                               example_dir + '/config/params.yaml', {
                                   'action_name':
                                   'transport',
                                   'publisher_port':
                                   1678,
                                   'server_port':
                                   1679,
                                   'bt_xml_file':
                                   example_dir +
                                   '/behavior_trees_xml/transport.xml'
                               }
                           ])

    lift_1_cmd = Node(
        package='plansys_multirobot',
        executable='lift_action_node',
        name='lift_1',
        namespace=namespace,
        output='screen',
        parameters=[])  # Create the launch description and populate
    lift_2_cmd = Node(
        package='plansys_multirobot',
        executable='lift_action_node',
        name='lift_2',
        namespace=namespace,
        output='screen',
        parameters=[])  # Create the launch description and populate
    lift_3_cmd = Node(package='plansys_multirobot',
                      executable='lift_action_node',
                      name='lift_3',
                      namespace=namespace,
                      output='screen',
                      parameters=[])

    drop_1_cmd = Node(
        package='plansys_multirobot',
        executable='drop_action_node',
        name='drop_1',
        namespace=namespace,
        output='screen',
        parameters=[])  # Create the launch description and populate
    drop_2_cmd = Node(
        package='plansys_multirobot',
        executable='drop_action_node',
        name='drop_2',
        namespace=namespace,
        output='screen',
        parameters=[])  # Create the launch description and populate
    drop_3_cmd = Node(package='plansys_multirobot',
                      executable='drop_action_node',
                      name='drop_3',
                      namespace=namespace,
                      output='screen',
                      parameters=[])

    ld = LaunchDescription()

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)
    ld.add_action(declare_namespace_cmd)

    # Declare the launch options
    ld.add_action(plansys2_cmd)

    ld.add_action(move_1_cmd)
    ld.add_action(move_2_cmd)
    ld.add_action(move_3_cmd)
    ld.add_action(transport_1_cmd)
    ld.add_action(transport_2_cmd)
    ld.add_action(transport_3_cmd)
    ld.add_action(lift_1_cmd)
    ld.add_action(lift_2_cmd)
    ld.add_action(lift_3_cmd)
    ld.add_action(drop_1_cmd)
    ld.add_action(drop_2_cmd)
    ld.add_action(drop_3_cmd)

    return ld
def generate_launch_description():
    bringup_dir = get_package_share_directory('plansys2_bringup')

    # Create the launch configuration variables
    model_file = LaunchConfiguration('model_file')
    namespace = LaunchConfiguration('namespace')
    params_file = LaunchConfiguration('params_file')
    default_action_bt_xml_filename = LaunchConfiguration(
        'default_action_bt_xml_filename')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    declare_model_file_cmd = DeclareLaunchArgument(
        'model_file', description='PDDL Model file')

    declare_namespace_cmd = DeclareLaunchArgument('namespace',
                                                  default_value='',
                                                  description='Namespace')

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

    declare_default_bt_file_cmd = DeclareLaunchArgument(
        'default_action_bt_xml_filename',
        default_value=os.path.join(
            get_package_share_directory('plansys2_executor'), 'behavior_trees',
            'plansys2_action_bt.xml'),
        description='BT representing a PDDL action')

    domain_expert_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('plansys2_domain_expert'),
                     'launch', 'domain_expert_launch.py')),
                                                 launch_arguments={
                                                     'model_file': model_file,
                                                     'namespace': namespace,
                                                     'params_file': params_file
                                                 }.items())

    problem_expert_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(
                get_package_share_directory('plansys2_problem_expert'),
                'launch', 'problem_expert_launch.py')),
        launch_arguments={
            'model_file': model_file,
            'namespace': namespace,
            'params_file': params_file
        }.items())

    planner_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('plansys2_planner'), 'launch',
                     'planner_launch.py')),
                                           launch_arguments={
                                               'namespace': namespace,
                                               'params_file': params_file
                                           }.items())

    executor_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('plansys2_executor'),
                         'launch', 'executor_launch.py')),
        launch_arguments={
            'namespace': namespace,
            'params_file': params_file,
            'default_action_bt_xml_filename': default_action_bt_xml_filename
        }.items())

    lifecycle_manager_cmd = Node(package='plansys2_lifecycle_manager',
                                 executable='lifecycle_manager_node',
                                 node_name='lifecycle_manager_node',
                                 namespace=namespace,
                                 output='screen',
                                 parameters=[])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)
    ld.add_action(declare_model_file_cmd)
    ld.add_action(declare_default_bt_file_cmd)
    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_params_file_cmd)

    # Declare the launch options
    ld.add_action(domain_expert_cmd)
    ld.add_action(problem_expert_cmd)
    ld.add_action(planner_cmd)
    ld.add_action(executor_cmd)
    ld.add_action(lifecycle_manager_cmd)

    return ld
def generate_launch_description():
    # Get the launch directory
    example_dir = get_package_share_directory('amazon_robot_bt')
    namespace = LaunchConfiguration('namespace')

    declare_namespace_cmd = DeclareLaunchArgument('namespace',
                                                  default_value='',
                                                  description='Namespace')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    lifecycle_nodes = ['move']

    # plansys2_cmd = IncludeLaunchDescription(
    #     PythonLaunchDescriptionSource(os.path.join(
    #         get_package_share_directory('amazon_robot_bringup'),
    #         'launch',
    #         'plansys2_bringup_launch_monolithic.py')),
    #     launch_arguments={
    #       'model_file': example_dir + '/pddl/bt_example.pddl',
    #       'namespace': namespace
    #       }.items())

    # Specify the actions
    move_cmd = Node(package='nav2_bt_navigator',
                    executable='bt_navigator',
                    name='move',
                    namespace=namespace,
                    output='screen',
                    parameters=[
                        example_dir + '/config/params.yaml', {
                            'action_name':
                            'move',
                            'bt_xml_file':
                            example_dir + '/behavior_trees_xml/move.xml'
                        }
                    ])

    nav2_cmd = Node(package='amazon_robot_bt',
                    executable='nav2_sim_node',
                    name='nav2_node',
                    namespace=namespace,
                    output='screen')

    # transport_cmd = Node(
    #     package='plansys2_bt_actions',
    #     executable='bt_action_node',
    #     name='transport',
    #     namespace=namespace,
    #     output='screen',
    #     parameters=[
    #       example_dir + '/config/params.yaml',
    #       {
    #         'action_name': 'transport',
    #         'bt_xml_file': example_dir + '/behavior_trees_xml/transport.xml'
    #       }
    #     ])

    lifecycle_node_cmd = Node(package='nav2_lifecycle_manager',
                              executable='lifecycle_manager',
                              name='lifecycle_manager_navigation',
                              output='screen',
                              parameters=[{
                                  'use_sim_time': True
                              }, {
                                  'autostart': True
                              }, {
                                  'node_names': lifecycle_nodes
                              }])

    ld = LaunchDescription()

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)
    ld.add_action(declare_namespace_cmd)

    # Declare the launch options
    # ld.add_action(plansys2_cmd)

    ld.add_action(move_cmd)
    ld.add_action(nav2_cmd)
    ld.add_action(lifecycle_node_cmd)

    # ld.add_action(transport_cmd)
    # ld.add_action(assemble_cmd)

    return ld
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('robot_slam')

    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']

    remappings = [('/tf', 'tf'),
                  ('/tf_static', 'tf_static'),
                  ('scan', 'base_scan')]

    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(bringup_dir, 'maps', 'map.yaml'),
            description='Full path to map yaml file to load'),

        DeclareLaunchArgument(
            'use_sim_time', default_value='false',
            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, 'config', 'nav2_params.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():

    # Create the launch configuration variables
    model_file = LaunchConfiguration('model_file')
    namespace = LaunchConfiguration('namespace')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    declare_model_file_cmd = DeclareLaunchArgument(
        'model_file', description='PDDL Model file')

    declare_namespace_cmd = DeclareLaunchArgument('namespace',
                                                  default_value='',
                                                  description='Namespace')

    domain_expert_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('plansys2_domain_expert'),
                     'launch', 'domain_expert_launch.py')),
                                                 launch_arguments={
                                                     'model_file': model_file,
                                                     'namespace': namespace
                                                 }.items())

    problem_expert_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(
                get_package_share_directory('plansys2_problem_expert'),
                'launch', 'problem_expert_launch.py')),
        launch_arguments={
            'model_file': model_file,
            'namespace': namespace
        }.items())

    planner_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('plansys2_planner'),
                         'launch', 'planner_launch.py')),
        launch_arguments={'namespace': namespace}.items())

    executor_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(get_package_share_directory('plansys2_executor'),
                         'launch', 'executor_launch.py')),
        launch_arguments={'namespace': namespace}.items())

    lifecycle_manager_cmd = Node(package='plansys2_lifecycle_manager',
                                 node_executable='lifecycle_manager_node',
                                 node_name='lifecycle_manager_node',
                                 node_namespace=namespace,
                                 output='screen',
                                 parameters=[])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)
    ld.add_action(declare_model_file_cmd)
    ld.add_action(declare_namespace_cmd)

    # Declare the launch options
    ld.add_action(domain_expert_cmd)
    ld.add_action(problem_expert_cmd)
    ld.add_action(planner_cmd)
    ld.add_action(executor_cmd)
    ld.add_action(lifecycle_manager_cmd)

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

    namespace = LaunchConfiguration('namespace')
    use_sim_time = LaunchConfiguration('use_sim_time')
    autostart = LaunchConfiguration('autostart')
    params_file = LaunchConfiguration('config')
    default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename')
    map_subscribe_transient_local = LaunchConfiguration(
        'map_subscribe_transient_local')

    lifecycle_nodes = [
        'controller_server', 'planner_server', 'recoveries_server',
        'bt_navigator', 'waypoint_follower'
    ]

    remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static'),
                  ('/cmd_vel', '/nav_vel')]

    param_substitutions = {
        'use_sim_time': use_sim_time,
        'default_bt_xml_filename': default_bt_xml_filename,
        'autostart': autostart,
        'map_subscribe_transient_local': map_subscribe_transient_local
    }

    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(
            'use_sim_time',
            default_value='false',
            description='Use simulation (Gazebo) clock if true'),
        DeclareLaunchArgument(
            'autostart',
            default_value='true',
            description='Automatically startup the nav2 stack'),
        DeclareLaunchArgument(
            'config',
            default_value=os.path.join(bringup_dir, 'config/navigation',
                                       'nav2_params.yaml'),
            description='Full path to the ROS2 parameters file to use'),
        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'),
        DeclareLaunchArgument(
            'map_subscribe_transient_local',
            default_value='false',
            description=
            'Whether to set the map subscriber QoS to transient local'),
        Node(package='nav2_controller',
             executable='controller_server',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_planner',
             executable='planner_server',
             name='planner_server',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_recoveries',
             executable='recoveries_server',
             name='recoveries_server',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_bt_navigator',
             executable='bt_navigator',
             name='bt_navigator',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_waypoint_follower',
             executable='waypoint_follower',
             name='waypoint_follower',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_lifecycle_manager',
             executable='lifecycle_manager',
             name='lifecycle_manager_navigation',
             output='screen',
             parameters=[{
                 'use_sim_time': use_sim_time
             }, {
                 'autostart': autostart
             }, {
                 'node_names': lifecycle_nodes
             }]),
    ])
Example #14
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():
    # Get the launch directory
    bringup_dir = get_package_share_directory('nav2_bringup')

    namespace = LaunchConfiguration('namespace')
    use_sim_time = LaunchConfiguration('use_sim_time')
    autostart = LaunchConfiguration('autostart')
    params_file = LaunchConfiguration('params_file')
    bt_xml_file = LaunchConfiguration('bt_xml_file')
    use_lifecycle_mgr = LaunchConfiguration('use_lifecycle_mgr')
    use_remappings = LaunchConfiguration('use_remappings')
    map_subscribe_transient_local = LaunchConfiguration('map_subscribe_transient_local')

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

    # Create our own temporary YAML files that include substitutions
    param_substitutions = {
        'use_sim_time': use_sim_time,
        'bt_xml_filename': bt_xml_file,
        'autostart': autostart,
        'map_subscribe_transient_local': map_subscribe_transient_local}

    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(
            'use_sim_time', default_value='false',
            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.yaml'),
            description='Full path to the ROS2 parameters file to use'),

        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'),

        DeclareLaunchArgument(
            'use_lifecycle_mgr', default_value='true',
            description='Whether to launch the lifecycle manager'),

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

        DeclareLaunchArgument(
            'map_subscribe_transient_local', default_value='false',
            description='Whether to set the map subscriber QoS to transient local'),

        Node(
            package='nav2_controller',
            node_executable='controller_server',
            output='screen',
            parameters=[configured_params],
            use_remappings=IfCondition(use_remappings),
            remappings=remappings),

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

        Node(
            package='nav2_recoveries',
            node_executable='recoveries_server',
            node_name='recoveries_server',
            output='screen',
            parameters=[{'use_sim_time': use_sim_time}],
            use_remappings=IfCondition(use_remappings),
            remappings=remappings),

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

        Node(
            condition=IfCondition(use_lifecycle_mgr),
            package='nav2_lifecycle_manager',
            node_executable='lifecycle_manager',
            node_name='lifecycle_manager_navigation',
            output='screen',
            parameters=[{'use_sim_time': use_sim_time},
                        {'autostart': autostart},
                        {'node_names': ['controller_server',
                                        'planner_server',
                                        'recoveries_server',
                                        'bt_navigator']}]),

    ])
Example #16
0
def generate_launch_description():
    # Get the launch directory
    rover_config_dir = get_package_share_directory('rover_config')
    marta_launch_dir = os.path.join(
        get_package_share_directory('marta_launch'), '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_filename = LaunchConfiguration('default_bt_xml_filename')
    autostart = LaunchConfiguration('autostart')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    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', description='Full path to map yaml 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(rover_config_dir, 'config',
                                   '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_distance.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')

    # Specify the actions
    bringup_cmd_group = GroupAction([
        PushRosNamespace(condition=IfCondition(use_namespace),
                         namespace=namespace),
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'nav2_localization_launch.py')),
                                 launch_arguments={
                                     'namespace': namespace,
                                     'map': map_yaml_file,
                                     'use_sim_time': use_sim_time,
                                     'autostart': autostart,
                                     'params_file': params_file,
                                     'use_lifecycle_mgr': 'false'
                                 }.items()),
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'nav2_navigation_launch.py')),
                                 launch_arguments={
                                     'namespace': namespace,
                                     'use_sim_time': use_sim_time,
                                     'autostart': autostart,
                                     'params_file': params_file,
                                     'default_bt_xml_filename':
                                     default_bt_xml_filename,
                                     'use_lifecycle_mgr': 'false',
                                     'map_subscribe_transient_local': 'true'
                                 }.items()),
    ])

    # Create the launch description and populate
    return LaunchDescription([
        # Set env var to print messages colored. The ANSI color codes will appear in a log.
        SetEnvironmentVariable('RCUTILS_COLORIZED_OUTPUT', '1'),

        # Declare the launch options
        declare_namespace_cmd,
        declare_use_namespace_cmd,
        declare_map_yaml_cmd,
        declare_use_sim_time_cmd,
        declare_params_file_cmd,
        declare_autostart_cmd,
        declare_bt_xml_cmd,

        # Add the actions to launch all of the navigation nodes
        bringup_cmd_group
    ])
Example #17
0
def generate_launch_description():
    # Get the launch directory
    sm_aws_warehouse_navigation_dir = get_package_share_directory(
        "sm_aws_warehouse_navigation")
    launch_dir = os.path.join(sm_aws_warehouse_navigation_dir, "launch")

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

    stdout_linebuf_envvar = SetEnvironmentVariable(
        "RCUTILS_LOGGING_BUFFERED_STREAM", "1")

    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", description="Full path to map yaml 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(
    #         sm_aws_warehouse_navigation_dir, "params", "nav2z_client", "nav2_params.yaml"
    #     ),
    #     description="Full path to the ROS2 parameters file to use for all launched nodes",
    # )

    # declare_bt_xml_cmd = DeclareLaunchArgument(
    #     "default_nav_to_pose_bt_xml",
    #     default_value=os.path.join(
    #         sm_aws_warehouse_navigation_dir, "params", "nav2z_client", "navigation_tree.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")

    # Specify the actions
    bringup_cmd_group = GroupAction([
        PushRosNamespace(condition=IfCondition(use_namespace),
                         namespace=namespace),
        # IncludeLaunchDescription(
        #     PythonLaunchDescriptionSource(os.path.join(launch_dir, "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(launch_dir, "localization_launch.py")),
        #     condition=IfCondition(PythonExpression(["not ", slam])),
        #     launch_arguments={
        #         "namespace": namespace,
        #         "map": map_yaml_file,
        #         "use_sim_time": use_sim_time,
        #         "autostart": autostart,
        #         "params_file": params_file,
        #         "use_lifecycle_mgr": "false",
        #     }.items(),
        # ),
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                os.path.join(launch_dir, "navigation_launch.py")),
            launch_arguments={
                "namespace": namespace,
                "use_sim_time": use_sim_time,
                # "autostart": autostart,
                # "default_nav_to_pose_bt_xml": default_nav_to_pose_bt_xml,
                "use_lifecycle_mgr": "false",
                "map_subscribe_transient_local": "false",
            }.items(),
        ),
    ])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)

    # 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_autostart_cmd)
    # ld.add_action(declare_bt_xml_cmd)

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

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

    pilot_dir = get_package_share_directory('pilot_urjc_bringup')
    pilot_launch_dir = os.path.join(pilot_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_filename = LaunchConfiguration('default_bt_xml_filename')
    autostart = LaunchConfiguration('autostart')
    cmd_vel_topic = LaunchConfiguration('cmd_vel_topic')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    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 the launch arguments
    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map', description='Full path to map yaml 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'),
        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_cmd_vel_topic_cmd = DeclareLaunchArgument(
        'cmd_vel_topic',
        default_value='cmd_vel',
        description='Command velocity topic')

    # Specify the actions
    bringup_cmd_group = GroupAction([
        PushRosNamespace(condition=IfCondition(use_namespace),
                         namespace=namespace),
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            os.path.join(launch_dir, 'localization_launch.py')),
                                 launch_arguments={
                                     'namespace': namespace,
                                     'map': map_yaml_file,
                                     'use_sim_time': use_sim_time,
                                     'autostart': autostart,
                                     'params_file': params_file,
                                     'use_lifecycle_mgr': 'true'
                                 }.items()),
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            os.path.join(pilot_launch_dir, 'nav2_navigation_launch.py')),
                                 launch_arguments={
                                     'namespace': namespace,
                                     'use_sim_time': use_sim_time,
                                     'autostart': autostart,
                                     'params_file': params_file,
                                     'default_bt_xml_filename':
                                     default_bt_xml_filename,
                                     'use_lifecycle_mgr': 'true',
                                     'map_subscribe_transient_local': 'true',
                                     'cmd_vel_topic': cmd_vel_topic
                                 }.items()),
        Node(package='nav2_lifecycle_manager',
             executable='lifecycle_manager',
             name='lifecycle_manager',
             output='screen',
             parameters=[{
                 'use_sim_time': use_sim_time
             }, {
                 'autostart': autostart
             }, {
                 'node_names': [
                     'map_server', 'amcl', 'controller_server',
                     'planner_server', 'recoveries_server', 'bt_navigator',
                     'waypoint_follower'
                 ]
             }]),
    ])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)

    # 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_autostart_cmd)
    ld.add_action(declare_bt_xml_cmd)
    ld.add_action(declare_cmd_vel_topic_cmd)

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

    return ld
Example #19
0
def generate_launch_description():
    launch_dir = os.path.join(get_package_share_directory('tms_rc_bot'),
                              'launch')
    use_sim_time = LaunchConfiguration('use_sim_time', default='false')
    map_dir = LaunchConfiguration(
        'map',
        default=os.path.join(get_package_share_directory('tms_rc_bot'), 'maps',
                             'map_bsen.yaml'))

    # map_yaml_file = LaunchConfiguration('map')

    # bt_navigator_xml=os.path.join(get_package_share_directory('tms_rc_bot'), 'behavior_trees', 'navigate_w_recovery_retry.xml')

    params_file = 'guidebot_params.yaml'
    params_file_dir = LaunchConfiguration(
        'params',
        default=os.path.join(get_package_share_directory('tms_rc_bot'),
                             'params', params_file))

    bt_xml_file = LaunchConfiguration('bt_xml_file')
    autostart = LaunchConfiguration('autostart')

    # nav2_launch_file_dir = os.path.join(get_package_share_directory('nav2_bringup'), 'launch')

    # bt_navigator_install_path = get_package_prefix('nav2_bt_navigator')
    # bt_navigator_xml = os.path.join(bt_navigator_install_path,
    #                                 'behavior_trees',
    #                                 'navigate_w_recovery_retry.xml') # TODO(mkhansen): change to an input parameter

    # rviz_config_dir = os.path.join(get_package_share_directory('tms_rc_bot'), 'rviz', 'tb3_navigation2.rviz')

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

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    param_substitutions = {
        'use_sim_time': use_sim_time,
        'yaml_filename': map_dir,
        'bt_xml_filename': bt_xml_file,
        'autostart': autostart
    }

    configured_params = RewrittenYaml(source_file=params_file_dir,
                                      rewrites=param_substitutions,
                                      convert_types=True)

    # Declare the launch arguments
    declare_map_yaml_cmd = DeclareLaunchArgument(
        'map',
        default_value=os.path.join(get_package_share_directory('tms_rc_bot'),
                                   'maps', 'map_bsen.yaml'),
        description='Full path to map file to load')

    declare_params_file_cmd = DeclareLaunchArgument(
        'params',
        default_value=os.path.join(get_package_share_directory('tms_rc_bot'),
                                   'params', params_file),
        description='Full path to param file to load')

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

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

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

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

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

    start_double_node_cmd = Node(package='doublenode',
                                 node_executable='double_odom',
                                 node_name='double_node',
                                 output='screen')

    # start_map_server_cmd = Node(
    #     package='nav2_map_server',
    #     node_executable='map_server',
    #     node_name='map_server',
    #     output='screen',
    #     parameters=[{ 'use_sim_time': use_sim_time}, { 'yaml_filename': map_dir}]
    #     )

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

    # start_localizer_cmd = Node(
    #     package='nav2_amcl',
    #     node_executable='amcl',
    #     node_name='amcl',
    #     output='screen',
    #     parameters=[configured_params])

    start_localizer_cmd = Node(package='robot_localization',
                               node_executable='se_node',
                               node_name='ekf_localization_node',
                               output='screen',
                               parameters=[params_file_dir],
                               remappings=[('/set_pose', '/initialpose')])

    start_world_model_cmd = Node(package='nav2_world_model',
                                 node_executable='world_model',
                                 output='screen',
                                 parameters=[configured_params])

    start_dwb_cmd = Node(package='dwb_controller',
                         node_executable='dwb_controller',
                         output='screen',
                         parameters=[configured_params],
                         remappings=[('/cmd_vel', '/cmd2vel'),
                                     ('/odom', '/odometry/vicon')])

    # start_planner_cmd = Node(
    #     package='nav2_navfn_planner',
    #     node_executable='navfn_planner',
    #     node_name='navfn_planner',
    #     output='screen',
    #     parameters=[{'use_sim_time': use_sim_time}],
    #     remappings=[('/amcl_pose', '/initialpose'), ('/cmd_vel', '/hapirobo/cmd_vel')]
    #     )

    start_planner_cmd = Node(
        package='nav2_navfn_planner',
        node_executable='navfn_planner',
        node_name='navfn_planner',
        output='screen',
        parameters=[configured_params]
        # remappings=[('/amcl_pose', '/initialpose'), ('/cmd_vel', '/hapirobo/cmd_vel')]
    )

    start_recovery_cmd = Node(package='nav2_recoveries',
                              node_executable='recoveries_node',
                              node_name='recoveries',
                              output='screen',
                              parameters=[{
                                  'use_sim_time': use_sim_time
                              }],
                              remappings=[('/amcl_pose', '/initialpose'),
                                          ('/cmd_vel', '/cmd2vel'),
                                          ('/odom', '/odometry/vicon')])

    start_navigator_cmd = Node(package='nav2_bt_navigator',
                               node_executable='bt_navigator',
                               node_name='bt_navigator',
                               output='screen',
                               parameters=[configured_params])

    start_lifecycle_manager_cmd = Node(package='nav2_lifecycle_manager',
                                       node_executable='lifecycle_manager',
                                       node_name='lifecycle_manager',
                                       output='screen',
                                       parameters=[configured_params])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)

    # Declare the launch options
    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_autostart_cmd)
    ld.add_action(declare_bt_xml_cmd)

    # Add the actions to launch all of the navigation nodes
    ld.add_action(start_lifecycle_manager_cmd)
    ld.add_action(start_double_node_cmd)
    ld.add_action(start_map_server_cmd)
    # ld.add_action(start_localizer_cmd)
    ld.add_action(start_world_model_cmd)
    ld.add_action(start_dwb_cmd)
    ld.add_action(start_planner_cmd)
    ld.add_action(start_recovery_cmd)
    ld.add_action(start_navigator_cmd)

    ld.add_action(start_robot_state_publisher_cmd)

    return ld
def generate_launch_description():
    # Get the launch directory
    jemalloc_env = SetEnvironmentVariable(
        'LD_PRELOAD', '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2')
    nav2_bringup_dir = get_package_share_directory('nav2_bringup')
    gb_nav_dir = get_package_share_directory('gb_navigation')
    gb_nav_launch_dir = os.path.join(gb_nav_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')

    # 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_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(gb_nav_dir, 'maps/robocup2021', '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(gb_nav_dir, 'params',
                                   'nav2_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(gb_nav_dir, 'rviz', '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')
    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(gb_nav_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())

    odom_2_world_cmd = Node(package="tf2_ros",
                            executable="static_transform_publisher",
                            arguments=[
                                "2.9", "2.38", "0.0", "1.57", "0.0", "0.0",
                                "odom", "world"
                            ])

    # PDDL Actions
    move_1_cmd = Node(package='plansys2_bt_actions',
                      executable='bt_action_node',
                      name='move_1',
                      namespace=namespace,
                      output='screen',
                      parameters=[
                          gb_nav_dir + '/config/params.yaml', {
                              'action_name':
                              'move',
                              'bt_xml_file':
                              gb_nav_dir + '/behavior_trees_xml/move.xml'
                          }
                      ])

    search_1_cmd = Node(package='plansys2_bt_actions',
                        executable='bt_action_node',
                        name='search_1',
                        namespace=namespace,
                        output='screen',
                        parameters=[
                            gb_nav_dir + '/config/params.yaml', {
                                'action_name':
                                'search',
                                'bt_xml_file':
                                gb_nav_dir + '/behavior_trees_xml/search.xml'
                            }
                        ])

    # Create the launch description and populate
    ld = LaunchDescription()
    ld.add_action(jemalloc_env)
    # 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)
    ld.add_action(odom_2_world_cmd)

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

    # Add PDDL Actions
    ld.add_action(move_1_cmd)
    ld.add_action(search_1_cmd)

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

    return ld
Example #21
0
def generate_launch_description():
    map_yaml_file = os.getenv('TEST_MAP')
    world = os.getenv('TEST_WORLD')
    urdf = os.getenv('TEST_URDF')
    sdf = os.getenv('TEST_SDF')

    bt_xml_file = os.path.join(
        get_package_share_directory('nav2_bt_navigator'), 'behavior_trees',
        os.getenv('BT_NAVIGATOR_XML'))

    bringup_dir = get_package_share_directory('nav2_bringup')
    robot1_params_file = os.path.join(
        bringup_dir,  # noqa: F841
        'params/nav2_multirobot_params_1.yaml')
    robot2_params_file = os.path.join(
        bringup_dir,  # noqa: F841
        'params/nav2_multirobot_params_2.yaml')

    # Names and poses of the robots
    robots = [{
        'name': 'robot1',
        'x_pose': 0.0,
        'y_pose': 0.5,
        'z_pose': 0.01
    }, {
        'name': 'robot2',
        'x_pose': 0.0,
        'y_pose': -0.5,
        'z_pose': 0.01
    }]

    # Launch Gazebo server for simulation
    start_gazebo_cmd = ExecuteProcess(cmd=[
        'gzserver', '-s', 'libgazebo_ros_factory.so', '--minimal_comms', world
    ],
                                      output='screen')

    # Define commands for spawing the robots into Gazebo
    spawn_robots_cmds = []
    for robot in robots:
        spawn_robots_cmds.append(
            Node(package='nav2_gazebo_spawner',
                 node_executable='nav2_gazebo_spawner',
                 output='screen',
                 arguments=[
                     '--robot_name',
                     TextSubstitution(text=robot['name']), '--robot_namespace',
                     TextSubstitution(text=robot['name']), '--sdf',
                     TextSubstitution(text=sdf), '-x',
                     TextSubstitution(text=str(robot['x_pose'])), '-y',
                     TextSubstitution(text=str(robot['y_pose'])), '-z',
                     TextSubstitution(text=str(robot['z_pose']))
                 ]))

    # Define commands for launching the robot state publishers
    robot_state_pubs_cmds = []
    for robot in robots:
        robot_state_pubs_cmds.append(
            Node(package='robot_state_publisher',
                 node_executable='robot_state_publisher',
                 node_namespace=TextSubstitution(text=robot['name']),
                 output='screen',
                 parameters=[{
                     'use_sim_time': 'True'
                 }],
                 remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static')],
                 arguments=[urdf]))

    # Define commands for launching the navigation instances
    nav_instances_cmds = []
    for robot in robots:
        params_file = eval(robot['name'] + '_params_file')

        group = GroupAction([
            # Instances use the robot's name for namespace
            PushRosNamespace(robot['name']),
            IncludeLaunchDescription(PythonLaunchDescriptionSource(
                os.path.join(bringup_dir, 'launch', 'bringup_launch.py')),
                                     launch_arguments={
                                         'namespace': robot['name'],
                                         'map': map_yaml_file,
                                         'use_sim_time': 'True',
                                         'params_file': params_file,
                                         'bt_xml_file': bt_xml_file,
                                         'autostart': 'True',
                                         'use_remappings': 'True'
                                     }.items())
        ])
        nav_instances_cmds.append(group)

    ld = LaunchDescription()
    ld.add_action(
        SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'), )
    ld.add_action(start_gazebo_cmd)
    for spawn_robot in spawn_robots_cmds:
        ld.add_action(spawn_robot)
    for state_pub in robot_state_pubs_cmds:
        ld.add_action(state_pub)
    for nav_instance in nav_instances_cmds:
        ld.add_action(nav_instance)

    return ld
Example #22
0
def generate_launch_description():
    # 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
    namespace = LaunchConfiguration('namespace')
    use_namespace = LaunchConfiguration('use_namespace')
    slam = LaunchConfiguration('slam')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    autostart = LaunchConfiguration('autostart')
    use_composition = LaunchConfiguration('use_composition')

    # 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)

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_LOGGING_BUFFERED_STREAM', '1')

    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', description='Full path to map yaml 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'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

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

    declare_use_composition_cmd = DeclareLaunchArgument(
        'use_composition',
        default_value='True',
        description='Whether to use composed bringup')

    # Specify the actions
    bringup_cmd_group = GroupAction([
        PushRosNamespace(condition=IfCondition(use_namespace),
                         namespace=namespace),
        IncludeLaunchDescription(PythonLaunchDescriptionSource(
            os.path.join(launch_dir, '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(launch_dir, 'localization_launch.py')),
                                 condition=IfCondition(
                                     PythonExpression(['not ', slam])),
                                 launch_arguments={
                                     'namespace': namespace,
                                     'map': map_yaml_file,
                                     'use_sim_time': use_sim_time,
                                     'autostart': autostart,
                                     'params_file': params_file
                                 }.items()),
        Node(condition=IfCondition(use_composition),
             package='nav2_bringup',
             executable='composed_bringup',
             output='screen',
             parameters=[configured_params, {
                 'autostart': autostart
             }],
             remappings=remappings),
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                os.path.join(launch_dir, 'navigation_launch.py')),
            condition=IfCondition(PythonExpression(['not ', use_composition])),
            launch_arguments={
                'namespace': namespace,
                'use_sim_time': use_sim_time,
                'autostart': autostart,
                'params_file': params_file
            }.items()),
    ])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)

    # 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_autostart_cmd)
    ld.add_action(declare_use_composition_cmd)

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

    return ld
def generate_launch_description():
    # Get the launch directory
    example_dir = get_package_share_directory('plansys2_cooking_example')
    namespace = LaunchConfiguration('namespace')

    declare_namespace_cmd = DeclareLaunchArgument('namespace',
                                                  default_value='',
                                                  description='Namespace')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    plansys2_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(get_package_share_directory('plansys2_bringup'), 'launch',
                     'plansys2_bringup_monolithic_launch.py')),
                                            launch_arguments={
                                                'model_file': example_dir +
                                                '/pddl/cooking_domain.pddl',
                                                'namespace': namespace
                                            }.items())

    # Specify the actions
    move_1_cmd = Node(package='plansys2_bt_actions',
                      executable='bt_action_node',
                      name='move_1',
                      namespace=namespace,
                      output='screen',
                      parameters=[
                          example_dir + '/config/params.yaml', {
                              'action_name':
                              'move',
                              'bt_xml_file':
                              example_dir + '/behavior_trees_xml/move.xml'
                          }
                      ])

    transport_1_cmd = Node(package='plansys2_bt_actions',
                           executable='bt_action_node',
                           name='transport_1',
                           namespace=namespace,
                           output='screen',
                           parameters=[
                               example_dir + '/config/params.yaml', {
                                   'action_name':
                                   'transport',
                                   'bt_xml_file':
                                   example_dir +
                                   '/behavior_trees_xml/transport.xml'
                               }
                           ])
    recharge_1_cmd = Node(package='plansys2_bt_actions',
                          executable='bt_action_node',
                          name='recharge_1',
                          namespace=namespace,
                          output='screen',
                          parameters=[
                              example_dir + '/config/params.yaml', {
                                  'action_name':
                                  'recharge',
                                  'bt_xml_file':
                                  example_dir +
                                  '/behavior_trees_xml/recharge.xml'
                              }
                          ])

    cook_omelette_1_cmd = Node(
        package='plansys2_cooking_example',
        executable='cook_omelette_action_node',
        name='cook_omelette_1',
        namespace=namespace,
        output='screen',
        parameters=[])  # Create the launch description and populate

    cook_cake_1_cmd = Node(
        package='plansys2_cooking_example',
        executable='cook_cake_action_node',
        name='cook_cake_1',
        namespace=namespace,
        output='screen',
        parameters=[])  # Create the launch description and populate

    cook_spaghetti_1_cmd = Node(
        package='plansys2_cooking_example',
        executable='cook_spaghetti_action_node',
        name='cook_spaghetti_1',
        namespace=namespace,
        output='screen',
        parameters=[])  # Create the launch description and populate

    marker_cmd = Node(package='plansys2_cooking_example',
                      executable='marker_pub',
                      name='marker_pub',
                      namespace=namespace,
                      output='screen',
                      parameters=[
                          example_dir + '/config/params.yaml'
                      ])  # Create the launch description and populate

    ld = LaunchDescription()

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)
    ld.add_action(declare_namespace_cmd)

    # Declare the launch options
    ld.add_action(plansys2_cmd)

    ld.add_action(move_1_cmd)
    ld.add_action(transport_1_cmd)
    ld.add_action(recharge_1_cmd)
    ld.add_action(cook_omelette_1_cmd)
    ld.add_action(cook_cake_1_cmd)
    ld.add_action(cook_spaghetti_1_cmd)

    ld.add_action(marker_cmd)

    return ld
def generate_launch_description():

    bringup_dir = get_package_share_directory('nav2_bringup')

    namespace = LaunchConfiguration('namespace')
    use_sim_time = LaunchConfiguration('use_sim_time')
    autostart = LaunchConfiguration('autostart')
    params_file = LaunchConfiguration('params_file')
    default_nav_through_poses_bt_xml = LaunchConfiguration(
        'default_nav_through_poses_bt_xml')
    default_nav_to_pose_bt_xml = LaunchConfiguration(
        'default_nav_to_pose_bt_xml')
    map_subscribe_transient_local = LaunchConfiguration(
        'map_subscribe_transient_local')

    # Create our own temporary YAML files that include substitutions
    param_substitutions = {
        'use_sim_time': use_sim_time,
        'default_nav_through_poses_bt_xml': default_nav_through_poses_bt_xml,
        'default_nav_to_pose_bt_xml': default_nav_to_pose_bt_xml,
        'autostart': autostart,
        'map_subscribe_transient_local': map_subscribe_transient_local
    }

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

    lifecycle_nodes = ['behavior_server']

    # 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')]

    return LaunchDescription([
        SetEnvironmentVariable('RCUTILS_LOGGING_BUFFERED_STREAM', '1'),
        SetEnvironmentVariable('RCUTILS_LOGGING_USE_STDOUT', '1'),
        DeclareLaunchArgument('namespace',
                              default_value='',
                              description='Top-level namespace'),
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            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.yaml'),
            description='Full path to the ROS2 parameters file to use'),
        DeclareLaunchArgument(
            'default_nav_through_poses_bt_xml',
            default_value=os.path.join(
                get_package_share_directory('nav2_bt_navigator'),
                'behavior_trees',
                'navigate_through_poses_w_replanning_and_recovery.xml'),
            description='Full path to the behavior tree xml file to use'),
        DeclareLaunchArgument(
            'default_nav_to_pose_bt_xml',
            default_value=os.path.join(
                get_package_share_directory('nav2_bt_navigator'),
                'behavior_trees',
                'navigate_to_pose_w_replanning_and_recovery.xml'),
            description='Full path to the behavior tree xml file to use'),
        DeclareLaunchArgument(
            'map_subscribe_transient_local',
            default_value='false',
            description=
            'Whether to set the map subscriber QoS to transient local'),

        # TODO(orduno) Launch the robot state publisher instead
        #              using a local copy of TB3 urdf file
        Node(package='tf2_ros',
             executable='static_transform_publisher',
             output='screen',
             arguments=['0', '0', '0', '0', '0', '0', 'map', 'odom']),
        Node(package='tf2_ros',
             executable='static_transform_publisher',
             output='screen',
             arguments=[
                 '0', '0', '0', '0', '0', '0', 'base_footprint', 'base_link'
             ]),
        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            output='screen',
            arguments=['0', '0', '0', '0', '0', '0', 'base_link',
                       'base_scan']),
        Node(package='nav2_behaviors',
             executable='behavior_server',
             name='behavior_server',
             output='screen',
             parameters=[configured_params],
             remappings=remappings),
        Node(package='nav2_lifecycle_manager',
             executable='lifecycle_manager',
             name='lifecycle_manager_navigation',
             output='screen',
             parameters=[{
                 'use_sim_time': use_sim_time
             }, {
                 'autostart': autostart
             }, {
                 'node_names': lifecycle_nodes
             }]),
    ])
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('nav2_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']

    # 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(bringup_dir, 'maps',
                                       'turtlebot3_world.yaml'),
            description='Full path to map yaml file to load'),
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            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.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
             }])
    ])
Example #26
0
def generate_launch_description():

    marta_launch_dir = os.path.join(
        get_package_share_directory('marta_launch'), 'launch')
    rover_config_dir = os.path.join(
        get_package_share_directory('rover_config'))

    # Launch configurations
    use_sim_time = LaunchConfiguration('use_sim_time')
    config_file = LaunchConfiguration('config_file')
    robot_description = LaunchConfiguration('robot_description')
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    use_rviz = LaunchConfiguration('use_rviz')
    use_simulator = LaunchConfiguration('use_simulator')
    use_gazebo_gui = LaunchConfiguration('use_gazebo_gui')
    world = LaunchConfiguration('world')
    use_loc_cam = LaunchConfiguration('use_loc_cam')
    stereo_cam_name = LaunchConfiguration('stereo_cam_name')
    use_stereo_view = LaunchConfiguration('use_stereo_view')

    # ## ROBOT MODEL
    # Load XACRO and parse to URDF
    xacro_model_name = 'marta.xacro'
    xacro_model_path = os.path.join(rover_config_dir, 'urdf', xacro_model_name)

    # Parse XACRO file to URDF
    urdf_model_path = to_urdf(xacro_model_path)

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

    declare_config_file_cmd = DeclareLaunchArgument(
        'config_file',
        default_value=os.path.join(rover_config_dir, 'config', 'marta.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

    declare_robot_description_cmd = DeclareLaunchArgument(
        'robot_description',
        default_value=urdf_model_path,
        description='Full path to robot urdf file.')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config_file',
        default_value=os.path.join(rover_config_dir, 'rviz',
                                   'gamepad_sim.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_use_simulator_cmd = DeclareLaunchArgument(
        'use_simulator',
        default_value='True',
        description='Whether to start the simulator')

    declare_use_gazebo_gui_cmd = DeclareLaunchArgument(
        'use_gazebo_gui',
        default_value='True',
        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
        # EMPTY WORLD
        # default_value=os.path.join(rover_config_dir, 'worlds', 'empty.world'),
        # MARS YARD
        default_value=os.path.join(rover_config_dir, 'worlds',
                                   'mars_yard.world'),
        description='Full path to world model file to load')

    declare_use_loc_cam_cmd = DeclareLaunchArgument(
        'use_loc_cam',
        default_value='True',
        description='Whether to process loc_cam data.)')

    declare_stereo_cam_name_cmd = DeclareLaunchArgument(
        'stereo_cam_name',
        default_value='/loc_cam',
        description='Name of the stereo cam to be used.')

    declare_use_stereo_view_cmd = DeclareLaunchArgument(
        'use_stereo_view',
        default_value='True',
        description='Option to display stereo images.')

    start_locomotion_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'locomotion.launch.py')))

    start_simulation_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'simulation.launch.py')))

    start_stereo_image_proc_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'stereo_image_proc.launch.py')), )

    rviz_cmd = Node(
        condition=IfCondition(use_rviz),
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        arguments=['-d', rviz_config_file],
        # Use this option to see all output from rviz:
        # output='screen',
        # Use this option to supress messages of missing tfs,
        # at startup of rviz and gazebo:
        output={'stdout': 'log'},
        parameters=[{
            'use_sim_time': use_sim_time
        }],
        remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static')])
    return LaunchDescription([
        # Set env var to print messages colored. The ANSI color codes will appear in a log.
        SetEnvironmentVariable('RCUTILS_COLORIZED_OUTPUT', '1'),

        # Parameter Declarations
        declare_use_sim_time_cmd,
        declare_config_file_cmd,
        declare_robot_description_cmd,
        declare_rviz_config_file_cmd,
        declare_use_rviz_cmd,
        declare_use_simulator_cmd,
        declare_use_gazebo_gui_cmd,
        declare_world_cmd,
        declare_use_loc_cam_cmd,
        declare_stereo_cam_name_cmd,
        declare_use_stereo_view_cmd,

        # Start Nodes and Launch files
        start_locomotion_cmd,
        start_simulation_cmd,
        start_stereo_image_proc_cmd,
        rviz_cmd,
    ])
Example #27
0
def generate_launch_description():
    # 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
    namespace = LaunchConfiguration('namespace')
    use_namespace = LaunchConfiguration('use_namespace')
    slam = LaunchConfiguration('slam')
    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')

    stdout_linebuf_envvar = SetEnvironmentVariable(
        'RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')

    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',
        description='Full path to map yaml 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'),
        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')

    # Specify the actions
    bringup_cmd_group = GroupAction([
        PushRosNamespace(
            condition=IfCondition(use_namespace),
            namespace=namespace),

        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(os.path.join(launch_dir, '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(launch_dir,
                                                       'localization_launch.py')),
            condition=IfCondition(PythonExpression(['not ', slam])),
            launch_arguments={'namespace': namespace,
                              'map': map_yaml_file,
                              'use_sim_time': use_sim_time,
                              'autostart': autostart,
                              'params_file': params_file,
                              'use_lifecycle_mgr': 'false'}.items()),

        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(os.path.join(launch_dir, 'navigation_launch.py')),
            launch_arguments={'namespace': namespace,
                              'use_sim_time': use_sim_time,
                              'autostart': autostart,
                              'params_file': params_file,
                              'default_bt_xml_filename': default_bt_xml_filename,
                              'use_lifecycle_mgr': 'false',
                              'map_subscribe_transient_local': 'true'}.items()),
    ])

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

    # Set environment variables
    ld.add_action(stdout_linebuf_envvar)

    # 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_autostart_cmd)
    ld.add_action(declare_bt_xml_cmd)

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

    return ld
Example #28
0
def generate_launch_description():

  # Configure environment
  stdout_linebuf_envvar = SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1')
  stdout_colorized_envvar = SetEnvironmentVariable('RCUTILS_COLORIZED_OUTPUT', '1')

  # Simulated time
  use_sim_time = LaunchConfiguration('use_sim_time', default='true')

  # Nodes Configurations
  config_file = os.path.join("/home/harry/dev_ws/src/LeGO-LOAM-SR/LeGO-LOAM/config", 'loam_config.yaml')
#   config_file = os.path.join(get_package_share_directory('lego_loam_sr'), 'config', 'loam_config.yaml')

  # Tf transformations
  # initialization of camera_init by using UWB
  transform_map = Node(
    package='tf2_ros',
    node_executable='static_transform_publisher',
    node_name='camera_init_to_map',
    arguments=['0.095', '1.06', '0.38', '1.570795', '0', '1.570795', 'map', 'camera_init'],
  )

  #velodyne
  transform_camera = Node(
    package='tf2_ros',
    node_executable='static_transform_publisher',
    node_name='base_link_to_camera',
    arguments=['0', '-0.38', '-0.405', '-1.570795', '-1.570795', '0', 'camera', 'base_link'],
  )

  transform_vel = Node(
    package='tf2_ros',
    node_executable='static_transform_publisher',
    node_name='vel_to_camera',
    arguments=['0', '0', '0', '0', '0', '0', 'camera', 'velodyne'],
  )

  # LeGO-LOAM
  lego_loam_node = Node(
    package='lego_loam_sr',
    node_executable='lego_loam_sr',
    output='screen',
    parameters=[config_file],
    remappings=[('/lidar_points', '/velodyne_points')],
  )

  driver_share_dir = get_package_share_directory('velodyne_driver')
  driver_params_file = os.path.join(driver_share_dir, 'config', 'VLP16-velodyne_driver_node-params.yaml')
  with open(driver_params_file, 'r') as f:
      driver_params = yaml.safe_load(f)['velodyne_driver_node']['ros__parameters']

  convert_share_dir = get_package_share_directory('velodyne_pointcloud')
  convert_params_file = os.path.join(convert_share_dir, 'config', 'VLP16-velodyne_convert_node-params.yaml')
  with open(convert_params_file, 'r') as f:
      convert_params = yaml.safe_load(f)['velodyne_convert_node']['ros__parameters']
  convert_params['calibration'] = os.path.join(convert_share_dir, 'params', 'VLP16db.yaml')

  laserscan_share_dir = get_package_share_directory('velodyne_laserscan')
  laserscan_params_file = os.path.join(laserscan_share_dir, 'config', 'default-velodyne_laserscan_node-params.yaml')
  with open(laserscan_params_file, 'r') as f:
      laserscan_params = yaml.safe_load(f)['velodyne_laserscan_node']['ros__parameters']

  container = ComposableNodeContainer(
          node_name='velodyne_container',
          node_namespace='',
          package='rclcpp_components',
          node_executable='component_container',
          composable_node_descriptions=[
              ComposableNode(
                  package='velodyne_driver',
                  node_plugin='velodyne_driver::VelodyneDriver',
                  node_name='velodyne_driver_node',
                  parameters=[driver_params]),
              ComposableNode(
                  package='velodyne_pointcloud',
                  node_plugin='velodyne_pointcloud::Convert',
                  node_name='velodyne_convert_node',
                  parameters=[convert_params]),
              ComposableNode(
                  package='velodyne_laserscan',
                  node_plugin='velodyne_laserscan::VelodyneLaserScan',
                  node_name='velodyne_laserscan_node',
                  parameters=[laserscan_params]),
          ],
          output='both',
  )

  gl_back = Node(
      node_name = 'gl_ros2_driver_node_front',
      package = 'gl_ros2_driver',
      node_executable = 'gl_ros2_driver_node',
      output = 'screen',
      parameters = [
          {'serial_port_name': '/dev/ttyUSB0'},
          {'serial_baudrate': 921600},
          {'frame_id': 'laser_back'},
          {'parent_frame_id': 'base_link'},
          {'pub_topicname_lidar': 'scan_back'},
          {'angle_offset': -1.570796},
      ],
  )

  tf_back = Node(
      package='tf2_ros',
      node_executable='static_transform_publisher',
      output = 'screen',
      arguments = ['-0.405','0','0.38','0','0','0','base_link','laser_back']
  )

  uwb = Node(
      node_name = 'uwb_node',
      package='uwb_mdek1001',
      node_executable='uwb_mdek1001_node',
      output = 'screen',
      parameters = [
          {'serial_port_name': '/dev/ttyACM0'},
          {'serial_baudrate': 115200},
          {'frame_id': 'uwb_frame'},
          {'pub_topicname_uwb': 'uwb_data'},
          {'save_filepath': '/home/jetson-nx/ros2_ws/src/uwb_mdek1001/save_files'},
      ],
  )

  ld = LaunchDescription()
  # Set environment variables
  ld.add_action(stdout_linebuf_envvar)
  ld.add_action(stdout_colorized_envvar)
  # Add nodes
  ld.add_action(lego_loam_node)
  ld.add_action(transform_map)
  ld.add_action(transform_camera)
  ld.add_action(transform_vel)

  #ld.add_action(container)
  #ld.add_action(gl_back)
  #ld.add_action(tf_back)

  #ld.add_action(uwb)


  return ld
def generate_launch_description():
    map_yaml_file = os.getenv('TEST_MAP')
    world = os.getenv('TEST_WORLD')

    bt_navigator_xml = os.path.join(get_package_share_directory('nav2_bt_navigator'),
                                    'behavior_trees',
                                    os.getenv('BT_NAVIGATOR_XML'))

    bringup_dir = get_package_share_directory('nav2_bringup')
    params_file = os.path.join(bringup_dir, 'params', 'nav2_params.yaml')

    # Replace the default parameter values for testing special features
    # without having multiple params_files inside the nav2 stack
    context = LaunchContext()
    param_substitutions = {}

    if (os.getenv('ASTAR') == 'True'):
        param_substitutions.update({'use_astar': 'True'})

    if (os.getenv('GROOT_MONITORING') == 'True'):
        param_substitutions.update({'enable_groot_monitoring': 'True'})

    param_substitutions.update(
        {'planner_server.ros__parameters.GridBased.plugin': os.getenv('PLANNER')})
    param_substitutions.update(
        {'controller_server.ros__parameters.FollowPath.plugin': os.getenv('CONTROLLER')})

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

    new_yaml = configured_params.perform(context)

    return LaunchDescription([
        SetEnvironmentVariable('RCUTILS_LOGGING_BUFFERED_STREAM', '1'),
        SetEnvironmentVariable('RCUTILS_LOGGING_USE_STDOUT', '1'),

        # Launch gazebo server for simulation
        ExecuteProcess(
            cmd=['gzserver', '-s', 'libgazebo_ros_init.so',
                 '--minimal_comms', world],
            output='screen'),

        # TODO(orduno) Launch the robot state publisher instead
        #              using a local copy of TB3 urdf file
        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            output='screen',
            arguments=['0', '0', '0', '0', '0', '0', 'base_footprint', 'base_link']),

        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            output='screen',
            arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'base_scan']),

        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                os.path.join(bringup_dir, 'launch', 'bringup_launch.py')),
            launch_arguments={'namespace': '',
                              'use_namespace': 'False',
                              'map': map_yaml_file,
                              'use_sim_time': 'True',
                              'params_file': new_yaml,
                              'bt_xml_file': bt_navigator_xml,
                              'autostart': 'True'}.items()),
    ])
def generate_launch_description():

    marta_launch_dir = os.path.join(
        get_package_share_directory('marta_launch'), 'launch')
    rover_config_dir = get_package_share_directory('rover_config')

    # Launch configurations
    config_file = LaunchConfiguration('config_file')
    robot_description = LaunchConfiguration('robot_description')
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    urdf_path = LaunchConfiguration('urdf_path')
    use_rviz = LaunchConfiguration('use_rviz')

    # ## ROBOT MODEL
    # Load XACRO and parse to URDF
    xacro_model_name = 'marta.xacro'
    xacro_model_path = os.path.join(rover_config_dir, 'urdf', xacro_model_name)

    # Parse XACRO file to URDF
    # TODO: Use LaunchConfigurations arguments to set parameters in URDF. How can the parameters be read out here???
    urdf_model_path, robot_desc = to_urdf(xacro_model_path,
                                          mappings={'use_ptu': 'true'})

    # Launch declarations
    declare_config_file_cmd = DeclareLaunchArgument(
        'config_file',
        default_value=os.path.join(rover_config_dir, 'config', 'marta.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launched nodes')

    declare_urdf_path_cmd = DeclareLaunchArgument(
        'urdf_path',
        default_value=urdf_model_path,
        description='Full path to robot urdf file.')

    declare_robot_description_cmd = DeclareLaunchArgument(
        'robot_description',
        default_value=robot_desc,
        description='Full path to robot urdf file.')

    declare_rviz_config_file_cmd = DeclareLaunchArgument(
        'rviz_config_file',
        default_value=os.path.join(rover_config_dir, 'rviz',
                                   'gamepad_rover.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')

    start_locomotion_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'locomotion.launch.py')))

    start_pd_driver_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir,
                         'platform_driver_ethercat.launch.py')))

    rviz_cmd = Node(
        condition=IfCondition(use_rviz),
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        arguments=['-d', rviz_config_file],
        # Use this option to see all output from rviz:
        # output='screen',
        # Use this option to supress messages of missing tfs,
        # at startup of rviz and gazebo:
        output={'stdout': 'log'},
        remappings=[('/tf', 'tf'), ('/tf_static', 'tf_static')])

    return LaunchDescription([
        # Set env var to print messages colored. The ANSI color codes will appear in a log.
        SetEnvironmentVariable('RCUTILS_COLORIZED_OUTPUT', '1'),

        # Parameter Declarations
        declare_config_file_cmd,
        declare_robot_description_cmd,
        declare_rviz_config_file_cmd,
        declare_urdf_path_cmd,
        declare_use_rviz_cmd,

        # Start Launch Files
        start_locomotion_cmd,
        start_pd_driver_cmd,
        rviz_cmd,
    ])