コード例 #1
0
def generate_launch_description():
    keystroke_node = Node(package='keystroke',
                          node_executable='keystroke_listen',
                          output='screen',
                          node_name='keystroke_listen',
                          parameters=[{
                              'exit_on_esc': True
                          }],
                          arguments=['__log_level:=warn'])
    twist_node = Node(package='keystroke',
                      node_executable='keystroke_arrows_to_twist',
                      output='screen',
                      node_name='arrows_to_twist',
                      parameters=[{
                          'publish_period': 0.1,
                          'linear_scale': 0.1,
                          'angular_scale': 0.2
                      }])
    return LaunchDescription([
        keystroke_node, twist_node,
        RegisterEventHandler(event_handler=OnProcessExit(
            target_action=keystroke_node,
            on_exit=[EmitEvent(event=Shutdown())],
        )),
        RegisterEventHandler(event_handler=OnProcessExit(
            target_action=twist_node,
            on_exit=[EmitEvent(event=Shutdown())],
        ))
    ])
コード例 #2
0
 def _succeed(self, test_name, side_effect=None):
     """Mark test as a success and shutdown if all other tests have finished too."""
     assert test_name in self.__tests
     self.__tests[test_name] = 'succeeded'
     if all(status != 'armed' for status in self.__tests.values()):
         return [EmitEvent(event=Shutdown(reason='all tests finished'))]
     if side_effect == 'shutdown':
         return [EmitEvent(event=Shutdown(reason='shutdown after test'))]
     return []
コード例 #3
0
def generate_launch_description():
    teleop_config = Path(get_package_share_directory('openrover_demo'), 'config', 'teleop.yaml')
    assert teleop_config.is_file()

    nodes = [
        Node(
            package='keystroke', node_executable='keystroke_listen', output='screen',
            arguments=['__log_level:=warn'],
            parameters=[teleop_config]
        ),
        Node(
            package='keystroke', node_executable='keystroke_arrows_to_twist', output='screen',
            arguments=['__log_level:=info'],
            parameters=[teleop_config]
        )]

    events = [RegisterEventHandler(
        event_handler=OnProcessExit(
            target_action=n,
            on_exit=[EmitEvent(event=Shutdown())]
        )
    ) for n in nodes]

    return LaunchDescription([
        SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'),
        *nodes,
        *events
    ])
def generate_launch_description():
    localization_benchmark_supervisor_node = Node(
        package='localization_performance_modelling',
        node_executable='localization_benchmark_supervisor',
        node_name='localization_benchmark_supervisor',
        output='screen',
        emulate_tty=True,
        parameters=[LaunchConfiguration('configuration')],
    )
    return LaunchDescription([
        # Set env var to print messages to stdout immediately
        SetEnvironmentVariable('RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED', '1'),
        DeclareLaunchArgument('configuration',
                              description='Configuration yaml file path'),
        DeclareLaunchArgument('use_sim_time',
                              description='Use simulation/bag clock if true'),
        localization_benchmark_supervisor_node,
        Node(package='nav2_lifecycle_manager',
             node_executable='lifecycle_manager',
             node_name='lifecycle_manager',
             output='screen',
             parameters=[{
                 'use_sim_time': LaunchConfiguration('use_sim_time')
             }, {
                 'node_names': [
                     'map_server', 'amcl', 'controller_server',
                     'planner_server', 'recoveries_server', 'bt_navigator',
                     'waypoint_follower'
                 ]
             }]),
        RegisterEventHandler(event_handler=OnProcessExit(
            target_action=localization_benchmark_supervisor_node,
            on_exit=EmitEvent(event=Shutdown(reason='supervisor_finished')))),
    ])
コード例 #5
0
def generate_launch_description():
    return launch.LaunchDescription(
        [
            IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    [get_package_share_directory(robot), "/launch/nav-core.py"]
                ),
                launch_arguments={
                    "namespace": robot,
                    "params_file": os.path.join(
                        get_package_share_directory(robot), "param", f"{robot}.yml"
                    ),
                }.items(),
            )
            for robot in robots
        ]
        + [
            RegisterEventHandler(
                event_handler=OnProcessExit(
                    on_exit=[
                        EmitEvent(event=Shutdown()),
                    ]
                )
            )
        ]
    )
