February 2020
Intermediate to advanced
432 pages
10h 50m
English
Now, it's time to interpret the scan data. This can be accomplished with a simple snippet called scan.py, which is provided with the ROS package:
#! /usr/bin/env pythonimport rospyfrom sensor_msgs.msg import LaserScandef callback(msg): print "\nNumber of points =", len(msg.ranges) print "------------------" print "Range (m) at 0 deg = ", round(msg.ranges[360] , 1) print "Range (m) at 90 deg = ", round(msg.ranges[540] , 1) print "Range (m) at 180 deg = ", round(msg.ranges[719] , 1) print "Range (m) at -90 deg = ", round(msg.ranges[180] , 1), " or 270 deg"rospy.init_node('scan_values')sub = rospy.Subscriber('/scan', LaserScan, callback)rospy.spin()
Type the following command into a Terminal on a ...
Read now
Unlock full access