pythonrosrospy

How to define optional arguments in ROS service request


I want to define optional arguments in my ROS service request, the .srv file looks like this:

abb_rapid_msgs/RobTarget pickpoint
abb_rapid_msgs/RobTarget placepoint
bool leftarm
# Optional Parameters
abb_rapid_msgs/RobTarget pickappoint
abb_rapid_msgs/RobTarget placeappoint
float32 speed
---
bool success

and I want to check whether one or more of these optional arguments are passed in order to call the correspondent ServiceProxy.

Can you please tell me how can I do that? thanks in advance.


Solution

  • Unfortunately there is no support for optional fields in either service or message files; it has been proposed a couple of times, though.

    Instead, you can add another field to your srv to work as a bitvector. The new field can be used to designate which other "optional" fields are set and use their values accordingly.