Hi,
“library call”: I mean, a function that can be imported and called without any network call.
It hink, that services are very similar to library function calls. Also services seem to me overkill for such tasks like “generating Fibonacchi number” or “AddTwoInts” like in the documentation: Writing a simple service and client (Python) — ROS 2 Documentation: Foxy documentation.
Do you know some rule-of-thumbs to decide which one to use for a task?
I definitely not use ROS2 Service for a purely computational task. SO my “rule of thumb” can be:
If a function is fast and does not use live robotic information, I may create a librabry function.
If a function is fast but uses some sensory information which is hidden from the caller (or the caller is unaware of it), I definitely use ROS2 Service.
But there is a caveate here:
Lets say, that our service uses LaserScan data (It is frequently changing and big). But we are calling this service rarely.
In this case I see only three possibility:
if I write this service to store the latest LaserScan data but it uses this latest data only when the service is called, the storing consume resources unnecessarily most of the time.
If I write this service that it only starts to listen to LaserScan data only when the service is called, it probably will be slow.
If I call this service with the LaserScan data as a parameter, it will be fast, but now it is overkill, because a library function would be much faster and lightweight.
Based on these, I never choose ROS2 Service, I rather write simple functions and call them.
What do you think?
Thank you in advance
Péter