Mongu

class Mongu<T : Any>(val motor: T, val engu: Engu? = null, val control: ControlType, enguConfig: CANcoderConfiguration.() -> Unit = {}, monguConfig: MonguConfig<out T>.() -> Unit = {})

A generic motor wrapper class that allows configuration of different motor types.

The control type is locked at initialization and cannot be changed during runtime. This ensures type safety and prevents accidental control type switching.

Usage Examples:

// Create a motor with PWM control
val motor = Mongu(TalonFX(1), control = ControlType.PWM)
motor.move(0.5) // 50% forward

// Create a motor with position control
val posMotor = Mongu(TalonFX(2), control = ControlType.POSITION) {
this as TalonFXConfig
pingu.p = 0.1
}
posMotor.move(10.0) // move to position 10

Parameters

T

The type of motor being wrapped.

monguConfig

A lambda that applies configuration settings to the motor.

enguConfig

A lambda that applies configuration settings to the encoder.

Constructors

Link copied to clipboard
constructor(motor: T, engu: Engu? = null, control: ControlType, enguConfig: CANcoderConfiguration.() -> Unit = {}, monguConfig: MonguConfig<out T>.() -> Unit = {})

Properties

Link copied to clipboard
val MonguFX.acceleration: Double

Retrieves the current acceleration of the TalonFX motor.

Link copied to clipboard
val MonguSpark.channel: Int

Extension property to retrieve the PWM channel for MonguSpark.

val MonguSRX.channel: Int

Extension property to retrieve the PWM channel for MonguSRX.

Link copied to clipboard
lateinit var configuration: MonguConfig<T>

Holds the last configuration applied to this motor. This property is updated whenever the configure method is called. It allows retrieval of the configuration settings for inspection or reuse.

Link copied to clipboard

The control type that this motor is locked to.

Link copied to clipboard
val MonguFX.deviceID: Int

Retrieves the device ID of the underlying TalonFX motor.

Link copied to clipboard
val engu: Engu?

An optional encoder associated with the motor.

Link copied to clipboard
val MonguFX.isConnected: Boolean

Indicates whether the TalonFX motor is currently connected.

Link copied to clipboard
val motor: T

The motor instance being wrapped.

Link copied to clipboard

Retrieves the stall current of the TalonFX motor.

Link copied to clipboard
val MonguFX.motorVoltage: Double

Retrieves the motor voltage of the TalonFX motor.

Link copied to clipboard
val MonguFX.pingu: Pingu

Retrieves the custom pingu property from the TalonFXConfig configuration.

Link copied to clipboard
val MonguFX.position: Double

Retrieves the current position of the TalonFX motor.

Link copied to clipboard
val MonguSpark.pwm: Double

Extension property to calculate the PWM voltage ratio for MonguSpark.

val MonguSRX.pwm: Double

Extension property to calculate the PWM voltage ratio for MonguSRX.

Link copied to clipboard
val MonguFX.rotorPosition: Double

Retrieves the rotor position of the TalonFX motor.

Link copied to clipboard
val MonguFX.rotorVelocity: Double

Retrieves the rotor velocity of the TalonFX motor.

Link copied to clipboard
val MonguFX.statorCurrent: Double

Retrieves the stator current of the TalonFX motor.

Link copied to clipboard
val MonguFX.supplyCurrent: Double

Retrieves the supply current of the TalonFX motor.

Link copied to clipboard
val MonguFX.supplyVoltage: Double

Retrieves the supply voltage of the TalonFX motor.

Link copied to clipboard
val MonguFX.velocity: Double

Retrieves the current velocity of the TalonFX motor.

Functions

Link copied to clipboard
fun configure(block: MonguConfig<out T>.() -> Unit = {})

Configures the motor using a DSL-style configuration block.

Link copied to clipboard
fun move(value: Double)

Moves the motor using the locked control type.

Link copied to clipboard
operator fun not()

Operator overload for logical NOT (!) to stop the motor.

Link copied to clipboard
fun MonguFX.resetPosition(position: Double = 0.0): StatusCode

Resets the position of the TalonFX motor to the specified value.

Link copied to clipboard
fun MonguFX.setControl(control: ControlRequest): StatusCode

Sets the ControlRequest for the underlying TalonFX motor.

Link copied to clipboard
fun stopMotor()

Stops the motor by invoking the configured stop function.