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

How to call a service with a char argument

asked 2016-03-13 17:54:28 -0500

Cerin gravatar image

How do you pass a char to rosservice call?

I have a srv file like:

uint8 id
string data
---

exposed as /myservice which I'd like to call like rosservice call /myservice m '!!str mydata' but this gives me a Python traceback to the autogenerated code for my srv class:

UnboundLocalError: local variable '_x' referenced before assignment

presumably because it doesn't convert "m" to the uint8 value 109. The docs declare char is deprecated because it's essentially the same thing as uint8.

Is there a way to explicitly declare this type, or do I have to pass in a literal int value?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-03-13 19:59:46 -0500

Arowana gravatar image

I am not familiar with the way you call the service. I usually do it this way

rosservice call /myservice '{id: A, data: ok}'

edit flag offensive delete link more

Comments

I tried that hash notation, but that gives me the error, "expected [id, data]. I guess it assumes a list notation for custom services?

Cerin gravatar image Cerin  ( 2016-03-13 23:30:04 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-13 17:54:28 -0500

Seen: 593 times

Last updated: Mar 13 '16