rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

add expand_action_name APIs to action client and server

Open alsora opened this issue 1 year ago • 0 comments

I noticed that ROS 2 action clients and servers don't have an API equivalent to get_topic_name or get_service_name that you can find in publishers, subscriptions, etc.

I often needed this API in my applications and I always end up with some ugly thing that would be better handled by the client library. So I went to try to implement it... but I quickly discovered that the logic that we normally use for topics and services is not directly applicable to actions. rcl actions don't store such name, moreover it looks like actions ignore remapping rules?

Looking at the RCL code I see that we don't have a remapping type for actions (only for namespaces, nodes, topics and services). I guess that users could try to remap the underlying topics and services individually, but that seems the most error prone and ugly thing to do.

I tried to solve this issue at the rclcpp level, by providing an API that at least expands the namespace. The API is named differently from its topics and services counterpart and has a different return type, to denote that it works differently. It's not just a lookup, it's doing string manipulations with a non-negligible performance impact.

Let me know what you think

alsora avatar Aug 11 '24 17:08 alsora