Engu
Enhanced CANcoder wrapper class with simplified configuration and utility methods.
Provides convenient methods for common encoder operations like angle reading, offset calibration, and unit conversions specifically useful for swerve drive modules.
Usage Examples:
// Basic setup
val encoder = Engu(1)
// Configure with offset and direction
encoder.configure {
MagnetSensor.apply {
SensorDirection = SensorDirectionValue.CounterClockwise_Positive
MagnetOffset = 0.25
}
}
// Get angle as Rotation2d
val angle = encoder.rotation
// Get position in rotations
val rotations = encoder.rotations
// Get position in degrees
val degrees = encoder.degreesProperties
Gets the angular velocity as a measured value.
Holds the last CANcoderConfiguration applied to this CANcoder. This property is updated whenever the configure method is called. It allows retrieval of the configuration settings for inspection or reuse.
Gets the velocity in degrees per second.
Gets the velocity in radians per second.
Gets the velocity in rotations per second.
Functions
Sets the magnet offset to the current position.
Configures the encoder for swerve module use with common settings.
Extension to configure an existing Engu for swerve use with a DSL.
Extension to get the angle error between current position and target.
Sets a specific offset in degrees.
Sets a specific offset in rotations.
Extension to get the shortest angular distance to target.
Extension to log encoder information to a string.