コード例 #6
0
def generate_launch_description():
    return launch.LaunchDescription([
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                [get_package_share_directory(robot), "/launch/interfaces.py"]),
            launch_arguments={
                "namespace":
                robot,
                "params_file":
                os.path.join(get_package_share_directory(robot), "param",
                             f"{robot}.yml"),
            }.items(),
        ) for robot in robots
    ] + [
        GroupAction([
            Node(
                package="strategix",
                executable="strategix",
                output="screen",
            ),
        ])
    ] + [
        RegisterEventHandler(event_handler=OnProcessExit(on_exit=[
            EmitEvent(event=Shutdown()),
        ]))
    ])
コード例 #7
0
ファイル: interfaces.py プロジェクト: robotique-ecam/cdfr
def generate_launch_description():
    return launch.LaunchDescription(
        [
            IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    [get_package_share_directory(robot), "/launch/interfaces.py"]
                ),
                launch_arguments={
                    "namespace": robot,
                    "params_file": os.path.join(
                        get_package_share_directory(robot), "param", f"{robot}.yml"
                    ),
                }.items(),
            )
            for robot in robots
        ]
        + [
            IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    [
                        get_package_share_directory("assurancetourix"),
                        "/launch/launch.py",
                    ]
                ),
                launch_arguments={
                    "namespace": "assurancetourix",
                    "params_file": os.path.join(
                        get_package_share_directory("assurancetourix"),
                        "param",
                        "assurancetourix.yml",
                    ),
                }.items(),
            )
        ]
        + [
            GroupAction(
                [
                    Node(
                        package="strategix",
                        executable="strategix",
                        output="screen",
                    ),
                    WebotsLauncher(
                        mode="realtime",
                        world="tools/simulation/worlds/cdr2022.wbt",
                    ),
                ]
            )
        ]
        + [
            RegisterEventHandler(
                event_handler=OnProcessExit(
                    on_exit=[
                        EmitEvent(event=Shutdown()),
                    ]
                )
            )
        ]
    )
コード例 #8
0
 def _fail(self, test_name, reason):
     """Mark test as a failure and shutdown, dropping the tests that are still in progress."""
     assert test_name in self.__tests
     self.__tests[test_name] = 'failed'
     for test_name in self.__tests:
         if self.__tests[test_name] == 'armed':
             self.__tests[test_name] = 'dropped'
     return [EmitEvent(event=Shutdown(reason=reason))]
コード例 #9
0
ファイル: __init__.py プロジェクト: josephduchesne/launch
        def on_test_process_exit(event, context):
            nonlocal action
            nonlocal self
            self.__test_returncodes[action] = event.returncode

            if len(self.__test_returncodes) == len(self.__test_processes):
                shutdown_event = Shutdown(
                    reason='all test processes finished')
                return EmitEvent(event=shutdown_event)
コード例 #10
0
def launch_gtest(test_path):
    """Launch a gtest."""
    ld = LaunchDescription([
        GTest(path=str(test_path),
              timeout=5.0,
              on_exit=[EmitEvent(event=Shutdown())])
    ])
    ls = LaunchService()
    ls.include_launch_description(ld)
    assert 0 == ls.run()
コード例 #11
0
 def on_fixture_process_exit(event, context):
     process_name = event.action.process_details['name']
     allowed_to_exit = exit_allowed
     if isinstance(exit_allowed, list):
         allowed_to_exit = event.returncode in exit_allowed
     if not context.is_shutdown and not allowed_to_exit:
         rc = event.returncode if event.returncode else 1
         self.__processes_rc[process_name] = rc
         return EmitEvent(event=Shutdown(
             reason='{} fixture process died!'.format(
                 process_name)))
コード例 #12
0
def generate_rviz_launch_description(namespace="robot"):
    # Get the launch directory
    titan_dir = get_package_share_directory("titan")

    rviz_config_file = os.path.join(titan_dir, "rviz", "namespaced_view.rviz")

    use_namespace = "true"

    namespaced_rviz_config_file = ReplaceString(
        source_file=rviz_config_file,
        replacements={"<robot_namespace>": ("/", namespace)},
    )

    start_namespaced_rviz_cmd = Node(
        condition=IfCondition(use_namespace),
        package="rviz2",
        executable="rviz2",
        name="rviz2",
        namespace=namespace,
        # TODO: FIX onload MUTEX ERROR
        # arguments=['-d', namespaced_rviz_config_file],
        output="screen",
        remappings=[
            ("/tf", "tf"),
            ("/tf_static", "tf_static"),
            ("/goal_pose", "goal_pose"),
            ("/clicked_point", "clicked_point"),
            ("/initialpose", "initialpose"),
        ],
    )

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

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

    # Add any conditioned actions
    ld.add_action(start_namespaced_rviz_cmd)

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

    return ld
