FTC Move a Distance 20221007

From wikidb
Jump to: navigation, search

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.

  1. Add telemetry
    while (opModeIsActive() && myLeftMotor.isBusy())
    {
        telemetry.addData("position ", myLeftMotor.getCurrentPosition());
        telemetry.update();
    }
        

    Test and demonstrate to the instructor

  2. Reset the position counter
    myLeftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
      

    Test and demonstrate to the instructor

  3. 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

  4. Put the left motor in run to position mode.
    myLeftMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
      

    Test and demonstrate to the instructor

  5. Set target to computed distance
    Demonstrate to the instructor that you can make the robot drive 24 inches.
  6. 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.

References