コード例 #1
0
def test_shutdown_reason():
    """Test the execute (or visit) of a Shutdown class that has a reason."""
    action = Shutdown(reason='test reason')
    context = LaunchContext()
    assert action.visit(context) is None
    assert context._event_queue.qsize() == 1
    event = context._event_queue.get_nowait()
    assert isinstance(event, ShutdownEvent)
    assert event.reason == 'test reason'
コード例 #2
0
def test_shutdown_execute():
    """Test the execute (or visit) of the Shutdown class."""
    action = Shutdown()
    context = LaunchContext()
    assert context._event_queue.qsize() == 0
    assert action.visit(context) is None
    assert context._event_queue.qsize() == 1
    event = context._event_queue.get_nowait()
    assert isinstance(event, ShutdownEvent)
コード例 #3
0
ファイル: executor.launch.py プロジェクト: Wojcik98/hexapod
def generate_launch_description():
    description_path = generate_models()

    return LaunchDescription([
        Node(
            name='robot_state_publisher',
            package='robot_state_publisher',
            executable='robot_state_publisher',
            output='own_log',
            arguments=[description_path],
        ),
        Node(
            name='rviz',
            package='rviz2',
            executable='rviz2',
            output='own_log',
        ),
        Node(
            name='executor',
            package='hex_control',
            executable='executor',
            output='screen',
            on_exit=Shutdown(),
        ),
        # Node(
        #     name='dummy_path_publisher',
        #     package='hex_control',
        #     executable='dummy_path_publisher',
        #     output='screen',
        # ),
    ])
コード例 #4
0
def generate_launch_description():
    return LaunchDescription([
        DeclareLaunchArgument(
            name="config_path",
            default_value=os.path.join(
                get_package_share_directory("march_safety"),
                "config",
                "safety_settings.yaml",
            ),
            description="Path to the configuration for the safety settings",
        ),
        DeclareLaunchArgument(
            name="use_sim_time",
            default_value="true",
            description="Whether to use simulation time",
        ),
        Node(
            package="march_safety",
            executable="march_safety_node",
            name="safety_node",
            namespace="march",
            output="screen",
            parameters=[
                LaunchConfiguration("config_path"),
                {
                    "use_sim_time": LaunchConfiguration("use_sim_time")
                },
            ],
            # If this node exits, the entire system is shutdown
            # This is the ROS2 equivalent of required:=true
            # See: https://ubuntu.com/blog/ros2-launch-required-nodes
            on_exit=Shutdown(),
        ),
    ])
コード例 #5
0
def generate_launch_description():
    """Generate launch file."""

    joy_node = Node(
        package='joy',
        executable='joy_node',
        on_exit=Shutdown(),
    )

    record_joy = Node(
        package='ps_ros2_common',
        executable='joy_test',
        output='screen',
        on_exit=Shutdown(),
    )

    return LaunchDescription([
        joy_node,
        record_joy,
    ])
コード例 #6
0
def generate_launch_description():
    """Launch file for the fake_covid_publisher node that will spam fake possible foot location.
    For more information see '../march_fake_covid/fake_covid_publisher.py'.

    Can change parameters during runtime by calling in a terminal:
        'ros2 param set fake_covid_publisher [param_name] [value]'
        with param_name and value possibilities:
        * location_x: either a double or 'random'
        * location_y: either a double or 'random'
    """
    return LaunchDescription([
        DeclareLaunchArgument(
            name="use_sim_time",
            default_value="True",
            description="Whether to use simulation time as published on the "
            "/clock topic by gazebo instead of system time.",
        ),
        DeclareLaunchArgument(
            name="location_x",
            default_value="0.4",
            description=
            "x-location for fake covid topic, takes double or 'random'",
        ),
        DeclareLaunchArgument(
            name="location_y",
            default_value="0.0",
            description=
            "y-location for fake covid topic, takes double or 'random'",
        ),
        Node(
            package="march_fake_covid",
            executable="march_fake_covid",
            output="screen",
            name="fake_covid_publisher",
            namespace="march",
            parameters=[
                {
                    "use_sim_time": LaunchConfiguration("use_sim_time")
                },
                {
                    "location_x": LaunchConfiguration("location_x")
                },
                {
                    "location_y": LaunchConfiguration("location_y")
                },
            ],
            on_exit=Shutdown(),
        ),
    ])
