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

ROS hokuyo_node LaserScan Subscriber msg data class python

asked 2013-03-11 17:20:22 -0500

Sentinal_Bias gravatar image

updated 2014-01-28 17:15:38 -0500

ngrennan gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-03-11 19:50:57 -0500

fergs gravatar image

You need to use the whole .msg in the import

 import sensor_msgs.msg
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-11 17:20:22 -0500

Seen: 4,710 times

Last updated: Mar 11 '13