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

How do I numpy-ize a Service node or a Client node to manage Request or Response containing numpy array ?

asked 2011-11-21 05:41:08 -0600

sylou gravatar image

updated 2011-11-22 00:34:06 -0600


I am trying to transmit a numpy array in a response of a service but I have some trouble to convert it in the appropriate type. I saw the numpy_msg tutorials it works fine for messages but I don't get how to make it work for request/response of services.

Thanks to you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-12-05 20:10:16 -0600

tingfan gravatar image

updated 2011-12-05 20:12:29 -0600

The numpy serialization/deserialization stubs has been generated in the corresponding PKG.srv.*; So one can probably override the default serialize() deserialize() in the same manner as numpy_msg does. Take the rospy_tutorial/005_AddTwoInts for an example, You'll probably need to add these new lines:

import rospy.numpy_msg
AddTwoInts._request_class = rospy.numpy_msg.numpy_msg(AddTwoIntsRequest)
AddTwoInts._response_class = rospy.numpy_msg.numpy_msg(AddTwoIntsResponse)
AddTwoIntsRequest = rospy.numpy_msg.numpy_msg(AddTwoIntsRequest)
AddTwoIntsResponse= rospy.numpy_msg.numpy_msg(AddTwoIntsResponse)

I haven't got a chance to test the code myself, but hope this give you some idea.

edit flag offensive delete link more

Question Tools


Asked: 2011-11-21 05:41:08 -0600

Seen: 912 times

Last updated: Dec 05 '11