ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to pass number as a string to a rosservice?

asked 2020-01-07 17:09:58 -0500

billtheplatypus gravatar image

I have a rosservice that takes a string as an argument. That string may be an integer (or rather, the string representation of an integer). However, when I try to call the service with the number, it tries to pass it as a number, which fails. I've tried putting the number in quotes, but that doesn't change anything. I think it has to do with the rosservice command line utility using yaml to parse the command.

Is there any good solution or workaround?

$ rosservice call /config_set gnss 1
ERROR: Unable to send request. One of the fields has an incorrect type:
  field configuration must be of type str

srv file:
string device
string configuration
---
bool successful
bool reboot_required
string message

The srv file, if needed:

# Set a configuration setting

string device # The device whose configuration is being set, either a name or a number
string configuration # The new configuration option for the device, either a name or a number
---
bool successful
bool reboot_required
string message # Either an error message or more specific response. May be from rosflight_io or from the firmware
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-01-07 18:07:47 -0500

See the documentation for rosservice -- specifically the section on "Command-line and Strings". That would suggest something like:

rosservice call /config_set 'gnss' '!!str 1'
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-01-07 17:09:58 -0500

Seen: 949 times

Last updated: Jan 07 '20