Package frc.robot.simulation
Class ClimbSim
A specialized simulation for a spring-extended, motor-retracted climber.
-
Field Summary
Fields inherited from class edu.wpi.first.wpilibj.simulation.LinearSystemSim
m_measurementStdDevs, m_plant, m_u, m_x, m_y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the simulated current draw of the climber.doubleReturns the current position of the climber.doubleReturns the current velocity of the climber.booleanisHooked()Returns whether the climber has hooked onto the bar.voidsetInputVoltage(double volts) Sets the input voltage for the climber motors.final voidsetState(double positionMeters, double velocityMetersPerSecond) Sets the state of the simulation.
-
Constructor Details
-
ClimbSim
public ClimbSim(DCMotor gearbox, double gearing, double armMassKg, double botMassKg, double drumRadiusMeters, double minHeightMeters, double maxHeightMeters, double springForceNewtons) Constructs a new ClimbSim.- Parameters:
gearbox- The climber motor gearbox.gearing- The total reduction (e.g., 50.0).armMassKg- The mass of the extending climber stage.botMassKg- The total mass of the robot.drumRadiusMeters- The radius of the spool/drum.minHeightMeters- The bottom limit (usually 0).maxHeightMeters- The height at which the hook catches the bar.springForceNewtons- The upward force provided by extension springs.
-
-
Method Details
-
setState
public final void setState(double positionMeters, double velocityMetersPerSecond) Sets the state of the simulation.- Parameters:
positionMeters- The new position in meters.velocityMetersPerSecond- The new velocity in meters per second.
-
isHooked
public boolean isHooked()Returns whether the climber has hooked onto the bar.- Returns:
- True if hooked, false otherwise.
-
getPositionMeters
public double getPositionMeters()Returns the current position of the climber.- Returns:
- The position in meters.
-
getVelocityMetersPerSecond
public double getVelocityMetersPerSecond()Returns the current velocity of the climber.- Returns:
- The velocity in meters per second.
-
setInputVoltage
public void setInputVoltage(double volts) Sets the input voltage for the climber motors.- Parameters:
volts- The input voltage to apply.
-
getCurrentDrawAmps
public double getCurrentDrawAmps()Returns the simulated current draw of the climber.- Returns:
- The current draw in amps.
-
updateX
- Overrides:
updateXin classLinearSystemSim<N2,N1, N2>
-