ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ros2 launch_test gtest parameters argument

asked 2020-09-02 09:43:27 -0500

I can't figure out how to pass parameters loaded from a yml file into a gtest launched with launch_test. I looked through the code in ros2/launch and couldn't find how to pass in parameters to the node.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-20 07:36:20 -0500

404RobotNotFound gravatar image

updated 2021-05-20 07:36:48 -0500

After looking this up myself, I found that you can pass parameters directly to the gtest file assuming in the main function you call rclcpp::init(&argc, argv). You can pass parameters like you would in ros2 run in the design documentation for parameters.

To load in a yaml file, you will then pass --ros-args --params-file /path/to/params.yaml to the executable.

If you are using the python GTest class in launch_testing.actions.GTest to launch your test, it only accepts a "path" which you could pass in the full command, or just use the Test parent class directly and pass in the cmd input.

You would end up with something like this as your command in python (for an example, I load in two param files):

cmd = test_path + ['--ros-args', '--params-file', '/path/to/params.yaml'] + ['--params-file', 'path/to/second_params_file.yaml' ]
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-09-02 09:43:27 -0500

Seen: 565 times

Last updated: May 20 '21