コード例 #7
0
    def generate_launch_description():
        return LaunchDescription([

            ExecuteLocal(
                process_description=Executable(cmd=[sys.executable, '-c', "print('action')"]),
                respawn=True, respawn_delay=respawn_delay, on_exit=on_exit_callback
            ),

            TimerAction(
                period=shutdown_time,
                actions=[
                    Shutdown(reason='Timer expired')
                ]
            )
        ])
コード例 #8
0
def test_shutdown_execute_conditional():
    """Test the conditional execution (or visit) of the Shutdown class."""
    true_action = Shutdown(condition=IfCondition('True'))
    false_action = Shutdown(condition=IfCondition('False'))
    context = LaunchContext()

    assert context._event_queue.qsize() == 0
    assert false_action.visit(context) is None
    assert context._event_queue.qsize() == 0
    assert true_action.visit(context) is None
    assert context._event_queue.qsize() == 1
    event = context._event_queue.get_nowait()
    assert isinstance(event, ShutdownEvent)
コード例 #9
0
def generate_launch_description():
    return LaunchDescription([
        Node(
            package="test_minimal_publisher",
            executable="test_minimal_publisher_node",
            name="test_minimal_publisher_node",
        ),
        Node(
            package="test_minimal_subscriber",
            executable="test_minimal_subscriber_node",
            name="test_minimal_subscriber_node",
            output="screen",
            emulate_tty=True,
            parameters=[{
                "exit_after_receive": True
            }],
            on_exit=Shutdown(),
        ),
    ])
コード例 #10
0
ファイル: test_node.py プロジェクト: ross-desmond/launch_ros
    def test_launch_required_node(self):
        # This node will never exit on its own, it'll keep publishing forever.
        long_running_node = launch_ros.actions.Node(
            package='demo_nodes_py', node_executable='talker_qos', output='screen',
            node_namespace='my_ns',
        )

        # This node will exit after publishing a single message. It is required, so we
        # tie on_exit to the Shutdown action which means that, once it exits, it should
        # bring down the whole launched system, including the above node that will never
        # exit on its own.
        required_node = launch_ros.actions.Node(
            package='demo_nodes_py', node_executable='talker_qos', output='screen',
            node_namespace='my_ns2', arguments=['--number_of_cycles', '1'],
            on_exit=Shutdown()
        )

        # If the on_exit functionality or Shutdown action breaks, this will never return.
        self._assert_launch_no_errors([required_node, long_running_node])
コード例 #11
0
def generate_launch_description():

    return LaunchDescription([
        DeclareLaunchArgument('namespace', default_value=''),
        Node(
            package='rviz2',
            executable='rviz2',
            arguments=[
                '-d',
                os.path.join(
                    get_package_share_directory('naosoccer_visualization_launch'),
                    'rviz', 'nao.rviz')
            ],
            namespace=LaunchConfiguration('namespace'),
            on_exit=Shutdown()
        ),
        Node(
            package='soccer_marker_generation',
            executable='ball_to_marker',
            namespace=LaunchConfiguration('namespace')
        ),
        Node(
            package='soccer_marker_generation',
            executable='goalpost_array_to_marker_array',
            namespace=LaunchConfiguration('namespace')
        ),
        Node(
            package='soccer_marker_generation',
            executable='field_line_array_to_marker_array',
            namespace=LaunchConfiguration('namespace')
        ),
        Node(
            package='soccer_marker_generation',
            executable='robot_array_to_marker_array',
            namespace=LaunchConfiguration('namespace')
        ),
    ])
