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

How to read a value from a ros message?

asked 2014-04-29 23:22:57 -0500

Mobile_robot gravatar image

Dear friends,

I am new in ROS, I am usinig CMVISION package, and the tos topic which I need is " /blobs ", with type "cmvision/blobs"

$ rosmsg show cmvision/Blob

uint32 red uint32 green uint32 blue uint32 area uint32 x uint32 y uint32 left uint32 right uint32 top uint32 bottom

I want to just read the "x", and "y" from this message,

As far as I know the "/" can help me, but I tried "rostopic echo /blobs/x" and it did not work....

Any body knows how I could do this?


edit retag flag offensive close merge delete


Do you want to read the value in terminal or use it in your code?

Jacco van der Spek gravatar image Jacco van der Spek  ( 2014-04-29 23:51:57 -0500 )edit

I want to use that in another code to be the input,

Mobile_robot gravatar image Mobile_robot  ( 2014-04-30 00:08:09 -0500 )edit

May you please say your solution for use in terminal , also?

abtin gravatar image abtin  ( 2020-05-17 15:34:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-04-30 00:52:02 -0500

Jacco van der Spek gravatar image

The message that is being send over the topic is of type Blob.

You need to receive the message type Blob by subscribing to the topic. Then in your code you can write something like

int x = blob_message.x;
int y = blob_message.y;

So in summary you need to receive the complete message.

edit flag offensive delete link more


Thanks a lot

Mobile_robot gravatar image Mobile_robot  ( 2014-04-30 02:02:05 -0500 )edit

Question Tools



Asked: 2014-04-29 23:22:57 -0500

Seen: 2,898 times

Last updated: Apr 30 '14