Package com.pocolifo.robobase.motor
Class NovelMotor
java.lang.Object
com.pocolifo.robobase.motor.NovelMotor
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal int
final com.qualcomm.robotcore.hardware.DcMotorEx
final double
final double
-
Constructor Summary
ConstructorsConstructorDescriptionNovelMotor
(com.qualcomm.robotcore.hardware.DcMotorEx motor, double ticksPerRevolution, double wheelDiameterInches, int gearRatio) -
Method Summary
Modifier and TypeMethodDescriptionstatic double
encoderTicksPerSecondToInchesPerSecond
(double diameterIn, double ticksPerRevolution, double encoderTicksPerSecond) double
encoderTicksToInches
(double ticks) double
double
gets the number of motor rotationsdouble
static double
inchesPerSecondToEncoderTicksPerSecond
(double diameterIn, double ticksPerRevolution, double inchesPerSecond) double
inchesToEncoderTicks
(double inches) void
setPower
(double power) void
setTargetPositionInches
(double centimeters) Sets the target position in centimeters instead of motor ticksvoid
setVelocity
(double inchesPerSecond) void
setZeroPowerBehavior
(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.
-