コード例 #12
0
def launch_setup(context, *args, **kwargs):
    # fmt: off
    architecture_type = LaunchConfiguration("architecture_type",
                                            default="awf/universe")
    autoware_launch_file = LaunchConfiguration(
        "autoware_launch_file",
        default=default_autoware_launch_file_of(
            architecture_type.perform(context)))
    autoware_launch_package = LaunchConfiguration(
        "autoware_launch_package",
        default=default_autoware_launch_package_of(
            architecture_type.perform(context)))
    global_frame_rate = LaunchConfiguration("global_frame_rate", default=30.0)
    global_real_time_factor = LaunchConfiguration("global_real_time_factor",
                                                  default=1.0)
    global_timeout = LaunchConfiguration("global_timeout", default=180)
    initialize_duration = LaunchConfiguration("initialize_duration",
                                              default=30)
    launch_autoware = LaunchConfiguration("launch_autoware", default=True)
    launch_rviz = LaunchConfiguration("launch_rviz", default=False)
    output_directory = LaunchConfiguration("output_directory",
                                           default=Path("/tmp"))
    port = LaunchConfiguration("port", default=8080)
    record = LaunchConfiguration("record", default=True)
    scenario = LaunchConfiguration("scenario", default=Path("/dev/null"))
    sensor_model = LaunchConfiguration("sensor_model", default="")
    sigterm_timeout = LaunchConfiguration("sigterm_timeout", default=8)
    vehicle_model = LaunchConfiguration("vehicle_model", default="")
    workflow = LaunchConfiguration("workflow", default=Path("/dev/null"))
    # fmt: on

    print(f"architecture_type       := {architecture_type.perform(context)}")
    print(
        f"autoware_launch_file    := {autoware_launch_file.perform(context)}")
    print(
        f"autoware_launch_package := {autoware_launch_package.perform(context)}"
    )
    print(f"global_frame_rate       := {global_frame_rate.perform(context)}")
    print(
        f"global_real_time_factor := {global_real_time_factor.perform(context)}"
    )
    print(f"global_timeout          := {global_timeout.perform(context)}")
    print(f"initialize_duration     := {initialize_duration.perform(context)}")
    print(f"launch_autoware         := {launch_autoware.perform(context)}")
    print(f"launch_rviz             := {launch_rviz.perform(context)}")
    print(f"output_directory        := {output_directory.perform(context)}")
    print(f"port                    := {port.perform(context)}")
    print(f"record                  := {record.perform(context)}")
    print(f"scenario                := {scenario.perform(context)}")
    print(f"sensor_model            := {sensor_model.perform(context)}")
    print(f"sigterm_timeout         := {sigterm_timeout.perform(context)}")
    print(f"vehicle_model           := {vehicle_model.perform(context)}")
    print(f"workflow                := {workflow.perform(context)}")

    def make_parameters():
        parameters = [
            {
                "architecture_type": architecture_type
            },
            {
                "autoware_launch_file": autoware_launch_file
            },
            {
                "autoware_launch_package": autoware_launch_package
            },
            {
                "initialize_duration": initialize_duration
            },
            {
                "launch_autoware": launch_autoware
            },
            {
                "port": port
            },
            {
                "record": record
            },
            {
                "sensor_model": sensor_model
            },
            {
                "vehicle_model": vehicle_model
            },
        ]

        def description():
            return get_package_share_directory(
                vehicle_model.perform(context) + "_description")

        if vehicle_model.perform(context):
            parameters.append(description() +
                              "/config/vehicle_info.param.yaml")
            parameters.append(description() +
                              "/config/simulator_model.param.yaml")

        return parameters

    return [
        # fmt: off
        DeclareLaunchArgument("architecture_type",
                              default_value=architecture_type),
        DeclareLaunchArgument("autoware_launch_file",
                              default_value=autoware_launch_file),
        DeclareLaunchArgument("autoware_launch_package",
                              default_value=autoware_launch_package),
        DeclareLaunchArgument("global_frame_rate",
                              default_value=global_frame_rate),
        DeclareLaunchArgument("global_real_time_factor",
                              default_value=global_real_time_factor),
        DeclareLaunchArgument("global_timeout", default_value=global_timeout),
        DeclareLaunchArgument("launch_autoware",
                              default_value=launch_autoware),
        DeclareLaunchArgument("launch_rviz", default_value=launch_rviz),
        DeclareLaunchArgument("output_directory",
                              default_value=output_directory),
        DeclareLaunchArgument("scenario", default_value=scenario),
        DeclareLaunchArgument("sensor_model", default_value=sensor_model),
        DeclareLaunchArgument("sigterm_timeout",
                              default_value=sigterm_timeout),
        DeclareLaunchArgument("vehicle_model", default_value=vehicle_model),
        DeclareLaunchArgument("workflow", default_value=workflow),
        # fmt: on
        Node(
            package="scenario_test_runner",
            executable="scenario_test_runner",
            namespace="simulation",
            name="scenario_test_runner",
            output="screen",
            on_exit=Shutdown(),
            arguments=[
                # fmt: off
                "--global-frame-rate",
                global_frame_rate,
                "--global-real-time-factor",
                global_real_time_factor,
                "--global-timeout",
                global_timeout,
                "--output-directory",
                output_directory,
                "--scenario",
                scenario,
                "--workflow",
                workflow,
                # fmt: on
            ],
        ),
        Node(
            package="simple_sensor_simulator",
            executable="simple_sensor_simulator_node",
            namespace="simulation",
            name="simple_sensor_simulator",
            output="screen",
            parameters=[{
                "port": port
            }],
        ),
        LifecycleNode(
            package="openscenario_interpreter",
            executable="openscenario_interpreter_node",
            namespace="simulation",
            name="openscenario_interpreter",
            output="screen",
            parameters=make_parameters(),
            # on_exit=Shutdown(),
        ),
        Node(
            package="openscenario_visualization",
            executable="openscenario_visualization_node",
            namespace="simulation",
            name="openscenario_visualizer",
            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("scenario_test_runner"))
                    Path(get_package_share_directory("traffic_simulator")) /
                    "config/scenario_simulator_v2.rviz"),
            ],
        ),
    ]
