ROS Executor
Didn’t even know this was a thing, but yea, how does code get executed? Who executes the code?
Resources
The 3 types of executors:
SingleThreadedExecutor
MultiThreadedExecutor
(fastest)StaticSingleThreadedExecutor
When you do rclcpp::spin(node)
, this runs the executor!
The general syntax (from this tutorial), where they use a SharedPtr
(I see this in MIT-PITT-RW codebase, as well as pure pursuit code)
Second syntax I’ve seen (from this tutorial), where they call make_shared
Both expect a Shared Pointer of some sort, so we should look more into the detail on what is happening.
Is each executor its own process?
In ROS2, executors are not separate processes. They are part of the
main
application process, so if you define multiple executors in this function, they will still be part of the same process.
rclcpp::spin
vs. executor.spin()
The call to spin(node)
basically expands to an instantiation and invocation of the Single-Threaded Executor, which is the simplest Executor:
- So you can add multiple nodes to the same executor!
Ahh, and you can have a multithreaded executor! I saw this in MIT-PITT-RW code:
For my own code, I didn’t use executors before (ex: rrt code), but under the hood it’s just an executor
- So the
rclcpp::spin
is basically just an expansion of theSingleThreadedExecutor
How do executors fit into the picture of ROS architecture? Is it like RMW stuff? Same as create_subscription
and create_publisher
I guess.