Class RollerMech

java.lang.Object
com.marswars.mechanisms.MechBase
com.marswars.mechanisms.RollerMech
All Implemented Interfaces:
SubsystemIoBase
Direct Known Subclasses:
TurretMech

public class RollerMech extends MechBase
TalonFX-based mechanism implementation for rollers with position, velocity, and duty cycle control.
  • Field Details

    • motion_magic_position_request_

      protected final MotionMagicVoltage motion_magic_position_request_
    • motion_magic_velocity_request_

      protected final MotionMagicVelocityVoltage motion_magic_velocity_request_
    • signals_

      protected final BaseStatusSignal[] signals_
    • motor_disconnected_alerts_

      protected final Alert[] motor_disconnected_alerts_
    • motor_temp_alerts_

      protected final Alert[] motor_temp_alerts_
    • motor_conn_debouncers_

      protected final Debouncer[] motor_conn_debouncers_
    • inputs_

      protected final com.marswars.mechanisms.MechInputsAutoLogged inputs_
    • position_target_

      protected double position_target_
    • velocity_target_

      protected double velocity_target_
    • duty_cycle_target_

      protected double duty_cycle_target_
    • current_target_

      protected double current_target_
    • current_target_FF_

      protected double current_target_FF_
    • filtered_torque_current_

      protected double filtered_torque_current_
  • Constructor Details

    • RollerMech

      public RollerMech(String logging_prefix, List<MotorConfig> motor_configs, double gear_ratio)
      Constructs a new RollerMech with a default inertia value.
      Parameters:
      logging_prefix - String prefix for logging
      motor_configs - Configuration for the roller motor
      gear_ratio - Gear ratio as motor rotations / mechanism rotations
    • RollerMech

      public RollerMech(String logging_prefix, String mech_name, List<MotorConfig> motor_configs, double gear_ratio)
      Constructs a new RollerMech
      Parameters:
      logging_prefix - String prefix for logging
      mech_name - Name of the mechanism
      motor_configs - Configuration for the roller motor
      gear_ratio - Gear ratio as motor rotations / mechanism rotations
    • RollerMech

      public RollerMech(String logging_prefix, List<MotorConfig> motor_configs, double gear_ratio, double roller_inertia)
      Constructs a new RollerMech
      Parameters:
      logging_prefix - String prefix for logging
      motor_configs - Configuration for the roller motor
      gear_ratio - Gear ratio as motor rotations / mechanism rotations
      roller_inertia - Inertia of the roller in kg*m^2 (Simulation only)
    • RollerMech

      public RollerMech(String logging_prefix, String mech_name, List<MotorConfig> motor_configs, double gear_ratio, double roller_inertia)
      Constructs a new RollerMech
      Parameters:
      logging_prefix - String prefix for logging
      mech_name - Name of the mechanism
      motor_configs - Configuration for the roller motor
      gear_ratio - Gear ratio as motor rotations / mechanism rotations
      roller_inertia - Inertia of the roller in kg*m^2 (Simulation only)
  • Method Details

    • readInputs

      public void readInputs(double timestamp)
      Read inputs from hardware or simulation
      Parameters:
      timestamp - the current timestamp
    • 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
    • configSlot

      public void configSlot(int slot, SlotConfigs config)
      Configures the given slot with the given config
      Parameters:
      slot - the slot index to configure
      config - the slot config to apply
    • setCurrentPosition

      public void setCurrentPosition(double position_rad)
      Sets the current position of the roller mechanism (for resetting encoders, etc.)
      Parameters:
      position_rad - the position in radians
    • getCurrentPosition

      public double getCurrentPosition()
      Gets the current position of the roller mechanism in radians
      Returns:
      the position in radians
    • getCurrentVelocity

      public double getCurrentVelocity()
      Gets the current velocity of the roller mechanism in radians per second
      Returns:
      the velocity in radians per second
    • getLeaderSupplyCurrent

      public double getLeaderSupplyCurrent()
      Gets the supply (battery-side) current draw of the leader motor in amps.
      Returns:
      the leader supply current in amps
    • getLeaderStatorCurrent

      public double getLeaderStatorCurrent()
      Gets the stator (motor-winding) current draw of the leader motor in amps.
      Returns:
      the leader stator current in amps
    • setTargetPosition

      public void setTargetPosition(double position_rad)
      Sets the target position of the roller mechanism in radians using standard position control
      Parameters:
      position_rad - the target position in radians
    • setTargetPositionWithFF

      public void setTargetPositionWithFF(double position_rad, double arbitrary_feedforward)
      Sets the target position of the roller mechanism with arbitrary feed forward. This allows additional control output while holding a position (e.g., for a hood that adds backspin).
      Parameters:
      position_rad - the target position in radians
      arbitrary_feedforward - arbitrary feed forward value (units depend on slot gains configuration)
    • setTargetPositionMotionProfile

      public void setTargetPositionMotionProfile(double position_rad)
      Sets the target position of the roller mechanism in radians using motion profile control
      Parameters:
      position_rad - the target position in radians
    • setTargetPositionMotionProfileWithFF

      public void setTargetPositionMotionProfileWithFF(double position_rad, double arbitrary_feedforward)
      Sets the target position of the roller mechanism with arbitrary feed forward using motion profile control. This allows additional control output while holding a position (e.g., for a hood that adds backspin).
      Parameters:
      position_rad - the target position in radians
      arbitrary_feedforward - arbitrary feed forward value (units depend on slot gains configuration)
    • setTargetVelocity

      public void setTargetVelocity(double velocity_rad_per_sec)
      Sets the target velocity of the roller mechanism in radians per second using standard velocity control
      Parameters:
      velocity_rad_per_sec - the target velocity in radians per second
    • setTargetVelocityMotionProfile

      public void setTargetVelocityMotionProfile(double velocity_rad_per_sec)
      Sets the target velocity of the roller mechanism in radians per second using motion profile velocity control
      Parameters:
      velocity_rad_per_sec - the target velocity in radians per second
    • setTargetDutyCycle

      public void setTargetDutyCycle(double duty_cycle)
      Sets the target duty cycle of the roller mechanism
      Parameters:
      duty_cycle - the target duty cycle (-1.0 to 1.0)
    • setTargetCurrent

      public void setTargetCurrent(double current_amps)
    • setTargetCurrentWithFF

      public void setTargetCurrentWithFF(double current_amps, double feedforward)
      Sets the target current with a feedforward component.
      Parameters:
      current_amps - the target current in amps
      feedforward - the feedforward component in amps to add to the target current
    • applyLoadTorque

      public void applyLoadTorque(double torque_nm)
      Applies a load torque to the roller mechanism for simulation purposes. This method should be called during the simulation update cycle to apply external loads (like friction, compression forces, etc.) to the mechanism.
      Parameters:
      torque_nm - The load torque in Newton-meters (Nm) at the roller output shaft. Positive values oppose motion in the positive direction.
    • setCurrentLimits

      public void setCurrentLimits(CurrentLimitsConfigs currentLimits)
      Sets the current limits for all motors in the mechanism.
      Parameters:
      currentLimits - the current limits configuration to apply