コード例 #13
0
def generate_launch_description():
    cmd = [[
        'gzclient',
        _boolean_command('version'),
        ' ',
        _boolean_command('verbose'),
        ' ',
        _boolean_command('help'),
        ' ',
        LaunchConfiguration('extra_gazebo_args'),
    ]]

    model, plugin, media = GazeboRosPaths.get_paths()

    if 'GAZEBO_MODEL_PATH' in environ:
        model += pathsep + environ['GAZEBO_MODEL_PATH']
    if 'GAZEBO_PLUGIN_PATH' in environ:
        plugin += pathsep + environ['GAZEBO_PLUGIN_PATH']
    if 'GAZEBO_RESOURCE_PATH' in environ:
        media += pathsep + environ['GAZEBO_RESOURCE_PATH']

    env = {
        'GAZEBO_MODEL_PATH': model,
        'GAZEBO_PLUGIN_PATH': plugin,
        'GAZEBO_RESOURCE_PATH': media,
    }

    prefix = PythonExpression([
        '"gdb -ex run --args" if "true" == "',
        LaunchConfiguration('gdb'),
        '"else "valgrind" if "true" == "',
        LaunchConfiguration('valgrind'),
        '"else ""',
    ])

    return LaunchDescription([
        DeclareLaunchArgument(
            'version',
            default_value='false',
            description='Set "true" to output version information'),
        DeclareLaunchArgument(
            'verbose',
            default_value='false',
            description='Set "true" to increase messages written to terminal'),
        DeclareLaunchArgument(
            'help',
            default_value='false',
            description='Set "true" to produce gzclient help message'),
        DeclareLaunchArgument(
            'extra_gazebo_args',
            default_value='',
            description='Extra arguments to be passed to Gazebo'),

        # Specific to gazebo_ros
        DeclareLaunchArgument(
            'gdb',
            default_value='false',
            description='Set "true" to run gzserver with gdb'),
        DeclareLaunchArgument(
            'valgrind',
            default_value='false',
            description='Set "true" to run gzserver with valgrind'),
        DeclareLaunchArgument(
            'gui_required',
            default_value='false',
            description=
            'Set "true" to shut down launch script when GUI is terminated'),

        # Execute node with on_exit=Shutdown if gui_required is specified.
        # See ros-simulation/gazebo_ros_pkgs#1086. Simplification of logic
        # would be possible pending ros2/launch#290.
        ExecuteProcess(
            cmd=cmd,
            output='screen',
            additional_env=env,
            shell=True,
            prefix=prefix,
            on_exit=Shutdown(),
            condition=IfCondition(LaunchConfiguration('gui_required')),
        ),

        # Execute node with default on_exit if the node is not required
        ExecuteProcess(
            cmd=cmd,
            output='screen',
            additional_env=env,
            shell=True,
            prefix=prefix,
            condition=UnlessCondition(LaunchConfiguration('gui_required')),
        ),
    ])