コード例 #13
0
# limitations under the License.

"""Tests for the OnShutdown event handler."""

from unittest.mock import Mock
from unittest.mock import NonCallableMock

from launch import LaunchContext
from launch.action import Action
from launch.event_handlers.on_shutdown import OnShutdown
from launch.events import Shutdown
from launch.events.process import ProcessStarted

phony_process_started = ProcessStarted(
    action=Mock(spec=Action), name='PhonyProcessStarted', cmd=['ls'], cwd=None, env=None, pid=1)
phony_shutdown = Shutdown()
phony_context = Mock(spec=LaunchContext)


def test_matches_shutdown():
    handler = OnShutdown(on_shutdown=Mock())
    assert handler.matches(phony_shutdown)
    assert not handler.matches(phony_process_started)


def test_handle_callable():
    mock_callable = Mock()
    handler = OnShutdown(on_shutdown=mock_callable)
    handler.handle(phony_shutdown, phony_context)
    mock_callable.assert_called_once_with(phony_shutdown, phony_context)
コード例 #14
0
def generate_launch_description():

    namespace = LaunchConfiguration('namespace')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    bt_xml_file = LaunchConfiguration('bt_xml_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,
        'bt_xml_filename': bt_xml_file,
    }

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

    return LaunchDescription([
        DeclareLaunchArgument('namespace',
                              default_value='',
                              description='Top-level namespace'),
        DeclareLaunchArgument('use_sim_time',
                              default_value='false',
                              description='Use simulation/bag clock if true'),
        DeclareLaunchArgument(
            'params_file',
            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_remappings',
            default_value='false',
            description='Arguments to pass to all nodes launched by the file'),
        Node(
            package='nav2_controller',
            node_executable='controller_server',
            output='log',
            parameters=[configured_params],
            use_remappings=IfCondition(use_remappings),
            remappings=remappings,
            on_exit=EmitEvent(event=Shutdown(reason='nav2_controller_error'))),
        Node(package='nav2_planner',
             node_executable='planner_server',
             node_name='planner_server',
             output='log',
             parameters=[configured_params],
             use_remappings=IfCondition(use_remappings),
             remappings=remappings,
             on_exit=EmitEvent(event=Shutdown(reason='nav2_planner_error'))),
        Node(
            package='nav2_recoveries',
            node_executable='recoveries_server',
            node_name='recoveries_server',
            output='log',
            parameters=[{
                'use_sim_time': use_sim_time
            }],
            use_remappings=IfCondition(use_remappings),
            remappings=remappings,
            on_exit=EmitEvent(event=Shutdown(reason='nav2_recoveries_error'))),
        Node(package='nav2_bt_navigator',
             node_executable='bt_navigator',
             node_name='bt_navigator',
             output='log',
             parameters=[configured_params],
             use_remappings=IfCondition(use_remappings),
             remappings=remappings,
             on_exit=EmitEvent(event=Shutdown(
                 reason='nav2_bt_navigator_error'))),
        Node(package='nav2_waypoint_follower',
             node_executable='waypoint_follower',
             node_name='waypoint_follower',
             output='log',
             parameters=[configured_params],
             use_remappings=IfCondition(use_remappings),
             remappings=remappings,
             on_exit=EmitEvent(event=Shutdown(
                 reason='nav2_waypoint_follower_error'))),
    ])
