Chapter 4 proper launch file format for services_quiz_client.launch.py

Hi,

starting the services_quiz_client with

ros2 run services_quiz services_quiz_client "Turn Right" "0.2" "10"

does work but none of those tries to hand over parameters does work

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='services_quiz',
            executable='services_quiz_client',
            parameters=[
                {"direction:": "Turn Right"},
                {"angular_velocity:": 0.2},
                {"time:": 10}],
            output='screen'),
    ])

or

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='services_quiz',
            executable='services_quiz_client',
            output='screen'),
        DeclareLaunchArgument(
            direction='Turn Right', 
            angular_velocity='0.2',
            time='10'),
    ])

how to properly format the launch file ?

Hello @vkuehn ,

This is because these values are not really node parameters, so they cannot be passed like that. If you are using the same example explained in the course, capturing with sys.argv[1], then you have to pass them with the command line. In any case, for this Quiz, you don’t have to worry about all this. You should set the values directly in the code.

If you want to learn about how to work with parameters / arguments, you can have a look at the Intermediate ROS2 course, where all this is explained more in detail: Intermediate ROS2 - Robotics & ROS Online Courses | The Construct

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.