Difference between revisions of "FTC Motor Encoders 20200304"

From wikidb
Jump to: navigation, search
(Created page with "= Motor Drive Characteristics = * [https://www.revrobotics.com/rev-45-1171/ MiniBot Hardware Kit REV-45-1171] * [https://www.revrobotics.com/rev-41-1300/ Core Hex Motor REV-...")
 
(Robot HW Architecture)
 
(42 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Motor Drive Characteristics =
+
= Motor Encoder Demo =
 +
 
 +
== 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: [https://en.wikipedia.org/wiki/Odometry Odometry 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].
 +
 
 +
== Demo Code ==
 +
 
 +
* [https://github.com/edcepp/FTCJavaLabs/blob/main/DriveForwardWithEncoderEpp.java DriveForwardWithEncoderEpp.java]
 +
 
 +
== Exercise ==
 +
 
 +
* Exercise 1: Load the DriverForwardWithEncoderEpp Op Mode into Android Studio and execute it..
 +
 
 +
= Motor Encoders =
 +
 
 +
== REV Motor Drive Characteristics ==
  
 
* [https://www.revrobotics.com/rev-45-1171/ MiniBot Hardware Kit REV-45-1171]  
 
* [https://www.revrobotics.com/rev-45-1171/ MiniBot Hardware Kit REV-45-1171]  
Line 5: Line 24:
 
** Free Speed 125 RPM
 
** Free Speed 125 RPM
 
** Gear Ratio: 72:1
 
** Gear Ratio: 72:1
** Encoder Counts per Revolution at the motor: 4 counts/revolution
+
** Encoder Counts per Revolution at the motor: 4 counts/revolution REV-41-1336]
** At the output: ???
+
** Encoder Counts per Revolution at the output (wheels): _________
 +
* Gears - not relevant
 +
** [https://www.revrobotics.com/rev-41-1336/ 72 Tooth Plastic Gear REV-41-1336]
 +
** [https://www.revrobotics.com/rev-41-1337/ 90 Tooth Plastic Gear REV-41-1337]
 +
** Encoder Counts per Revolution at the wheels:  _________
 +
* Wheels
 +
** [https://www.revrobotics.com/rev-41-1354/ 90mm Traction Wheel REV-41-1354]
 +
** Counts per mm:  _________
 +
 
 +
== Exercise ==
 +
 
 +
* Exercise 2: Verify the Counts per mm above with a physical test.
 +
 
 +
== Encoder Diagram ==
 +
 
 +
[[File: HallEncoder.jpg | 500px]]
 +
 
 +
= FTC Motor Object Structure =
 +
 
 +
== References ==
 +
 
 +
* [https://first-tech-challenge.github.io/SkyStone/index.html FTC API reference]
 +
 
 +
== Motor Class Specs ==
 +
 
 +
* DcMotorSimple extends HardwareDevice
 +
** getPower -- 64 bit double
 +
** setPower -- 64 bit double
 +
** ...
 +
 
 +
DcMotor extends DcMotorSimple
 +
** getMode
 +
** getPowerFloat -- 32 bit float
 +
** getTargetPosiition -- encoder value
 +
** isBusy
 +
** setMode
 +
** setPowerFloat -- 32 bit float
 +
** setTargetPosition -- encoder value
 +
** ...
 +
 
 +
* DcMotorEx extends DcMotor
 +
** getCurrent
 +
** getPIDCoefficients
 +
** getTargetPositionTolerance
 +
** getVelocity -- ticks per second and angle unitis
 +
** isOverCurrent
 +
** setPIDCoefficients
 +
** setVelocity -- ticks per second and angle units
 +
* ...
 +
 
 +
== Exercise ==
 +
 
 +
* Exercise 3: Change the DriveForwardWithEncoder to use Velocity control for both wheels instead of Power control. How does the robots move characteristics change? eg
 +
** Did the robot drive in a straighter line using the setVelocity than the setPower example?
 +
** Did the robot start out moving straight at the very beginning?
 +
** Did the robot stop gradually or abruptly when its target distance was reached?
 +
** How would you improve the robot's performance?
 +
 
 +
=== Spoiler Alert ===
 +
 
 +
* [[DriveForwardWithEncoderEppGio.java]] - The team's colaborative solution
 +
** Key changes
 +
*** import DcMotorEx
 +
*** leftMotor and rightMotor change to type DcMotorEx
 +
*** type  cast for the hardwareMap.dcMotor.get
 +
*** change setPower to setVelocity
 +
*** remove setting rightMotor to RUN_WITHOUT_ENCODER run mode
 +
 
 +
* [[DriveForwardWithEncoderSpeed.java]] - Ed's solution
 +
** Key changes - same as above pluss
 +
*** Use this hardwareMap statement
 +
        rightMotor = hardwareMap.get(DcMotorEx.class,"myRightMotor");
 +
 
 +
=== DcMotor and DcMotorEx differences ===
 +
 
 +
* DcMotor is designed for Modern Robotics / HiTechnic motor controllers
 +
* DcMotor is designed for the Control Hub and Expansion Hub
 +
* Reference: [https://ftcforum.firstinspires.org/forum/ftc-technology/android-studio/84083-dcmotor-vs-dcmotorex DcMotor vs. DcMotorEx]
 +
 
 +
= References =
 +
 
 +
* [https://docs.revrobotics.com/rev-control-system/sensors/encoders REV Encoders]
 +
* [https://docs.revrobotics.com/rev-control-system/programming/using-encoder-feedback REV Using Encoders - Motor Modes]
 +
* [https://docs.revrobotics.com/rev-control-system/programming/hello-robot-autonomous-robot/robot-nav-onbot-java/autonomous-navigation-onbot Encoder Navigation - OnBot
 +
** For Java code see: "Setting Velocity" subsection in the program "HelloWorld_EncoderAuton".
 +
** In is also described in a subsection "Turning the Divetrain Using RUN_TO_POSITION"
 +
** There is also an earlier sections called "Moving to a Target Distance."
 +
 
 +
 
 +
== Robot HW Architecture ==
 +
 
 +
* [https://en.wikipedia.org/wiki/PID_controller Proportional Integral Derivative from Wikipedia] If you don't want to dig into the mathematics, look at the PID methods in the DcMotorEx class (getPIDCoefficients and setPIDCoefficients).
 +
 
 +
== Optical Encoders ==
 +
* [[File: IncrememtalEncoder.jpg ]]

Latest revision as of 17:00, 14 April 2022

Motor Encoder Demo

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.

Demo Code

Exercise

  • Exercise 1: Load the DriverForwardWithEncoderEpp Op Mode into Android Studio and execute it..

Motor Encoders

REV Motor Drive Characteristics

Exercise

  • Exercise 2: Verify the Counts per mm above with a physical test.

Encoder Diagram

HallEncoder.jpg

FTC Motor Object Structure

References

Motor Class Specs

  • DcMotorSimple extends HardwareDevice
    • getPower -- 64 bit double
    • setPower -- 64 bit double
    • ...

DcMotor extends DcMotorSimple

    • getMode
    • getPowerFloat -- 32 bit float
    • getTargetPosiition -- encoder value
    • isBusy
    • setMode
    • setPowerFloat -- 32 bit float
    • setTargetPosition -- encoder value
    • ...
  • DcMotorEx extends DcMotor
    • getCurrent
    • getPIDCoefficients
    • getTargetPositionTolerance
    • getVelocity -- ticks per second and angle unitis
    • isOverCurrent
    • setPIDCoefficients
    • setVelocity -- ticks per second and angle units
  • ...

Exercise

  • Exercise 3: Change the DriveForwardWithEncoder to use Velocity control for both wheels instead of Power control. How does the robots move characteristics change? eg
    • Did the robot drive in a straighter line using the setVelocity than the setPower example?
    • Did the robot start out moving straight at the very beginning?
    • Did the robot stop gradually or abruptly when its target distance was reached?
    • How would you improve the robot's performance?

Spoiler Alert

  • DriveForwardWithEncoderEppGio.java - The team's colaborative solution
    • Key changes
      • import DcMotorEx
      • leftMotor and rightMotor change to type DcMotorEx
      • type cast for the hardwareMap.dcMotor.get
      • change setPower to setVelocity
      • remove setting rightMotor to RUN_WITHOUT_ENCODER run mode
        rightMotor = hardwareMap.get(DcMotorEx.class,"myRightMotor");

DcMotor and DcMotorEx differences

  • DcMotor is designed for Modern Robotics / HiTechnic motor controllers
  • DcMotor is designed for the Control Hub and Expansion Hub
  • Reference: DcMotor vs. DcMotorEx

References


Robot HW Architecture

Optical Encoders

  • IncrememtalEncoder.jpg