コード例 #14
0
def generate_launch_description():
    cmd = [
        'gzserver',
        # Pass through arguments to gzserver
        LaunchConfiguration('world'), ' ',
        _boolean_command('version'), ' ',
        _boolean_command('verbose'), ' ',
        _boolean_command('lockstep'), ' ',
        _boolean_command('help'), ' ',
        _boolean_command('pause'), ' ',
        _arg_command('physics'), ' ', LaunchConfiguration('physics'), ' ',
        _arg_command('play'), ' ', LaunchConfiguration('play'), ' ',
        _boolean_command('record'), ' ',
        _arg_command('record_encoding'), ' ', LaunchConfiguration('record_encoding'), ' ',
        _arg_command('record_path'), ' ', LaunchConfiguration('record_path'), ' ',
        _arg_command('record_period'), ' ', LaunchConfiguration('record_period'), ' ',
        _arg_command('record_filter'), ' ', LaunchConfiguration('record_filter'), ' ',
        _arg_command('seed'), ' ', LaunchConfiguration('seed'), ' ',
        _arg_command('iters'), ' ', LaunchConfiguration('iters'), ' ',
        _boolean_command('minimal_comms'),
        _plugin_command('init'), ' ',
        _plugin_command('factory'), ' ',
        _plugin_command('force_system'), ' ',
        # Wait for (https://github.com/ros-simulation/gazebo_ros_pkgs/pull/941)
        # _plugin_command('force_system'), ' ',
        _arg_command('profile'), ' ', LaunchConfiguration('profile'),
        LaunchConfiguration('extra_gazebo_args'),
    ]

    model, plugin, media = GazeboRosPaths.get_paths()

    if 'GAZEBO_MODEL_PATH' in environ:
        model += pathsep+environ['GAZEBO_MODEL_PATH']
    if 'GAZEBO_PLUGIN_PATH' in environ:
        plugin += pathsep+environ['GAZEBO_PLUGIN_PATH']
    if 'GAZEBO_RESOURCE_PATH' in environ:
        media += pathsep+environ['GAZEBO_RESOURCE_PATH']

    env = {
        'GAZEBO_MODEL_PATH': model,
        'GAZEBO_PLUGIN_PATH': plugin,
        'GAZEBO_RESOURCE_PATH': media
    }

    prefix = PythonExpression([
        '"gdb -ex run --args" if "true" == "',
        LaunchConfiguration('gdb'),
        '" else "valgrind" if "true" == "',
        LaunchConfiguration('valgrind'),
        '" else ""'
    ])

    return LaunchDescription([
        DeclareLaunchArgument(
            'world', default_value='',
            description='Specify world file name'
        ),
        DeclareLaunchArgument(
            'version', default_value='false',
            description='Set "true" to output version information.'
        ),
        DeclareLaunchArgument(
            'verbose', default_value='false',
            description='Set "true" to increase messages written to terminal.'
        ),
        DeclareLaunchArgument(
            'lockstep', default_value='false',
            description='Set "true" to respect update rates'
        ),
        DeclareLaunchArgument(
            'help', default_value='false',
            description='Set "true" to produce gzserver help message.'
        ),
        DeclareLaunchArgument(
            'pause', default_value='false',
            description='Set "true" to start the server in a paused state.'
        ),
        DeclareLaunchArgument(
            'physics', default_value='',
            description='Specify a physics engine (ode|bullet|dart|simbody).'
        ),
        DeclareLaunchArgument(
            'play', default_value='',
            description='Play the specified log file.'
        ),
        DeclareLaunchArgument(
            'record', default_value='false',
            description='Set "true" to record state data.'
        ),
        DeclareLaunchArgument(
            'record_encoding', default_value='',
            description='Specify compression encoding format for log data (zlib|bz2|txt).'
        ),
        DeclareLaunchArgument(
            'record_path', default_value='',
            description='Absolute path in which to store state data.'
        ),
        DeclareLaunchArgument(
            'record_period', default_value='',
            description='Specify recording period (seconds).'
        ),
        DeclareLaunchArgument(
            'record_filter', default_value='',
            description='Specify recording filter (supports wildcard and regular expression).'
        ),
        DeclareLaunchArgument(
            'seed', default_value='', description='Start with a given a random number seed.'
        ),
        DeclareLaunchArgument(
            'iters', default_value='', description='Specify number of iterations to simulate.'
        ),
        DeclareLaunchArgument(
            'minimal_comms', default_value='false',
            description='Set "true" to reduce TCP/IP traffic output.'
        ),
        DeclareLaunchArgument(
            'profile', default_value='',
            description='Specify physics preset profile name from the options in the world file.'
        ),
        DeclareLaunchArgument(
            'extra_gazebo_args', default_value='',
            description='Extra arguments to be passed to Gazebo'
        ),

        # Specific to gazebo_ros
        DeclareLaunchArgument(
            'gdb', default_value='false',
            description='Set "true" to run gzserver with gdb'
        ),
        DeclareLaunchArgument(
            'valgrind', default_value='false',
            description='Set "true" to run gzserver with valgrind'
        ),
        DeclareLaunchArgument(
            'init', default_value='true',
            description='Set "false" not to load "libgazebo_ros_init.so"'
        ),
        DeclareLaunchArgument(
            'factory', default_value='true',
            description='Set "false" not to load "libgazebo_ros_factory.so"'
        ),
        DeclareLaunchArgument(
            'force_system', default_value='true',
            description='Set "false" not to load "libgazebo_ros_force_system.so"'
        ),
        DeclareLaunchArgument(
            'server_required', default_value='false',
            description='Set "true" to shut down launch script when server is terminated'
        ),

        # Execute node with on_exit=Shutdown if server_required is specified.
        # See ros-simulation/gazebo_ros_pkgs#1086. Simplification of logic
        # would be possible pending ros2/launch#290.
        ExecuteProcess(
            cmd=cmd,
            output='screen',
            additional_env=env,
            shell=True,
            prefix=prefix,
            on_exit=Shutdown(),
            condition=IfCondition(LaunchConfiguration('server_required')),
        ),

        # Execute node with default on_exit if the node is not required
        ExecuteProcess(
            cmd=cmd,
            output='screen',
            additional_env=env,
            shell=True,
            prefix=prefix,
            condition=UnlessCondition(LaunchConfiguration('server_required')),
        ),
    ])
