Purpose:
In the previous lab we learned how to 'talk' to the Ultrasonic Ranger and use it to measure distances to reflective surfaces. In this lab we will be developing a better model for the conditions under which the ranger makes good measurements and when it gets confused.
Procedure:
For this lab you need your Qbot and the Arduino IDE and your usual sense of curiousity. We'll assume that you have the IDE up and running and the IDE 'sees' your robot on the port. As usual I am providing you with the basic test code for each step. Your responsibility is to copy, save your own version of the code, and upload that code to the robot. There will also be a guide which walks you through the new tools in the code to help you understand what is happening.
- In the Sonic I lab we focused on just getting the SR04 sonic ranger to work. It is likely that the distance the ranger measured and what you physically measured were pretty similar. You could adjust the measured distance by changing the speed of sound in the sketch if you wanted but only if you feel a need. As is the custom in this class this lab asks you to use what you learned in the previous Sonic I lab and tools you learned in the motor labs and blend it with a new idea to achieve some new performance from your robot. Along the way I hope you notice that you are slowly building a smarter and smarter robot one incremental step at a time.
- First we will combine the sonic ranger with a single conditional statement to make it stop when an object gets too close. Here is a guide for this part of the lab.
- In the previous step you used a conditional test (if - else) to tell the robot how to decide whether to stop the wheels or move forward. What if I want to get more sophisticated? What if I want to slow down before I stop so the whole process is not so abrupt. Here's how I would say it in words:
- When the robot is far from the wall drive forward a some speed. When the robot is twice the safe distance from the wall slow down but keep moving forward. When the robot reaches the safe distance stop.
- Here is a video clip of the intended behavior
- Given that you have a basic sense of how to measure a distance and then 'make a decision' about what your robot should do here are two different and more complex conditional sketches based on the material in this lab. Pick one and describe in words what you see it doing and where you think the conditional decisions are made.
...and
- After you have described the behavior you observe and the decisions the robot is making teach your robot to make at least two additional decisions like those you observed. You could teach it to slow down under some circumstance or turn around and go in a new direction. Be thoughtful, the robot needs a reason to do something different. That's what makes this more challenging.
- Here's a version of my wall following sketch that follows along the edge of a couch until it gets to the corner and then proceeds forwards. Like finding it's way around an obstacle.
LAB DELIVERABLES: (Turn in on Bb)
I) Share your loop() code that makes your robot slow down when it is twice the 'safe distance' from the wall. Your robot still needs to stop that 'safe distance' from the wall.
II) Include your description of what you observe one (1) of the video to be doing. Either the Run Away video or the Wall Following. Be sure that it is clear what you believe is the trigger that causes the robot to change it's behavior.
III) Describe what new conditional behaviors you 'taught' your robot being clear about the trigger for the conditional decision.
IV) Include your loop code that executes the new behaviors you describe in III) above.