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

ros2 commandline service call

asked 2018-08-31 18:41:31 -0500

alsora gravatar image

updated 2018-08-31 18:43:51 -0500

What's the correct syntax for performing a service call from the command line in ROS2 ?

Consider the following service, defined in example_interfaces package

AddTwoInts.srv

int a
int b
---
int c

Assuming that the server is called "add_two_ints"

I managed to pass one argument to the service call in the following way

$ ros2 service call /add_two_ints example_interfaces/AddTwoInts "a: '1'"        
requester: making request: example_interfaces.srv.AddTwoInts_Request(a=1, b=0)

How to pass also the second argument ?

These are not working

$ ros2 service call /add_two_ints example_interfaces/AddTwoInts "a: '1'b:'2'"
$ ros2 service call /add_two_ints example_interfaces/AddTwoInts "a: '1' b:'2'"
$ ros2 service call /add_two_ints example_interfaces/AddTwoInts "a: '1', b:'2'"
$ ros2 service call /add_two_ints example_interfaces/AddTwoInts "a:'1'" "b:'2'"
$ ros2 service call /add_two_ints example_interfaces/AddTwoInts "a:'1'", "b:'2'"
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-08-31 19:10:47 -0500

Dirk Thomas gravatar image

You need to pass a string which is valid YAML, e.g.:

ros2 service call /add_two_ints example_interfaces/AddTwoInts "{a: 1, b: 2}"

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-08-31 18:41:31 -0500

Seen: 5,457 times

Last updated: Aug 31 '18