Ask Your Question
0

What determines the published message on a topic

asked 2013-07-17 23:59:47 -0500

Asfandyar Ashraf Malik gravatar image

updated 2014-04-20 14:09:36 -0500

ngrennan gravatar image

I made 2 msg file. In one msg file I have 4 variables and in the other I have an array to that message

Files are as follows. This is car.msg

  int32 id
  int32 width
  float64 height
  float64 speed

The second file which is just an array to the cars is as follows. cardata.msg

  car[] mycars

I am opening a master node in one terminal and then I am launching another node in another terminal then through rostopic echo /topic_name I am publishing data.

I want to know what determines the data published. I have succeeded in publishing data which is like this:

id: 21
width: 1
height: 1.05549145701
speed: 0.385172053253

id: 22
width: 1
height: 1.057
speed: 0.394

and it keeps on going recursively for till id =50. id starts from zero till 50.

I want to publish this data only when my id is an even number so in this case the id=21 will not be published. How can I do that. Which files determine what is being published. msg file generated .h files and other files. I have tried to change the .h files (car.h and cardata.h in my case) to change the output but it does not work. The same message is published. Can you tell me how can I change this?

edit retag flag offensive close merge delete

Comments

@DirkThomas if you can help me with this. I have tried my best to figure this pety problem but could not.

Asfandyar Ashraf Malik gravatar imageAsfandyar Ashraf Malik ( 2013-07-18 00:04:31 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-07-18 01:26:58 -0500

dornhege gravatar image

Your code determines this. So you need to look in your code and only publish, when you want to. This is not a ROS issue.

edit flag offensive delete link more

Comments

3

You can also publish data (even one for example) and not take it in account when you receive it (your subscriber must then not take into account any received data with an even id).

Lucile gravatar imageLucile ( 2013-07-18 01:51:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-07-17 23:59:47 -0500

Seen: 163 times

Last updated: Jul 18 '13