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

How to publish whole message to a topic? [closed]

asked 2014-12-06 13:35:05 -0500

Aarif gravatar image

hello, how can i publish a whole message to a topic?, for example i have Laser Data being published on /lms200 topic, i have made a subscriber node which subscribes to the /lms200 topic which gives me the message in the following format:-

header: 
seq: 296
stamp: 
secs: 1417864716
nsecs: 451817364
frame_id: lms200
angle_min: -1.5707000494
angle_max: 1.5707000494
angle_increment: 0.0174000002444
time_increment: 0.0
scan_time: 0.0
range_min: 0.10000000149
range_max: 20.0
ranges: [9.380000114440918, 9.380000114440918, 9.380000114440918, 9.390000343322754, 9.390000343322754, 9.399999618530273, 9.420000076293945, 9.430000305175781, 9.449999809265137, 9.470000267028809, 9.5, 9.529999732971191, 9.5600004196167, 9.59000015258789, 9.630000114440918, 9.670000076293945, 1.7699999809265137, 1.7699999809265137]
intensities: []

now i want to group all these variables in a message (LaserScan.msg) and publish it on the /Scan topic.

I have gone through the Writing a Simple Publisher and Subscriber (C++)/Tutorial but there they have published the value only one variable, but i want to publish whole message, how can i do it??

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Aarif
close date 2014-12-21 10:48:07.177544

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-12-06 14:49:59 -0500

bvbdort gravatar image

updated 2014-12-07 14:19:36 -0500

If you want same messages on available other topic name

You just have to remap your topic from "lms200" to "Scan"

just addd below line in your launchfile.

<remap from="lms200" to="Scan"/>

In case you want to modify the message and re publish again, your node should subcribe to /lms200 and then modify in call back and publish modified message.

edit flag offensive delete link more

Comments

hi @bvbdort, thanks for helping, this remap solution is not worth-full for me, i want to make a node which can subscribes a /lms200 topic and publish whole message to /scan topic, I've made a node with your help which can subscribe to /lms200, now i want to publish that whole message to /scan topic.

Aarif gravatar image Aarif  ( 2014-12-07 05:03:53 -0500 )edit

do you want to modify any values in message ? if not remap is enough.

bvbdort gravatar image bvbdort  ( 2014-12-07 07:01:43 -0500 )edit

hi @bvbdort, yes you are right, i want to make some changes in the message. :)

Aarif gravatar image Aarif  ( 2014-12-07 11:24:38 -0500 )edit

i jsut add some text to answer, if you are looking for code, you need a class to do it properly. Just go through this package https://github.com/uscrs-art/beohawk-... , let me know if any questions.

bvbdort gravatar image bvbdort  ( 2014-12-07 14:42:35 -0500 )edit

hi @bvbdort, Thanks for giving the link, i was also expecting exactly what they have mentioned there but i was not sure but now i am sure thanks for your link. :)

Aarif gravatar image Aarif  ( 2014-12-08 10:41:47 -0500 )edit
0

answered 2014-12-07 09:34:22 -0500

l0g1x gravatar image

I think what @bvbdort is trying to say is all you need to do is tell the lms200 node to publish on the "Scan" topic, instead of publishing on the "lms200" topic. Im a bit confused as to what you are trying to do, since the message you pasted in your question is already in the form of sensor_msgs::LaserScan. If you type rostopic info /lms200 after your lms200 node is running, it will tell you the message type that topic is sending. Are you trying to right a custom driver of some sort?

Not sure why you would have /lms200 as the name of your topic in the first place, if you look here at the lms200 rosnode driver, it is already publishing on the /scan topic, sending messages in the LaserScan message format as you showed above.

edit flag offensive delete link more

Comments

hi @l0g1x, i have Laser in the simulator environment and that simulator publishes the data on the /lms200 topic instead of /scan, i want laser data to be published on both /lms200 and /scan topic. for this I've made a no which subscribes to /lms200 but i am unable to publish to /scan topic.

Aarif gravatar image Aarif  ( 2014-12-07 11:25:33 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-12-06 13:35:05 -0500

Seen: 799 times

Last updated: Dec 07 '14