Class MotorDevice
java.lang.Object
com.cdarobotics.cdalib.devices.Device
com.cdarobotics.cdalib.devices.actuators.MotorDevice
- Direct Known Subclasses:
PositionMotorDevice,VelocityMotorDevice
-
Constructor Summary
ConstructorsConstructorDescriptionMotorDevice(com.qualcomm.robotcore.hardware.DcMotorEx motor) Wraps an already-resolved motor.MotorDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name) Resolves the motor from the hardware map by configured name. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetCurrent(org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit unit) intdoubledoublecom.qualcomm.robotcore.hardware.DcMotorExgetMotor()setDirection(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction) Sets the motor's rotation direction.setMode(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode) Sets the run mode (e.g.setPower(double power) Sets the power to command on the nextupdate().setPowerWriteThreshold(double threshold) Sets the minimum power change (relative to the value last written to hardware) that triggers an actual write inupdate().setZeroPowerBehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior behavior) Sets what the motor does at zero power —BRAKEorFLOAT.voidupdate()Flush pending writes to, or refresh cached reads from, the underlying hardware.
-
Constructor Details
-
MotorDevice
public MotorDevice(com.qualcomm.robotcore.hardware.DcMotorEx motor) Wraps an already-resolved motor. -
MotorDevice
Resolves the motor from the hardware map by configured name.
-
-
Method Details
-
setPower
Sets the power to command on the nextupdate(). Range [-1.0, 1.0]. -
setPowerWriteThreshold
Sets the minimum power change (relative to the value last written to hardware) that triggers an actual write inupdate(). Larger values collapse more redundant Lynx writes — cutting loop time when the command is steady — at the cost of coarser resolution. Set to0for exact writes (every change flushed). Defaults to 0.005. -
getCurrentPower
public double getCurrentPower()- Returns:
- the last commanded power (not necessarily yet flushed to hardware).
-
getCurrentPosition
public int getCurrentPosition()- Returns:
- the encoder position, in ticks.
-
getCurrentVelocity
public double getCurrentVelocity()- Returns:
- the current velocity, in ticks per second.
-
setDirection
Sets the motor's rotation direction. -
setZeroPowerBehavior
public MotorDevice setZeroPowerBehavior(com.qualcomm.robotcore.hardware.DcMotor.ZeroPowerBehavior behavior) Sets what the motor does at zero power —BRAKEorFLOAT. -
setMode
Sets the run mode (e.g.RUN_USING_ENCODER,RUN_TO_POSITION). -
getMotor
public com.qualcomm.robotcore.hardware.DcMotorEx getMotor()- Returns:
- the wrapped SDK motor, for operations not exposed here.
-
update
public void update()Description copied from class:DeviceFlush pending writes to, or refresh cached reads from, the underlying hardware.
-