Hi I am trying to subscribe to a laser scan of the hokuyo_node. I am a bit new to ROS, here is my code so far. I have read the python subscriber tutorials but they don't tell how to subscribe to topics that transmits a struts or collections of data.
#!/usr/bin/env python
import roslib; roslib.load_manifest('laser')
import rospy
import hokuyo_node
import sensor_msgs
def callback(data):
pass
def laser_listener():
pass
rospy.init_node('laser_listener', anonymous=True)
rospy.Subscriber("/sensor_msgs/LaserScan",sensor_msgs.msg.LaserScan,callback,20)
rospy.spin()
if __name__ == '__main__':
laser_listener()
I get the following error
Traceback (most recent call last):
File "/home/spartan3123/fuerte_workspace/laser/scripts/main2.py", line 19, in <module>
laser_listener()
File "/home/spartan3123/fuerte_workspace/laser/scripts/main2.py", line 15, in laser_listener
rospy.Subscriber("/sensor_msgs/LaserScan",sensor_msgs.msg.LaserScan,callback,20)
AttributeError: 'module' object has no attribute 'msg'
links
here is a link to the rospy Subscriber API
http://ros.org/doc/fuerte/api/rospy/html/rospy.topics.Subscriber-class.html
and a link to the topic definition of a Laser_Scan for the hokuyo_node
http://www.ros.org/doc/api/sensor_msgs/html/msg/LaserScan.html
btw does anyone have any sample code in python where you connect to a hokuyo_laser it would be helpful
thanks
Originally posted by Sentinal_Bias on ROS Answers with karma: 418 on 2013-03-11
Post score: 1