ServoEx

open class ServoEx : ServoImpl, PwmControl

Extension of the extended Servo interface that allows for motion profiling via a TrapezoidProfile. This extension also offers refresh rate and position cache tolerance handling for loop time optimisation similar to an SimpleRotator.

This class serves as a drop-in replacement for the Servo, similar to Motor with the DcMotor. Do note that this class cannot be cast to a ServoImplEx instance, but it does implement the extended PwmControl interface for extended operations.

Author

Lucas Bubner, 2024

Since

5.1.0

Constructors

Link copied to clipboard
constructor(@NonNull servo: Servo)
Wrap a Servo to use with the ServoEx class.

Inherited properties

Link copied to clipboard
protected open var controller: ServoController
Link copied to clipboard
protected open var direction: Servo.Direction
Link copied to clipboard
protected open var limitPositionMax: Double
Link copied to clipboard
protected open var limitPositionMin: Double
Link copied to clipboard
val MAX_POSITION: Double = 1.0
Link copied to clipboard
val MIN_POSITION: Double = 0.0
Link copied to clipboard
protected open var portNumber: Int

Functions

Link copied to clipboard
Return to standard servo controls without a motion profile.
Link copied to clipboard
open fun getPwmRange(): PwmControl.PwmRange
Returns the current PWM range limits for the servo
Link copied to clipboard
open fun isPwmEnabled(): Boolean
Returns whether the PWM is energized for this particular servo
Link copied to clipboard
open fun setConstraints(@Nullable positionConstraints: TrapezoidProfile.Constraints)
Sets the trapezoidal constraints to apply to this servo's positions.
Link copied to clipboard
open fun setPosition(targetPosition: Double)
Sets the current position of the servo, expressed as a fraction of its available range.
Link copied to clipboard
open fun setPositionDeltaThreshold(magnitude: Double)
Set the delta in servo position required to propagate a hardware write.
Link copied to clipboard
open fun setPositionRefreshRate(@NonNull refreshRate: Measure<Time>)
Set the refresh rate of the servo that will be a minimum time between hardware writes.
Link copied to clipboard
open fun setPwmDisable()
Individually de-energizes the PWM for this particular servo
Link copied to clipboard
open fun setPwmEnable()
Individually energizes the PWM for this particular servo.
Link copied to clipboard
open fun setPwmRange(@NonNull range: PwmControl.PwmRange)
Sets the PWM range limits for the servo

Inherited functions

Link copied to clipboard
open fun close()
Link copied to clipboard
Link copied to clipboard
open fun getController(): ServoController
Link copied to clipboard
open fun getDeviceName(): String
Link copied to clipboard
open fun getDirection(): Servo.Direction
Link copied to clipboard
open fun getManufacturer(): HardwareDevice.Manufacturer
Link copied to clipboard
open fun getPortNumber(): Int
Link copied to clipboard
open fun getPosition(): Double
Link copied to clipboard
open fun getVersion(): Int
Link copied to clipboard
protected open fun internalSetPosition(position: Double)
Link copied to clipboard
open fun scaleRange(min: Double, max: Double)
Link copied to clipboard
open fun setDirection(direction: Servo.Direction)