Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment for Feb 8 + laser_scan_subscriber.py #9

Open
cmurray3 opened this issue Feb 6, 2024 · 1 comment
Open

Assignment for Feb 8 + laser_scan_subscriber.py #9

cmurray3 opened this issue Feb 6, 2024 · 1 comment

Comments

@cmurray3
Copy link
Contributor

cmurray3 commented Feb 6, 2024

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()
@cmurray3
Copy link
Contributor Author

cmurray3 commented Feb 8, 2024

All,
I just pushed some updated code to GitHub:

https://github.com/IE-482-582/spring2024/blob/main/Projects/IE_tools/IE_tools.py
https://github.com/IE-482-582/spring2024/blob/main/Projects/misc_code/laser_scan_subscriber.py

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.

Remember, for Tuesday:

  1. Bring a print-out of your Linux cheat-sheet
  2. Read/Study Chapers 2, 3, and 4
  3. Read/Study the code mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant