Syntax for ros service with message type string array in request.

asked 2019-03-09 05:51:51 -0600

BhanuKiran.Chaluvadi gravatar image

Hi, My service message looks like this.

string[] joint_names
bool ok

And advertised joint_service. From terminal I can call the service the with single joint but it appears that my syntax for multiple joints is wrong.

// single joint service call - succeeded
 rosservice call /joint_service  "joint_names:
- 'c1' "

Tried different way to call the service with multiple joints but nothing worked. Whats the correct syntax ?

// Nothing worked - service error
rosservice call /joint_service "joint_names:
- [' c1', 'c2'] "

rosservice call /joint_service "joint_names:
-  '[c1, c2]' "

rosservice call /joint_service "joint_names: {['c1', 'c2'] }"
edit retag flag offensive close merge delete


I would advise you to exploit the tab-completion that rosservice call supports.

Something like this:

rosservice call /joint_service <tab-tab>

where <tab-tab> means: press <key>tab</key> twice. The correct syntax will then be shown to you.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-09 11:54:02 -0600 )edit

Yes, I am using tab completion

rosservice call /joint_service "joint_names:
- ''"

After which, i filled in joint c1 and its working fine. But not sure how to input multiple joints to the joint array.

// working     
rosservice call /joint_service "joint_names:
    - 'c1'"
BhanuKiran.Chaluvadi gravatar image BhanuKiran.Chaluvadi  ( 2019-03-09 14:01:24 -0600 )edit