The Perfect Endless Square

 

It’s time to put all the control structures you’ve learned about to good use.  One difficult aspect of making robots drive straight or turn is that the two motors often don’t have the same torque and rotational speed at a given current and voltage. To compensate for this problem sensors can be used to continuously measure how many times each motor has turned. If at one instant in time one sensor registers more rotations on one motor than another, the speed of the motors is adjusted to compensate.

 

For this problem you will be perfecting 90 degree point turns. A point turn means that the wheels MUST turn in opposite directions, they MUST travel the same distance, and travel that distance at approximately the same speed.

 

Hints for point turns:

  1. Make the wheels turn in opposite directions.
  2. Then use a loop with if statements to check when one wheel has rotated more than the other.
  3. Adjust the motor’s speed accordingly (Does turning the motors on and off instead of changing the power lever work also?)

 

Make your robot drive in an endless square. The edges should be ~2 feet in length and the turning direction is up to you. How you time the length of the edges of the square is up to you. You do not have to worry about perfecting driving in a straight line or using multiple procedures, that will be coming in the next P Set.

 

Demo: Get a TA to verify that your turns sharp 90 degree turns. Make sure your team gets checked off.

 

Turn in: Each team member needs to turn in: a hardcopy of the team’s code as a “Listing.” What are the Preconditions, Postconditions, Inputs, and Outputs? This time it is not okay to put None.