コード例 #15
0
def generate_launch_description():
    # Get the launch directory
    nav2_bringup_dir = get_package_share_directory('nav2_bringup')
    marathon_dir = get_package_share_directory('marathon_ros2_bringup')
    marathon_launch_dir = os.path.join(marathon_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')
    bt_xml_file = LaunchConfiguration('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(marathon_dir, 'maps/aulario', '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(marathon_dir, 'params',
                                   'nav2_marathon_teb_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(
        'bt_xml_file',
        default_value=os.path.join(
            get_package_share_directory('marathon_ros2_bringup'),
            'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),
        description='Full path to the behavior tree xml file to use')

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

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

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

    start_rviz_cmd = Node(condition=IfCondition(use_rviz),
                          package='rviz2',
                          node_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(marathon_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': bt_xml_file,
                                               'autostart': autostart,
                                               'cmd_vel_topic': cmd_vel_topic
                                           }.items())

    marathon_cmd = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        os.path.join(marathon_launch_dir, 'nav2_marathon_launch.py')),
                                            launch_arguments={
                                                'total_distance_sum': '0.25',
                                                'next_wp': '0'
                                            }.items())

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

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

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

    # Add any conditioned actions
    ld.add_action(start_rviz_cmd)

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

    ld.add_action(marathon_cmd)

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

    return ld
コード例 #16
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')
    map_yaml_file = LaunchConfiguration('map')
    use_sim_time = LaunchConfiguration('use_sim_time')
    params_file = LaunchConfiguration('params_file')
    bt_xml_file = LaunchConfiguration('bt_xml_file')
    autostart = LaunchConfiguration('autostart')
    use_remappings = LaunchConfiguration('use_remappings')

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

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

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

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

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

    declare_params_file_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_share_directory('nav2_bt_navigator'), 'behavior_trees',
            'navigate_w_replanning_and_recovery.xml'),
        description='Full path to the behavior tree xml file to use')

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

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

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

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

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

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

    declare_simulator_cmd = DeclareLaunchArgument(
        'simulator',
        default_value='gazebo',
        description='The simulator to use (gazebo or gzserver)')

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

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

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

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

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

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

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

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

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

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

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

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

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

    return ld
コード例 #17
0
 def _finish(self, test_name):
     """Mark test as finished and shutdown if all other tests have finished too."""
     assert test_name in self.__tests
     self.__tests[test_name] = 'finished'
     if all(status != 'armed' for status in self.__tests.values()):
         return [EmitEvent(event=Shutdown(reason='all tests finished'))]
コード例 #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')

    # Create the launch configuration variables
    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')

    # Launch configuration variables specific to simulation
    rviz_config_file = LaunchConfiguration('rviz_config_file')
    use_simulator = LaunchConfiguration('use_simulator')
    simulator = LaunchConfiguration('simulator')
    world = LaunchConfiguration('world')

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

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

    declare_params_file_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='false',
        description='Automatically startup the nav2 stack')

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

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

    declare_simulator_cmd = DeclareLaunchArgument(
        'simulator',
        default_value='gazebo',
        description='The simulator to use (gazebo or gzserver)')

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

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

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

    start_robot_state_publisher_cmd = Node(
        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])

    # TODO(orduno) RVIZ crashing if launched as a node: https://github.com/ros2/rviz/issues/442
    #              Launching as node works after applying the change described on the github issue.
    # start_rviz_cmd = Node(
    #     package='rviz2',
    #     node_executable='rviz2',
    #     node_name='rviz2',
    #     arguments=['-d', rviz_config_file],
    #     output='screen')

    start_rviz_cmd = ExecuteProcess(cmd=[
        os.path.join(get_package_prefix('rviz2'), 'lib/rviz2/rviz2'),
        ['-d', rviz_config_file]
    ],
                                    cwd=[launch_dir],
                                    output='screen')

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

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

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

    # 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_bt_xml_cmd)
    ld.add_action(declare_autostart_cmd)

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

    # Add any actions to launch in simulation (conditioned on 'use_simulator')
    ld.add_action(start_gazebo_cmd)

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

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

    return ld
