0
$\begingroup$

Rosanswers logo

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?


Originally posted by Cerin on ROS Answers with karma: 940 on 2016-03-13

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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

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


Originally posted by Arowana with karma: 381 on 2016-03-13

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Cerin on 2016-03-13:
I tried that hash notation, but that gives me the error, "expected [id, data]. I guess it assumes a list notation for custom services?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.