def generate_launch_description():
    """Launch controller_testing_node and pure purusit controller."""
    controller_testing_pkg_prefix = get_package_share_directory("controller_testing")
    controller_testing_param_file = os.path.join(
        controller_testing_pkg_prefix, "param/defaults.param.yaml"
    )
    rviz_cfg_path = os.path.join(controller_testing_pkg_prefix, 'config/pure_pursuit_cotrols.rviz')

    pure_pursuit_pkg_prefix = get_package_share_directory("pure_pursuit_nodes")
    pure_pursuit_param_file = os.path.join(
        pure_pursuit_pkg_prefix, "param/pure_pursuit.param.yaml"
    )

    urdf_pkg_prefix = get_package_share_directory('lexus_rx_450h_description')
    urdf_path = os.path.join(urdf_pkg_prefix, 'urdf/lexus_rx_450h.urdf')

    # Arguments
    controller_testing_param = DeclareLaunchArgument(
        "controller_testing_param_file",
        default_value=controller_testing_param_file,
        description="Path to config file for Controller Testing",
    )

    pure_pursuit_controller_param = DeclareLaunchArgument(
        "pure_pursuit_param_file",
        default_value=pure_pursuit_param_file,
        description="Path to config file to Pure Pursuit Controller",
    )

    with_rviz_param = DeclareLaunchArgument(
        'with_rviz',
        default_value='True',
        description='Launch RVIZ2 in addition to other nodes'
    )

    real_time_sim_param = DeclareLaunchArgument(
        'real_time_sim',
        default_value='False',
        description='Launch RVIZ2 in addition to other nodes'
    )

    # Nodes

    controller_testing = Node(
        package="controller_testing",
        node_executable="controller_testing_main.py",
        node_namespace="control",
        node_name="controller_testing_node",
        output="screen",
        parameters=[LaunchConfiguration("controller_testing_param_file"), {
            'real_time_sim': LaunchConfiguration('real_time_sim')
        }],
        remappings=[
            ("vehicle_state", "/vehicle/vehicle_kinematic_state"),
            ("planned_trajectory", "/planning/trajectory"),
            ("control_command", "/vehicle/control_command"),
            ("control_diagnostic", "/control/control_diagnostic"),
        ],
        on_exit=Shutdown(),
        condition=UnlessCondition(LaunchConfiguration('with_rviz'))
    )
    controller_testing_delayed = Node(
        package="controller_testing",
        node_executable="controller_testing_main.py",
        node_namespace="control",
        node_name="controller_testing_node",
        output="screen",
        parameters=[LaunchConfiguration("controller_testing_param_file"), {
            'real_time_sim': LaunchConfiguration('real_time_sim')
        }],
        remappings=[
            ("vehicle_state", "/vehicle/vehicle_kinematic_state"),
            ("planned_trajectory", "/planning/trajectory"),
            ("control_command", "/vehicle/control_command"),
            ("control_diagnostic", "/control/control_diagnostic"),
        ],
        on_exit=Shutdown(),
        # delay added to allow rviz to be ready, better to start rviz separately, beforehand
        prefix="bash -c 'sleep 2.0; $0 $@'",
        condition=IfCondition(LaunchConfiguration('with_rviz'))
    )

    # pure pursuit controller
    pure_pursuit_controller = Node(
        package="pure_pursuit_nodes",
        node_executable="pure_pursuit_node_exe",
        # node_namespace="control",
        node_name="pure_pursuit_node",
        output="screen",
        parameters=[LaunchConfiguration("pure_pursuit_param_file"), {}],
        remappings=[
            ("current_pose", "/vehicle/vehicle_kinematic_state"),
            ("trajectory", "/planning/trajectory"),
            ("ctrl_cmd", "/vehicle/control_command"),
            ("ctrl_diag", "/control/control_diagnostic"),
        ],
    )

    rviz2 = Node(
        package='rviz2',
        node_executable='rviz2',
        node_name='rviz2',
        arguments=['-d', str(rviz_cfg_path)],
        condition=IfCondition(LaunchConfiguration('with_rviz'))
    )
    urdf_publisher = Node(
        package='robot_state_publisher',
        node_executable='robot_state_publisher',
        node_name='robot_state_publisher',
        arguments=[str(urdf_path)]
    )

    return LaunchDescription(
        [
            real_time_sim_param,
            controller_testing_param,
            pure_pursuit_controller_param,
            with_rviz_param,
            rviz2,
            urdf_publisher,
            pure_pursuit_controller,
            controller_testing,          # if not with_rviz
            controller_testing_delayed   # with_rviz
        ]
    )
