Tongu FX
Wrapper around TalonFX that implements Mongu configuration and control using a ControlRequest.
Type parameter T represents the specific subtype of ControlRequest used to send control commands.
Usage:
// Provide a control request and a function that produces a new request with the desired output.
val velocityVoltage = VelocityVoltage()
val motor = TonguFX(1, velocityVoltage, { out -> this.withVelocity(out) })
// Configure via DSL, then control the motor.
motor.configure {
pingu.p = 0.1
inverted = InvertedValue.Clockwise_Positive
}
motor.movePWM(0.5) // simple PWM control
motor.control(25) // send a ControlRequest with output 25
motor.stopMotor() // stops using configured stop behaviorNotes:
withOutputmust return a new or modified instance ofTthat encodes the requested output. Implementations should avoid mutating a shared template in-place unless it is safe for concurrent use.The provided
controlRequestacts as a template; the concrete request sent is created by invokingcontrolRequest.withOutput(value).Initialization resets position to
0.0and applies the optionalmonguConfigblock.configureapplies changes to the in-memoryTalonFXConfigand immediately applies them to the hardware.
Parameters
The CAN device id for the TalonFX.
A template control request instance used as the base for control operations.
An extension function on the control request type that returns a new request with the given output value.
The CAN bus to use (default is roboRIO).
Optional DSL block to configure the motor's TalonFXConfig during initialization.
Constructors
Properties
The configuration for this TalonFX motor.
Convenience property that exposes the controller's current acceleration as a Double.
Convenience property that exposes the controller's current position as a Double.
Convenience property that exposes the controller's rotor velocity as a Double.
Convenience property that exposes the controller's current velocity as a Double.
Retrieves the custom pingu property from the TalonFXConfig configuration.
Functions
Configures the motor using a DSL-style configuration block.
Applies a set of sensible default values to this motor's TalonFXConfig and then invokes the provided block to allow callers to override or extend those defaults.
Resets the position of the TonguFX motor to the specified value.