0
$\begingroup$

Rosanswers logo

Hi, I wander known how I can subscribe a known laserscan


Originally posted by flightgong on ROS Answers with karma: 3 on 2014-04-06

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi

I am assuming you have done all the beginner tutorials, because they explain subscribers, topics and publishers really well see here http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29

If you want to know the name of the laser scan topic run the laser_node or the node that publishes the laser scan use rostopic list to figure out the name of the topic. eg "chatter" in the beginner tutorials

In order to write your subscriber you need to import the msg http://docs.ros.org/api/sensor_msgs/html/msg/LaserScan.html eg

from sensor_msgs.msg import LaserScan

Once your callback function is triggered you will get back a struct that is defined by the .msg file

you can also use the rosmsg XXX command to figure out the types of msgs packages publish from the terminal and their format.


Originally posted by Sentinal_Bias with karma: 418 on 2014-04-06

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by flightgong on 2014-04-06:
Hi, I have found the laser_node, and its published laser topic, for example named base_scan. When I try to use this data in my subscriber, it returns that this global name doesn't exist. I don't know how to deal with it. Thx

Comment by Sentinal_Bias on 2014-04-08:
do you mean the data in your subscriber function? It should be a struct as defined by the msg file

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.