FTC Motor Encoders 20200304

From wikidb
Revision as of 17:00, 14 April 2022 by Edc (Talk | contribs)

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

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