FTC Move a Distance 20230919

From wikidb
Revision as of 19:59, 19 September 2023 by Edc (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Lab 2: Move a Known 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.

Best Known Method (BKM)

Best Know Method is a term originally crafted in the semiconductor manufacturing industry to refer to a well-documented technic or procedure that is considered the current standard on how to execute a given process. BKM. See also Best Practice

  • Work Together:
  • Incremental Development: Made a small change, built and test your program to make sure it still works. 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.

Check Points

Check Point 1

Download theMotorGoToPosition.java program below and load it to OnBotJava.

  • Press the download button on the right side of the Github page. DownloadButton.png
  • MotorGoToPosition.java You will need to be connected to the web.
  • Press the upload on the OnBotJava page. You will need to be connected to the Controller hub at 192.168.43.1:8080.

Build the MotorGoToPosition Op Mode.

Test it on your Robot.

Check Point 2

Modify the MotorGoToPosition Op Mode so that it backs up to a position half way between where it started and ended.

  • Use Incremental Development
  1. Add a new constant for half the distance. Build and test.
  2. Add a new target after the while loop. Build and test. Build and test. (You'll need to press the stop on the Driver Hub to stop the robot.)
  3. Add the while loop without telemetry. Build and test.
  4. Add the telemetry. Build and test.

Check Point 3

The robot drives 1000 clicks

Check Point 4

Modify the MotorGotoPosition Op Mode to

  1. Go forward like above.
  2. Make a 180 degree turn
  3. Drive back to the stating point

Check Point 5

  1. How close did you return to the same spot?
  2. What modification to the robot or program would make you get closer?

References

RunMode Enumation Constant Detail

  • RUN_WITHOUT_ENCODER
    • public static final DcMotor.RunMode RUN_WITHOUT_ENCODER
    • The motor is simply to run at whatever velocity is achieved by apply a particular power level to the motor.
  • RUN_USING_ENCODER
    • public static final DcMotor.RunMode RUN_USING_ENCODER
    • The motor is to do its best to run at targeted velocity. An encoder must be affixed to the motor in order to use this mode. This is a PID mode.
  • RUN_TO_POSITION
    • public static final DcMotor.RunMode RUN_TO_POSITION
    • The motor is to attempt to rotate in whatever direction is necessary to cause the encoder reading to advance or retreat from its current setting to the setting which has been provided through the setTargetPosition() method. An encoder must be affixed to this motor in order to use this mode. This is a PID mode.
  • STOP_AND_RESET_ENCODER
    • public static final DcMotor.RunMode STOP_AND_RESET_ENCODER
    • The motor is to set the current encoder position to zero. In contrast to RUN_TO_POSITION, the motor is not rotated in order to achieve this; rather, the current rotational position of the motor is simply reinterpreted as the new zero value. However, as a side effect of placing a motor in this mode, power is removed from the motor, causing it to stop, though it is unspecified whether the motor enters brake or float mode. Further, it should be noted that setting a motor toSTOP_AND_RESET_ENCODER may or may not be a transient state: motors connected to some motor controllers will remain in this mode until explicitly transitioned to a different one, while motors connected to other motor controllers will automatically transition to a different mode after the reset of the encoder is complete.

Motor and Encoder Diagrams

  • IncrememtalEncoder.jpg
  • HallEncoder.jpg

Using FTC Motors