コード例 #16
0
def generate_launch_description():
    """Basic launch file to launch the gait selection node"""
    return LaunchDescription([
        DeclareLaunchArgument(
            "use_sim_time",
            default_value="true",
            description="Whether to use simulation time as published on the "
            "/clock topic by gazebo instead of system time.",
        ),
        DeclareLaunchArgument(
            "gait_package",
            default_value="march_gait_files",
            description="The package where the gait files are located.",
        ),
        DeclareLaunchArgument(
            "gait_directory",
            default_value="airgait_vi",
            description="The directory in which the gait files to use are "
            "located, relative to the gait_package.",
        ),
        DeclareLaunchArgument(
            "balance",
            default_value="False",
            description="Whether balance is being used.",
        ),
        DeclareLaunchArgument(
            "dynamic_gait",
            default_value="False",
            description="Wether dynamic_setpoint_gait is enabled",
        ),
        # Dynamic gait parameters:
        DeclareLaunchArgument(
            name="dynamic_subgait_duration",
            default_value="1.5",
            description="Duration of a subgait created by the dynamic gait",
        ),
        DeclareLaunchArgument(
            name="middle_point_fraction",
            default_value="0.45",
            description="Fraction of the step at which the middle point "
            "of the dynamic gait will take place.",
        ),
        DeclareLaunchArgument(
            name="middle_point_height",
            default_value="0.15",
            description="Height of the middle setpoint of dynamic gait "
            "relative to the desired position, given in meters.",
        ),
        DeclareLaunchArgument(
            name="minimum_stair_height",
            default_value="0.15",
            description="A step lower or higher than the minimum_stair_height"
            "will change the gait type to stairs_like instead of walk_like.",
        ),
        DeclareLaunchArgument(
            name="push_off_fraction",
            default_value="0.15",
            description="Fraction of the step at which the push off will"
            "take place.",
        ),
        DeclareLaunchArgument(
            name="push_off_position",
            default_value="-0.15",
            description="Maximum joint position of the ankle during push off.",
        ),
        # State machine parameters:
        DeclareLaunchArgument(
            name="first_subgait_delay",
            default_value="0.2",
            description="Duration to wait before starting first subgait."
            "If 0 then the first subgait is started immediately,"
            "dropping the first setpoint in the process.",
        ),
        DeclareLaunchArgument(
            name="early_schedule_duration",
            default_value="0.2",
            description="Duration to schedule next subgait early. If 0 then the"
            "next subgait is never scheduled early.",
        ),
        DeclareLaunchArgument(name="timer_period",
                              default_value="0.004",
                              description=""),
        Node(
            package="march_gait_selection",
            executable="march_gait_selection",
            output="screen",
            name="gait_selection",
            namespace="march",
            parameters=[
                {
                    "use_sim_time": LaunchConfiguration("use_sim_time")
                },
                {
                    "gait_package": LaunchConfiguration("gait_package")
                },
                {
                    "gait_directory": LaunchConfiguration("gait_directory")
                },
                {
                    "balance": LaunchConfiguration("balance")
                },
                {
                    "dynamic_gait": LaunchConfiguration("dynamic_gait")
                },
                {
                    "dynamic_subgait_duration":
                    LaunchConfiguration("dynamic_subgait_duration")
                },
                {
                    "middle_point_fraction":
                    LaunchConfiguration("middle_point_fraction")
                },
                {
                    "middle_point_height":
                    LaunchConfiguration("middle_point_height")
                },
                {
                    "minimum_stair_height":
                    LaunchConfiguration("minimum_stair_height")
                },
                {
                    "push_off_fraction":
                    LaunchConfiguration("push_off_fraction")
                },
                {
                    "push_off_position":
                    LaunchConfiguration("push_off_position")
                },
                {
                    "first_subgait_delay":
                    LaunchConfiguration("first_subgait_delay")
                },
                {
                    "early_schedule_duration":
                    LaunchConfiguration("early_schedule_duration")
                },
                {
                    "timer_period": LaunchConfiguration("timer_period")
                },
            ],
            on_exit=Shutdown(),
        ),
    ])