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

How to pass message into rosservice using args

asked 2019-12-14 04:30:44 -0600

artemiialessandrini gravatar image

updated 2019-12-16 21:03:17 -0600

Please refer to the package ethzasl_icp_mapper's node matcher_service

Matcher Service node offers a Service match_clouds, which is by description:

<...> takes two sensor_msgs/PointCloud2 messages as inputs (the first is the reference and the second the reading) and provides a geometry_msgs/Transform message as output.

Thus, the service structure is the following:

sensor_msgs/PointCloud2 reference
sensor_msgs/PointCloud2 readings
geometry_msgs/Transform transform

And required arguments are reference and readings

I have two topics with the same msgs type, but cannot understand how to provide them properly?

Double_tabbing gives a skeleton, but I'd be happy to make them taken from topics aready existing, than typing myself.

Service arguments are: [reference.header.seq reference.header.stamp reference.header.frame_id reference.height reference.width reference.fields reference.is_bigendian reference.point_step reference.row_step reference.is_dense readings.header.seq readings.header.stamp readings.header.frame_id readings.height readings.width readings.fields readings.is_bigendian readings.point_step readings.row_step readings.is_dense]


Thanks @fexner for your answer, your logic is completely right, I think it can be accepted.

After digging up, I realized, that's what ROS Client stands for. I completely forget about it.

That means, parsing arguments from the command line is only a little part of ServiceClient tool. Unfortunately, tutorials only consist of sums of 1+3, without more advanced implementations.

[EDIT 2]

Got lucky to find lots of practical examples, hopefully gets helpful for those, who tries to implement something more than prime numbers addition:)

edit retag flag offensive close merge delete


For reference matcher_service node

artemiialessandrini gravatar image artemiialessandrini  ( 2019-12-14 04:32:46 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-12-14 07:52:53 -0600

fexner gravatar image

Filling sensor_msgs/PointCloud2 fields from the command lines is probably not recommended, as they usually contain quite a lot of data.

To fill this service's request using data from topics, you probably would have to write a short wrapper node that subscribes to those topics, saves data in two cache variables and offers a service which will call the matcher_service using the two cache variables.

edit flag offensive delete link more


Question updated for more details

artemiialessandrini gravatar image artemiialessandrini  ( 2019-12-16 05:34:39 -0600 )edit

Question Tools

1 follower


Asked: 2019-12-14 04:30:44 -0600

Seen: 432 times

Last updated: Dec 16 '19