rclcpp equivalent of 'ros2 run'
Is there a ros2 C++ API(rclcpp) equivalent of 'ros2 run
Asked by thejeeb on 2023-03-31 00:46:56 UTC
Answers
As far as I now, in order to manage which nodes to run, when, and with which parameters, you create a my_project_bringup package that mainly contains a launch file.
Then all of your project can be started with ros2 launch my_project_bringup my_launcher.launch.py
https://docs.ros.org/en/foxy/Tutorials/Intermediate/Launch/Creating-Launch-Files.html
Is there a reason why this wouldn't suit you ?
Asked by Nopas on 2023-03-31 04:14:29 UTC
Comments
Yes, this would not suit me because the list of nodes that the project starts is not static. It may vary from run to run. It is based on the configuration of the system and it could change. I want to be able to start the nodes programmatically based on a configuration file.
Asked by thejeeb on 2023-03-31 09:29:30 UTC
Your launcher could construct a LaunchDescription object adapted to the configuration.
Asked by Nopas on 2023-03-31 10:39:35 UTC
It is not easy to do that. LaunchDescription objects are good for static configuration and simple use-cases. There are also other reasons to launch the nodes from C++ code. So my original question remains.
Asked by thejeeb on 2023-03-31 10:52:54 UTC
That's not true, you can have dynamically changing different numbers of nodes or options. We do this quite frequently in Nav2.
Asked by stevemacenski on 2023-03-31 10:58:26 UTC
That's good to know. Can you provide a link to some examples of this? I still would like to know if this can be done with rclcpp.
Asked by thejeeb on 2023-03-31 11:05:10 UTC
Examples for using LaunchDescription at startup with a dynamic set of nodes would be useful.
We also launch nodes during run-time based on user interaction. This is why a method to launch nodes using the C++ API would be preferable.
Asked by thejeeb on 2023-04-12 07:38:41 UTC
Comments