Motor
Drop-in replacement for a DcMotor that uses custom control algorithms to operate RUN_USING_ENCODER and RUN_TO_POSITION modes. Internally integrates a gain scheduler to allow for more precise system coefficients against gravity and other external forces. This class effectively wraps an entire DcMotor and regulates all of the operations.
This class is designed to be down casted to a DcMotor where used, integrating with the current motor modes while providing faster, predictable control systems.
Author
Lucas Bubner, 2024
Since
4.0.0
Constructors
Types
Functions
Link copied to clipboard
Link copied to clipboard
Returns the underlying motor controller on which this motor is situated.
Link copied to clipboard
Returns the current consumed by this motor.
Link copied to clipboard
Returns the current alert for this motor.
Link copied to clipboard
Link copied to clipboard
Returns the assigned type for this motor.
Link copied to clipboard
Returns the PID control coefficients used when running in the indicated mode on this motor.
Link copied to clipboard
Returns the PIDF control coefficients used when running in the indicated mode on this motor.
Link copied to clipboard
Returns the port number on the underlying motor controller on which this motor is situated.
Link copied to clipboard
Returns whether the motor is currently in a float power level.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Returns the current target encoder position for this motor.
Link copied to clipboard
Note that this method will try to access the RUN_TO_POSITION controller to access information there.
Link copied to clipboard
Returns the current velocity of the motor, in angular units per second
Link copied to clipboard
Returns the current behavior of the motor were a power level of zero to be applied.
Link copied to clipboard
Returns whether this motor is energized
Link copied to clipboard
Returns whether the current consumption of this motor exceeds the alert threshold.
Link copied to clipboard
Reset the encoder value without stopping the motor.
Link copied to clipboard
Call to build a list of encoder tick positions where you want your RUN_TO_POSITION system controller gains to be.
Link copied to clipboard
Call to build a list of encoder tick positions where you want your RUN_USING_ENCODER system controller gains to be.
Link copied to clipboard
Sets the current alert for this motor
Link copied to clipboard
Individually de-energizes this particular motor
Link copied to clipboard
Individually energizes this particular motor
Link copied to clipboard
Sets the assigned type of this motor.
Link copied to clipboard
Sets the nominal voltage to use for power calculations.
Link copied to clipboard
open fun setNominalVoltageSensor(@NonNull nominalVoltageSensorMapping: HardwareMap.DeviceMapping<VoltageSensor>)
Sets a voltage sensor to use for nominal power calculation.
Link copied to clipboard
open fun setPIDCoefficients(@NonNull mode: DcMotor.RunMode, @NonNull pidCoefficients: PIDCoefficients)
Sets the PID control coefficients for one of the PID modes of this motor.
Link copied to clipboard
open fun setPIDFCoefficients(@NonNull mode: DcMotor.RunMode, @NonNull pidfCoefficients: PIDFCoefficients)
This method is a superset enhancement to setPIDCoefficients.
Link copied to clipboard
A shorthand for setting the P coefficient for the RUN_TO_POSITION mode.
Link copied to clipboard
Sets the zero power behavior of the motor to FLOAT, then applies zero power to that motor.
Link copied to clipboard
Set a system controller to use for RUN_TO_POSITION.
Link copied to clipboard
open fun setRunUsingEncoderController(bufferFraction: Double, @NonNull controller: SystemController)
open fun setRunUsingEncoderController(bufferFraction: Double, maxAchievableTicksPerSecond: Double, @Nullable controller: SystemController)
Set a system controller to use for RUN_USING_ENCODER.
Link copied to clipboard
Sets the desired encoder target position to which the motor should advance or retreat and then actively hold thereat.
Link copied to clipboard
Note that this method will try to access the RUN_TO_POSITION controller to access information there.
Link copied to clipboard
Switches the motor to velocity control and tries to set the ticks/sec target.
Switches the motor to velocity control and tries to set the angular velocity of the motor based on the intrinsic MotorConfigurationType configuration.
Link copied to clipboard
A shorthand for setting the PIDF coefficients for the RUN_USING_ENCODER mode.
Link copied to clipboard
Sets the behavior of the motor when a power level of zero is applied.
Link copied to clipboard
Call to use encoder overflow (exceeding 32767 ticks/sec) correction on getVelocity.
Inherited functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Sets the maximum power magnitude (applies for both negative and positive powers) this motor can run at.
Link copied to clipboard
Set the delta in power required to propagate a hardware write.
Link copied to clipboard
Set the refresh rate of the motor that will be a minimum time between hardware writes.