Motor

public final class Motor implements Component

A wrapper for the DcMotorEx object in the FTC SDK.

Parameters

motor

The motor for the wrapper to use.

maxRPM

The maximum revolutions per minute of the motor.

TPR

The ticks per revolution of the motor.

Constructors

Link copied to clipboard
public Motor Motor(HardwareMap hMap, String id, Double maxRPM, Double TPR, NanoClock clock)
public Motor Motor(HardwareMap hMap, String id, Double maxRPM, Double TPR)
public Motor Motor(HardwareMap hMap, String id, Double maxRPM)
public Motor Motor(HardwareMap hMap, String id, Motor.Type type, NanoClock clock)
public Motor Motor(HardwareMap hMap, String id, Motor.Type type)
public Motor Motor(DcMotorEx motor, Motor.Type type, NanoClock clock)
public Motor Motor(DcMotorEx motor, Motor.Type type)
public Motor Motor(DcMotorEx motor, Double maxRPM, Double TPR, NanoClock clock)
public Motor Motor(DcMotorEx motor, Double maxRPM, Double TPR)
public Motor Motor(DcMotorEx motor, Double maxRPM)

Types

Link copied to clipboard
public final class Encoder

A wrapper for motor encoders in the FTC SDK.

Link copied to clipboard
public enum RunMode extends Enum<Motor.RunMode>
Link copied to clipboard
public enum Type extends Enum<Motor.Type>

A class with the specs of many motors so you don't have to find them.

Link copied to clipboard

Properties

Link copied to clipboard
private final Integer currentPosition

The current position of the encoder (in ticks).

Link copied to clipboard
private final Double distance

The distance travelled by the motor. Computed using the encoder and distancePerTick.

Link copied to clipboard

The distance per revolution travelled by the motor.

Link copied to clipboard
private final Double distanceVelocity

The velocity of the motor in distance per second. Computed using the encoder and distancePerTick.

Link copied to clipboard
Link copied to clipboard

Feedforward used in RunMode.RUN_USING_ENCODER and optionally RunMode.RUN_WITHOUT_ENCODER. Note that these coefficients are applied to desired encoder tick velocity. This must be tuned in order for setTickVelocity, setDistanceVelocity, and setRPM to work.

Link copied to clipboard
public final DcMotorEx internal
Link copied to clipboard

The maximum achievable distance velocity of the motor, in units per second. Computed using maxTPS and distancePerTick.

Link copied to clipboard
public final Double maxRPM
Link copied to clipboard
public final Double maxTPS

The maximum achievable ticks per second of the motor. Computed using maxRPM and TPR.

Link copied to clipboard
private Double power

The percentage of power to the motor in the range [-1.0, 1.0].

Link copied to clipboard
private Boolean reversed

Whether the motor is reversed.

Link copied to clipboard
private final Angle rotation

The total rotation of the motor. Note that this value is positive or negative according to motor direction.

Link copied to clipboard
Link copied to clipboard
private final Double targetVelocity

The target velocity of RunMode.RUN_USING_ENCODER in ticks per second.

Link copied to clipboard
public final Double TPR
Link copied to clipboard
private final Double velocity

The velocity of the motor, in ticks per second. Computed using the encoder.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
public final Integer getCurrentPosition()
Link copied to clipboard
public final Double getDistance()
Link copied to clipboard
public final Double getDistancePerTick()
Link copied to clipboard
public final Double getDistanceVelocity()
Link copied to clipboard
public final Feedforward getFeedforward()

Feedforward used in RunMode.RUN_USING_ENCODER and optionally RunMode.RUN_WITHOUT_ENCODER. Note that these coefficients are applied to desired encoder tick velocity. This must be tuned in order for setTickVelocity, setDistanceVelocity, and setRPM to work.

Link copied to clipboard
Link copied to clipboard
public final Double getPower()
Link copied to clipboard
public final Angle getRotation()
Link copied to clipboard
public final Motor.RunMode getRunMode()
Link copied to clipboard
public final Double getTargetVelocity()
Link copied to clipboard
public final Double getVelocity()
Link copied to clipboard

PID coefficients used in RunMode.RUN_USING_ENCODER.

Link copied to clipboard
Link copied to clipboard
public final Boolean isReversed()
Link copied to clipboard
public final Unit resetEncoder()

Resets the encoder.

Link copied to clipboard
public final Motor reversed()

Reverses the direction of the motor.

Link copied to clipboard
public final Unit setDistancePerTick(Double distancePerTick)
Link copied to clipboard
public final Unit setDistanceVelocity(Double velocity)
public final Unit setDistanceVelocity(Double velocity, Double acceleration)

Sets the velocity of the motor in distance units per second.

Link copied to clipboard
public final Unit setFeedforward(Feedforward feedforward)

Feedforward used in RunMode.RUN_USING_ENCODER and optionally RunMode.RUN_WITHOUT_ENCODER. Note that these coefficients are applied to desired encoder tick velocity. This must be tuned in order for setTickVelocity, setDistanceVelocity, and setRPM to work.

Link copied to clipboard
public final Unit setPower(Double power)
Link copied to clipboard
public final Motor setReversed(Boolean reversed)
Link copied to clipboard
public final Unit setRPM(Double rpm)

Sets the velocity of the motor in revolutions per second.

Link copied to clipboard
public final Unit setRunMode(Motor.RunMode runMode)
Link copied to clipboard
public final Unit setTickVelocity(Double velocity)
public final Unit setTickVelocity(Double velocity, Double acceleration)

Sets the velocity of the motor in encoder ticks per second.

Link copied to clipboard
public final Unit setVeloCoefficients(PIDCoefficients veloCoefficients)
Link copied to clipboard
public final Unit setZeroPowerBehavior(Motor.ZeroPowerBehavior zeroPowerBehavior)
Link copied to clipboard
public Unit update()

Updates both RunMode.RUN_USING_ENCODER and RunMode.RUN_TO_POSITION. Running this method is not necessary for RunMode.RUN_WITHOUT_ENCODER.