As announced in the Robotics Lab 1, your homework for this week will be to implement the race program. To do so there are a number of tasks that you should do.
Task 0
The robotics lab is a group work. As such only one person needs to submit the files required below into gradebot. We need to know where to look for the file. So EVERYBODY needs to create a file called 'info.txt' in the root folder of the 'Robotics Lab Code' repo on gradebot. The file should have the following format:
So after 'main: ' the gradebot user name storing the groups files should be listed. After 'members:' all members of your group (including you) should be listed.
Task 1
If you have not yet done so, finish Task 10 from the Robotics Lab 1. Be sure to test this a couple of times with your Arduino, such that you don't waste time debugging this during the second and third lab.
Task 2
If you have not yet done so, finish Task 11 from the Robotics Lab 1.
Task 3
In 'race_ir.py' implement a function to decode the two signal values from the Int32. Take a look at the Arduino program to learn how they are encoded. Publish the two sensor values on two different topics. See the Publisher and Subscriber Tutorial about how to implement a publisher in ROS.
For this and the following tasks you can use the ros bagfile provided here. Download 'static.bag', 'straight.bag' and 'follow_line.bag' to your computer. You can replay the bagfile using this command:
rosbag play -l static.bag
The '-l' will loop the replay. Use 'rosbag info static.bag' to get some information about the bag file. Replaying the bagfile will publish the 'ir_data' messages, such that you can test your program. This is also very useful for the following tasks.
Task 4
In 'race_ir.py' implement a function to determine the position of the line with respect to the robot. Publish this position as a message in ROS.
Task 5
Use rqt_plot to display the values from Task 3 and Task 4 using one of the provided bagfiles. Create a screenshot with the window of rqt_plot and the console (partially) visible. Save it under the name 'rqt_plot.png' in the 'Robotics Lab Code' repo (only the 'main' person needs to do this).
Task 6
In 'race_ir.py' implement a function to determine the control output send to the robot, based on the position of the line calculated in Task 4. Be sure to check in the latest version of the race program.
Bonus Task 7
This bonus task is optional. If you succeed in the robotics lab 3 you will get 20% extra points for the robotics lab section.
Your task is to create an image similar to this using the rotating sensor and the robot. The approach is to have the robot drive forward slowly, record the data from the sensor and put the values in a grayscale image. Copy your 'race_ir.py' to 'image_ir.py'. Use the decoded sensor values to fill in an image. You can use the Pyton Image Library to create the image. Here are some commands that you might want to use (with different numbers of course):
im = Image.new('L',(500,500),(255)) # the first two numbers are the size, the third (255) is the number of gray scale values (don't change this number)
im.putpixel((column,row),(ir_value)) # set a pixel
im.save('gray.jpg') # save the image
There are different ways of how you could do this - you are free to explore.
You can get the bonus points if you do both:
A) Commit the working, final program and the image 'gray.jpg' to the repo and
B) show me a demo of the working program in lab 2 or lab 3.