コード例 #19
0
def generate_launch_description():
    # Get the launch directory
    marta_launch_dir = os.path.join(
        get_package_share_directory('marta_launch'), 'launch')
    rover_config_dir = get_package_share_directory('rover_config')

    # 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')
    default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename')
    autostart = LaunchConfiguration('autostart')

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

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

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

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

    declare_params_file_cmd = DeclareLaunchArgument(
        'params_file',
        default_value=os.path.join(rover_config_dir, 'config',
                                   'nav2_params.yaml'),
        description=
        'Full path to the ROS2 parameters file to use for all launchde 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')

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

    declare_use_simulator_cmd = DeclareLaunchArgument(
        'use_simulator',
        default_value='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_use_rviz_cmd = DeclareLaunchArgument(
        'use_rviz', default_value='True', description='Whether to start RVIZ')

    declare_world_path_cmd = DeclareLaunchArgument(
        'world_path',
        # TODO(orduno) Switch back once ROS argument passing has been fixed upstream
        #              https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91

        # TURTLEBOT EXAMPLE
        # default_value=os.path.join(rover_config_dir, 'worlds', 'tb3_world.model'),
        # EMPTY WORLD
        default_value=os.path.join(rover_config_dir, 'worlds', 'empty.world'),
        description='Full path to world model file to load')

    # Specify the actions
    locomotion_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'locomotion.launch.py')))

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

    # Start Nav2 Stack
    bringup_cmd = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(marta_launch_dir, 'nav2_bringup_launch.py')),
        # PythonLaunchDescriptionSource(os.path.join(launch_dir, 'nav2_bringup_launch.py')),
        launch_arguments={
            'namespace': namespace,
            'map': map_yaml_file,
            'use_sim_time': use_sim_time,
            'params_file': params_file,
            'default_bt_xml_filename': default_bt_xml_filename,
            'autostart': autostart
        }.items())

    start_rviz_cmd = Node(
        condition=IfCondition(use_rviz),
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        # 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'},
        arguments=['-d', rviz_config_file],
        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'))))

    # 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_sim_time_cmd,
        declare_map_yaml_cmd,
        declare_params_file_cmd,
        declare_bt_xml_cmd,
        declare_autostart_cmd,
        declare_rviz_config_file_cmd,
        declare_use_simulator_cmd,
        declare_use_rviz_cmd,
        declare_use_gazebo_gui_cmd,
        declare_world_path_cmd,

        # Add any conditioned actions
        start_rviz_cmd,

        # Add other nodes and processes we need
        exit_event_handler,

        # Add the actions to launch all of the navigation nodes
        locomotion_cmd,
        simulation_cmd,
        bringup_cmd
    ])
コード例 #20
0
    def launch_setup(self, context, *args, **kwargs):
        test_param_file = self.random_test_runner_launch_configuration[
            "test_parameters_filename"].perform(context)
        print("Test param file '{}'".format(test_param_file))

        autoware_architecture = self.autoware_launch_configuration[
            "architecture_type"].perform(context)
        print("Autoware architecture '{}'".format(autoware_architecture))

        parameters = [
            self.autoware_launch_configuration, {
                "autoware_launch_package":
                default_autoware_launch_package_of(autoware_architecture),
                "autoware_launch_file":
                default_autoware_launch_file_of(autoware_architecture)
            }, self.random_test_runner_launch_configuration
        ]

        if test_param_file:
            test_param_file_path = os.path.join(
                get_package_share_directory("random_test_runner"), "param",
                test_param_file)
            print(
                "Parameters file supplied: '{}'. "
                "Parameters passed there override passed via arguments".format(
                    test_param_file_path))
            parameters.append(test_param_file_path)

        # not tested for other architectures but required for "awf/universe"
        if autoware_architecture == "awf/universe":
            vehicle_model = self.autoware_launch_configuration[
                "vehicle_model"].perform(context)
            if vehicle_model:
                vehicle_model_description_dir = get_package_share_directory(
                    vehicle_model + "_description")

                vehicle_info_param_file_path = os.path.join(
                    vehicle_model_description_dir,
                    "config/vehicle_info.param.yaml")
                simulator_model_param_file_path = os.path.join(
                    vehicle_model_description_dir,
                    "config/simulator_model.param.yaml")

                print("Vehicle info parameters file supplied: '{}'. "
                      "Parameters passed there override passed via arguments".
                      format(vehicle_info_param_file_path))
                print("Simulator model parameters file supplied: '{}'. "
                      "Parameters passed there override passed via arguments".
                      format(simulator_model_param_file_path))
                parameters.append(vehicle_info_param_file_path)
                parameters.append(simulator_model_param_file_path)

        scenario_node = Node(package="random_test_runner",
                             executable="random_test_runner",
                             namespace="simulation",
                             name="random_test_runner",
                             output="screen",
                             arguments=[("__log_level:=info")],
                             parameters=parameters)

        shutdown_handler = OnProcessExit(target_action=scenario_node,
                                         on_exit=[EmitEvent(event=Shutdown())])

        launch_description = [
            scenario_node,
            RegisterEventHandler(event_handler=shutdown_handler),
            Node(
                package="openscenario_visualization",
                executable="openscenario_visualization_node",
                namespace="simulation",
                name="openscenario_visualizer",
                output="screen",
            ),
        ]

        simulation_type = self.random_test_runner_launch_configuration[
            "simulator_type"].perform(context)
        print("Chosen simulation type", simulation_type)
        if simulation_type == "simple_sensor_simulator":
            launch_description.append(
                Node(
                    package="simple_sensor_simulator",
                    executable="simple_sensor_simulator_node",
                    name="simple_sensor_simulator_node",
                    namespace="simulation",
                    output="log",
                    arguments=[("__log_level:=warn")],
                    parameters=[{
                        "port": 8080
                    }],
                ), )

        return launch_description
