You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry that the end of today's class was rushed. I've documented below your assignment for Thursday's class:
Modify the laser_scan_subscriber.py code (which we wrote together in class, and I've pasted below) to convert the list of LaserScan distances to a list of (x,y) coordinates. For now, we'll use a coordinate system where the origin (0,0) is the location of the scanner, +x is to the right, and +y is forward. (We might change this later).
We will use the output from your function to determine if it is safe for our Husky to move in a particular direction.
#!/usr/bin/env python3
import rospy
from sensor_msgs.msg import LaserScan
# The message **type** is sensor_msgs/LaserScan
# See output from `rostopic info /front/scan`
# from geometry_msgs.msg import Twist
import time
class LaserScanReader():
def __init__(self):
rospy.init_node("laser_scan_reader")
# rospy.Subscriber("<topic name>", <topic type>, <callback>)
rospy.Subscriber("/front/scan", LaserScan, self.callback_front_scan)
# self.cmd_vel_pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
# self.rate = rospy.Rate(1/5) # [Hz]
# self.run()
rospy.spin()
# time.sleep(3)
print('hi, I love this class')
def callback_front_scan(self, msg):
print(msg.angle_min, msg.ranges[0])
'''
def run(self):
# THIS IS BAD FORM!
while True:
self.rate.sleep()
'''
if __name__ == "__main__":
LaserScanReader()
The text was updated successfully, but these errors were encountered:
The IE_tools.py script contains the logic we discussed in class today; the laser_scan_subscriber.py script is an updated version of what we wrote together on Tuesday. It calls the code in the IE_tools.py script.
NOTE: I think I have fixed the issues I had warned you about in class today. So, rather than worrying about fixing the code, please study what it does. Of course, if you find an error please do let me know.
Sorry that the end of today's class was rushed. I've documented below your assignment for Thursday's class:
Modify the
laser_scan_subscriber.py
code (which we wrote together in class, and I've pasted below) to convert the list of LaserScan distances to a list of(x,y)
coordinates. For now, we'll use a coordinate system where the origin(0,0)
is the location of the scanner,+x
is to the right, and+y
is forward. (We might change this later).We will use the output from your function to determine if it is safe for our Husky to move in a particular direction.
The text was updated successfully, but these errors were encountered: