Package com.pocolifo.robobase.motor
Class NovelMotor
java.lang.Object
com.pocolifo.robobase.motor.NovelMotor
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intfinal com.qualcomm.robotcore.hardware.DcMotorExfinal doublefinal double -
Constructor Summary
ConstructorsConstructorDescriptionNovelMotor(com.qualcomm.robotcore.hardware.DcMotorEx motor, double ticksPerRevolution, double wheelDiameterInches, int gearRatio) -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleencoderTicksPerSecondToInchesPerSecond(double diameterIn, double ticksPerRevolution, double encoderTicksPerSecond) doubleencoderTicksToInches(double ticks) doubledoublegets the number of motor rotationsdoublestatic doubleinchesPerSecondToEncoderTicksPerSecond(double diameterIn, double ticksPerRevolution, double inchesPerSecond) doubleinchesToEncoderTicks(double inches) voidsetPower(double power) voidsetTargetPositionInches(double centimeters) Sets the target position in centimeters instead of motor ticksvoidsetVelocity(double inchesPerSecond) voidsetZeroPowerBehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior behavior)
-
Field Details
-
motor
public final com.qualcomm.robotcore.hardware.DcMotorEx motor -
ticksPerRevolution
public final double ticksPerRevolution -
wheelDiameterInches
public final double wheelDiameterInches -
gearRatio
public final int gearRatio
-
-
Constructor Details
-
NovelMotor
public NovelMotor(com.qualcomm.robotcore.hardware.DcMotorEx motor, double ticksPerRevolution, double wheelDiameterInches, int gearRatio)
-
-
Method Details
-
encoderTicksToInches
public double encoderTicksToInches(double ticks) -
inchesToEncoderTicks
public double inchesToEncoderTicks(double inches) -
getMotorRotations
public double getMotorRotations()gets the number of motor rotations -
setTargetPositionInches
public void setTargetPositionInches(double centimeters) Sets the target position in centimeters instead of motor ticks- Parameters:
centimeters- How far the motor should move, in centimeters. Negative values move the wheel in reverse, and positive values move the wheel forward.
-
setPower
public void setPower(double power) -
setZeroPowerBehavior
public void setZeroPowerBehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior behavior) -
inchesPerSecondToEncoderTicksPerSecond
public static double inchesPerSecondToEncoderTicksPerSecond(double diameterIn, double ticksPerRevolution, double inchesPerSecond) -
encoderTicksPerSecondToInchesPerSecond
public static double encoderTicksPerSecondToInchesPerSecond(double diameterIn, double ticksPerRevolution, double encoderTicksPerSecond) -
setVelocity
public void setVelocity(double inchesPerSecond) -
getEncoderInches
public double getEncoderInches() -
getVelocity
public double getVelocity()- Returns:
- The linear velocity in inches/second.
-