コード例 #21
0
def generate_launch_description():
    # Get the launch directory
    bringup_dir = get_package_share_directory('amazon_robot_bringup')

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

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

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

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

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

    namespaced_rviz_config_file = ReplaceString(
            source_file=rviz_config_file,
            replacements={'<robot_namespace>': ('/', namespace)})

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

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

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

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

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

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

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

    return ld
コード例 #22
0
def generate_launch_description():
    # Get the launch directory
    social_bringup_dir = get_package_share_directory('social_nav2_bringup')
    nav_bringup_dir = get_package_share_directory('nav2_bringup')
    launch_dir = os.path.join(nav_bringup_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')
    bt_xml_file = LaunchConfiguration('bt_xml_file')
    autostart = LaunchConfiguration('autostart')
    use_remappings = LaunchConfiguration('use_remappings')

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

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

    # Declare the launch arguments
    declare_namespace_cmd = 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(social_bringup_dir, 'maps',
                                   'turtlebot3_house.yaml'),
        description='Full path to map file to load')

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

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

    declare_params_file_cmd = DeclareLaunchArgument(
        'params_file',
        default_value=os.path.join(social_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_share_directory('social_nav2_bringup'),
            'behavior_trees', 'follow_point.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(social_bringup_dir, 'rviz',
                                   'nav2_default_view.rviz'),
        description='Full path to the RVIZ config file to use')

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

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

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

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

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

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

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

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

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

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

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

    agent_spawner_cmd = Node(package='pedsim_gazebo_plugin',
                             executable='spawn_pedsim_agents.py',
                             name='spawn_pedsim_agents',
                             output='screen')

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

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

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

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

    ld.add_action(exit_event_handler)

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

    return ld
コード例 #23
0
def generate_launch_description():
    timeout = LaunchConfiguration("timeout", default=10.0)
    scenario = LaunchConfiguration("scenario", default="")
    scenario_package = LaunchConfiguration("package",
                                           default="cpp_mock_scenarios")
    junit_path = LaunchConfiguration("junit_path",
                                     default="/tmp/output.xunit.xml")
    launch_rviz = LaunchConfiguration("launch_rviz", default=False)
    scenario_node = Node(
        package=scenario_package,
        executable=scenario,
        name=scenario,
        output="screen",
        arguments=[("__log_level:=info")],
        parameters=[{
            "junit_path": junit_path,
            "timeout": timeout
        }],
    )
    io_handler = OnProcessIO(
        target_action=scenario_node,
        on_stderr=on_stderr_output,
        on_stdout=on_stdout_output,
    )
    shutdown_handler = OnProcessExit(target_action=scenario_node,
                                     on_exit=[EmitEvent(event=Shutdown())])
    description = LaunchDescription([
        DeclareLaunchArgument("scenario",
                              default_value=scenario,
                              description="Name of the scenario."),
        DeclareLaunchArgument(
            "package",
            default_value=scenario_package,
            description="Name of package your scenario exists",
        ),
        DeclareLaunchArgument("timeout",
                              default_value=timeout,
                              description="Timeout in seconds."),
        DeclareLaunchArgument(
            "junit_path",
            default_value=junit_path,
            description="Path of the junit output.",
        ),
        DeclareLaunchArgument(
            "launch_rviz",
            default_value=launch_rviz,
            description="If true, launch with rviz.",
        ),
        scenario_node,
        RegisterEventHandler(event_handler=io_handler),
        RegisterEventHandler(event_handler=shutdown_handler),
        Node(
            package="simple_sensor_simulator",
            executable="simple_sensor_simulator_node",
            name="simple_sensor_simulator_node",
            output="log",
            arguments=[("__log_level:=warn")],
        ),
        Node(
            package="openscenario_visualization",
            executable="openscenario_visualization_node",
            name="openscenario_visualization_node",
            output="screen",
        ),
        Node(
            package="rviz2",
            executable="rviz2",
            name="rviz2",
            output={
                "stderr": "log",
                "stdout": "log"
            },
            condition=IfCondition(launch_rviz),
            arguments=[
                "-d",
                str(
                    Path(get_package_share_directory("cpp_mock_scenarios")) /
                    "rviz/mock_test.rviz"),
            ],
        ),
    ])
    return description