ros2 launch_test gtest parameters argument
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.
Asked by tyler-picknik on 2020-09-02 09:43:27 UTC
Answers
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' ]
Asked by 404RobotNotFound on 2021-05-20 07:36:20 UTC
Comments