Difference between revisions of "FTC Move a Distance 20230919"

From wikidb
Jump to: navigation, search
(Created page with "= 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...")
 
(Check Point 5)
 
(40 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Lab 2: Move a Distance =
+
= Lab 2: Move a Known Distance =
  
 
== Why ==
 
== Why ==
Line 7: Line 7:
 
* An '''encoder''' is an example sensor that can be used to answer that question: [https://en.wikipedia.org/wiki/Rotary_encoder Encoder from Wikipedia].
 
* An '''encoder''' is an example sensor that can be used to answer that question: [https://en.wikipedia.org/wiki/Rotary_encoder 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: [https://en.wikipedia.org/wiki/Dead_reckoning Dead Reckoning from Wiipedia].
 
* '''Dead reckoning''' is figuring out where you are based on where you were and your estimate on how far you moved in some direction: [https://en.wikipedia.org/wiki/Dead_reckoning 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. [https://en.wikichip.org/wiki/bkm BKM]. See also [https://en.wikipedia.org/wiki/Best_practice 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 Points ==
  
Start with the TestMotorEpp.java program and add the follow enhancements.
+
=== Check Point 1 ===
The following program will show you where to make the changes for each check point.
+
* [https://github.com/edcepp/DeLaSalle/blob/main/MotorPositionEpp.java MotorPositionEpp.java]
+
  
<ol>
+
Download theMotorGoToPosition.java program below and load it to OnBotJava.  
  <li> Add telemetry
+
* Press the download button on the right side of the Github page. [[File:DownloadButton.png  | 25px]]
    <pre>
+
* [https://github.com/edcepp/DeLaSalle/blob/main/MotorGotoPosition.java MotorGoToPosition.java] You will need to be connected to the web.
while (opModeIsActive() && myLeftMotor.isBusy())
+
* Press the upload on the OnBotJava page. You will need to be connected to the Controller hub at 192.168.43.1:8080.
{
+
    telemetry.addData("position ", myLeftMotor.getCurrentPosition());
+
    telemetry.update();
+
}
+
    </pre>
+
Test and demonstrate to the instructor
+
  </li>
+
  
<li> Reset the position counter
+
Build the MotorGoToPosition Op Mode.
  <pre>
+
myLeftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
+
  </pre>
+
Test and demonstrate to the instructor
+
</li>
+
+
<li> Turn the motor until the encoder reads the target position. Be sure to set the target position before you set run to position.
+
  <pre>
+
myLeftMotor.setTargetPosition(1000);
+
  </pre>
+
Test and demonstrate to the instructor
+
</li>
+
  
<li> Put the left motor in run to position mode.
+
Test it on your Robot.
  <pre>
+
myLeftMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
+
  </pre>
+
Test and demonstrate to the instructor
+
</li>
+
  
<li> Set target to computed distance<br>
+
=== Check Point 2 ===
  
Demonstrate to the instructor that you can make the robot drive 24 inches.
+
Modify the MotorGoToPosition Op Mode so that it backs up to a position half way between where it started and ended.
</li>
+
* Use Incremental Development
 +
# Add a new constant for half the distance. Build and test.
 +
# 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.)
 +
# Add the while loop without telemetry. Build and test.
 +
# Add the telemetry. Build and test.
  
<li> Update the comments<br>
+
=== Check Point 3 ===
  
Add your names as the programers who have enhanced this program. Describe what you did in a few words.
+
The robot drives 1000 clicks
</li>
+
* Measure that distance
</ol>
+
* Computer that distance using the distance of 1000 clicks and the characteristics of the motor and drive wheels
 +
** [https://www.revrobotics.com/rev-41-1300 Core Hex Motor REV-41-1300]
 +
** [https://www.revrobotics.com/rev-41-1354 DUO Traction Wheels REV-41-1354]
  
= Incremental Development =
+
=== Check Point 4 ===
  
We just demonstrated '''Incremental Development'''. We made a small change, built and tested our program to make sure it still worked.
+
Modify the MotorGotoPosition Op Mode to  
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.
+
# Go forward like above.
Incremental development help to keep us from getting into this trouble.
+
# Make a 180 degree turn
 +
# Drive back to the stating point
 +
 
 +
=== Check Point 5 ===
 +
 
 +
# How close did you return to the same spot?
 +
# What modification to the robot or program would make you get closer?
  
 
= References =
 
= References =
  
 +
== RunMode Enumation Constant Detail ==
 +
 +
* [https://first-tech-challenge.github.io/SkyStone/index.html FTC API reference]
 +
** See DcMotor.RunMode
 +
 +
* 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 =
 +
 +
* [[File: IncrememtalEncoder.jpg ]]
 +
* [[File: HallEncoder.jpg | 500px]]
 +
 +
== Using FTC Motors ==
 
*[https://ftc-tricks.com/dc-motors/ DC Motors]
 
*[https://ftc-tricks.com/dc-motors/ DC Motors]
 
*[https://stemrobotics.cs.pdx.edu/node/4746.html Using Encoders]
 
*[https://stemrobotics.cs.pdx.edu/node/4746.html Using Encoders]

Latest revision as of 19:59, 19 September 2023

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