Package com.marswars.swerve_lib.module
Class ModuleTalonFX
java.lang.Object
com.marswars.mechanisms.MechBase
com.marswars.swerve_lib.module.Module
com.marswars.swerve_lib.module.ModuleTalonFX
- All Implemented Interfaces:
SubsystemIoBase
TalonFX-based swerve module implementation with optional simulation support.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.marswars.swerve_lib.module.Module
Module.DriveControlMode, Module.SteerControlModeNested classes/interfaces inherited from class com.marswars.mechanisms.MechBase
MechBase.ConstructedMotors -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CANcoderprotected final StatusSignal<Voltage>protected final StatusSignal<Angle>protected final StatusSignal<Current>protected final StatusSignal<Current>protected final TalonFXprotected final StatusSignal<AngularVelocity>protected final AnalogEncoderprotected final PositionTorqueCurrentFOCprotected final PositionVoltageprotected final StatusSignal<Angle>protected final StatusSignal<Voltage>protected final StatusSignal<Current>protected final StatusSignal<Current>protected final TalonFXprotected final StatusSignal<AngularVelocity>protected final TorqueCurrentFOCprotected final VelocityTorqueCurrentFOCprotected final VelocityVoltageprotected final VoltageOutFields inherited from class com.marswars.swerve_lib.module.Module
config_, drive_conn_deb_, drive_disconnected_alert_, inputs_, module_encoder_alert_, module_index_, neutral_mode_, setpoint_, steer_conn_deb_, steer_disconnected_alert_ -
Constructor Summary
ConstructorsConstructorDescriptionModuleTalonFX(String logging_prefix, int index, SwerveModuleConfig config) Creates a new TalonFX swerve module. -
Method Summary
Modifier and TypeMethodDescriptionvoidlogData()Log data to NetworkTables or other logging systemsvoidreadInputs(double timestamp) Read inputs from hardware or simulationvoidsetDriveGains(int slot, SlotConfigs gains) Set the gains for the module drive motors to the given slotvoidsetDriveOpenLoop(double output) Run the drive motor at the specified open loop value.voidsetDriveVelocity(double wheelVelocityRadPerSec) Run the drive motor at the specified velocity.voidStores the current encoder reading as an offsetvoidSets the neutral mode for both motorsvoidsetSteerGains(SlotConfigs gains) Set the gains for the module steer motors to the given slotvoidsetSteerOpenLoop(double output) Run the turn motor at the specified open loop value.voidsetSteerPosition(Rotation2d rotation) Run the turn motor to the specified rotation.voidwriteOutputs(double timestamp) Write outputs to hardware or simulationMethods inherited from class com.marswars.swerve_lib.module.Module
getAngle, getCurrentState, getFFCharacterizationVelocity, getPosition, getPositionMeters, getSetpointState, getTranslation, getVelocityMetersPerSec, getWheelRadiusCharacterizationPosition, runCharacterization, runSetpoint, stopMethods inherited from class com.marswars.mechanisms.MechBase
configMotors, configMotors, getLoggingKey, getMechName, setMotorCurrentLimit
-
Field Details
-
drive_talonfx_
-
steer_talonfx_
-
cancoder
-
encoder
-
voltage_req_
-
position_voltage_req_
-
velocity_voltage_req_
-
torque_current_req_
-
position_torque_current_req_
-
velocity_torque_current_req_
-
drive_position_sig_
-
drive_velocity_sig_
-
drive_applied_volts_sig_
-
drive_stator_current_sig_
-
drive_supply_current_sig_
-
steer_absolute_position_sig_
-
steer_velocity_sig_
-
steer_applied_volts_sig_
-
steer_stator_current_sig_
-
steer_supply_current_sig_
-
-
Constructor Details
-
ModuleTalonFX
Creates a new TalonFX swerve module.- Parameters:
logging_prefix- Logging prefix for telemetryindex- Module index (0-3)config- Module configuration
-
-
Method Details
-
readInputs
public void readInputs(double timestamp) Read inputs from hardware or simulation- Parameters:
timestamp- the current timestamp
-
setDriveOpenLoop
public void setDriveOpenLoop(double output) Run the drive motor at the specified open loop value.- Specified by:
setDriveOpenLoopin classModule
-
setSteerOpenLoop
public void setSteerOpenLoop(double output) Run the turn motor at the specified open loop value.- Specified by:
setSteerOpenLoopin classModule
-
setDriveVelocity
public void setDriveVelocity(double wheelVelocityRadPerSec) Run the drive motor at the specified velocity.- Specified by:
setDriveVelocityin classModule
-
setSteerPosition
Run the turn motor to the specified rotation.- Specified by:
setSteerPositionin classModule
-
setDriveGains
Set the gains for the module drive motors to the given slot- Specified by:
setDriveGainsin classModule
-
setSteerGains
Set the gains for the module steer motors to the given slot- Specified by:
setSteerGainsin classModule
-
setModuleOffset
public void setModuleOffset()Stores the current encoder reading as an offset- Overrides:
setModuleOffsetin classModule
-
setNeutralMode
Sets the neutral mode for both motors- Overrides:
setNeutralModein classModule
-
writeOutputs
public void writeOutputs(double timestamp) Write outputs to hardware or simulation- Parameters:
timestamp- the current timestamp
-
logData
public void logData()Log data to NetworkTables or other logging systems
-