Package com.marswars.mechanisms
Class MechBase
java.lang.Object
com.marswars.mechanisms.MechBase
- All Implemented Interfaces:
SubsystemIoBase
- Direct Known Subclasses:
ArmMech,ElevatorMech,FlywheelMech,Module,RollerMech,SwerveMech
Base class for mechanism IO implementations with common motor configuration helpers.
Provides motor configuration helpers for CTRE TalonFX motor controllers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassContainer for constructed motor controllers and their status signals. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconfigMotors(List<MotorConfig> motor_configs, double sensor_to_mech_ratio) Configures the motors based on the given motor configs.configMotors(List<MotorConfig> motor_configs, double sensor_to_mech_ratio, Function<MotorConfig, MotorConfig> configMaster) Configures the TalonFX motors based on the given motor configsGet the logging key for this mechanism.Get the name of the mechanism.protected voidsetMotorCurrentLimit(CurrentLimitsConfigs currentLimits, CommonTalon[] motors) Applies the given current limits to each of the provided motors.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.marswars.subsystem.SubsystemIoBase
logData, readInputs, writeOutputs
-
Field Details
-
IS_SIM
protected final boolean IS_SIM
-
-
Constructor Details
-
MechBase
Creates a new mechanism base- Parameters:
logging_prefix- the logging prefix for this mechanism
-
MechBase
Creates a new mechanism base with a specified mechanism name- Parameters:
logging_prefix- the logging prefix for this mechanismmech_name- the name of the mechanism (used for mutliple instances of the same mech)
-
-
Method Details
-
getLoggingKey
Get the logging key for this mechanism.- Returns:
- the logging key
-
getMechName
Get the name of the mechanism.- Returns:
- the name of the mechanism
-
configMotors
public MechBase.ConstructedMotors configMotors(List<MotorConfig> motor_configs, double sensor_to_mech_ratio, Function<MotorConfig, MotorConfig> configMaster) Configures the TalonFX motors based on the given motor configs- Parameters:
motor_configs- the list of motor configssensor_to_mech_ratio- the sensor to mechanism ratioconfigMaster- a function to modify the master motor config before applying it- Returns:
- the constructed motors and their signals
-
configMotors
public MechBase.ConstructedMotors configMotors(List<MotorConfig> motor_configs, double sensor_to_mech_ratio) Configures the motors based on the given motor configs.- Parameters:
motor_configs- the list of motor configssensor_to_mech_ratio- the sensor to mechanism ratio- Returns:
- the constructed motors and their signals
-
setMotorCurrentLimit
Applies the given current limits to each of the provided motors.- Parameters:
currentLimits- the current limit configuration to applymotors- the motors to configure; each must be aTalonFXorTalonFXS- Throws:
IllegalArgumentException- if a motor is not a supported type for current limiting
-