Class MechBase

java.lang.Object
com.marswars.mechanisms.MechBase
All Implemented Interfaces:
SubsystemIoBase
Direct Known Subclasses:
ArmMech, ElevatorMech, FlywheelMech, Module, RollerMech, SwerveMech

public abstract class MechBase extends Object implements SubsystemIoBase
Base class for mechanism IO implementations with common motor configuration helpers. Provides motor configuration helpers for CTRE TalonFX motor controllers.
  • Field Details

    • IS_SIM

      protected final boolean IS_SIM
  • Constructor Details

    • MechBase

      public MechBase(String logging_prefix)
      Creates a new mechanism base
      Parameters:
      logging_prefix - the logging prefix for this mechanism
    • MechBase

      public MechBase(String logging_prefix, String mech_name)
      Creates a new mechanism base with a specified mechanism name
      Parameters:
      logging_prefix - the logging prefix for this mechanism
      mech_name - the name of the mechanism (used for mutliple instances of the same mech)
  • Method Details

    • getLoggingKey

      public String getLoggingKey()
      Get the logging key for this mechanism.
      Returns:
      the logging key
    • getMechName

      public String 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 configs
      sensor_to_mech_ratio - the sensor to mechanism ratio
      configMaster - 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 configs
      sensor_to_mech_ratio - the sensor to mechanism ratio
      Returns:
      the constructed motors and their signals
    • setMotorCurrentLimit

      protected void setMotorCurrentLimit(CurrentLimitsConfigs currentLimits, CommonTalon[] motors)
      Applies the given current limits to each of the provided motors.
      Parameters:
      currentLimits - the current limit configuration to apply
      motors - the motors to configure; each must be a TalonFX or TalonFXS
      Throws:
      IllegalArgumentException - if a motor is not a supported type for current limiting