FTC Move a Distance 20230919
From wikidb
Lab 2: Move a Distance
Why
- Where am I? is a key question a robot must know to get some things done.
- Odometry is the use of sensor data to estimate a robot's position: Odometry from Wikipedia.
- An encoder is an example sensor that can be used to answer that question: Encoder from Wikipedia.
- Dead reckoning is figuring out where you are based on where you were and your estimate on how far you moved in some direction: Dead Reckoning from Wiipedia.
Check Points
Start with the TestMotorEpp.java program and add the follow enhancements. The following program will show you where to make the changes for each check point.
- Add telemetry
while (opModeIsActive() && myLeftMotor.isBusy()) { telemetry.addData("position ", myLeftMotor.getCurrentPosition()); telemetry.update(); }
Test and demonstrate to the instructor
- Reset the position counter
myLeftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
Test and demonstrate to the instructor
- Turn the motor until the encoder reads the target position. Be sure to set the target position before you set run to position.
myLeftMotor.setTargetPosition(1000);
Test and demonstrate to the instructor
- Put the left motor in run to position mode.
myLeftMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
Test and demonstrate to the instructor
- Set target to computed distance
Demonstrate to the instructor that you can make the robot drive 24 inches. - Update the comments
Add your names as the programers who have enhanced this program. Describe what you did in a few words.
Incremental Development
We just demonstrated Incremental Development. We made a small change, built and tested our program to make sure it still worked. There are many ways of getting into trouble when writing a program. One is to start with a working program, make a lot of changes and end up with a non-working program with no idea what you did to break it. Incremental development help to keep us from getting into this trouble.