Class SimMotorState
java.lang.Object
org.ironmaple.simulation.motorsims.SimMotorState
Represents the state of a simulated motor at a given point in time.
This record holds the final angular position and velocity of the motor. It is used to track the motor's state during each simulation step.
-
Field Summary
Modifier and TypeFieldDescriptionedu.wpi.first.units.measure.Angle
edu.wpi.first.units.measure.AngularVelocity
-
Constructor Summary
ConstructorDescriptionSimMotorState
(edu.wpi.first.units.measure.Angle mechanismAngularPosition, edu.wpi.first.units.measure.AngularVelocity mechanismAngularVelocity) Constructs a new sim motor state with initial angle and velocity -
Method Summary
Modifier and TypeMethodDescriptionvoid
step
(edu.wpi.first.units.measure.Torque finalElectricTorque, edu.wpi.first.units.measure.Torque finalFrictionTorque, edu.wpi.first.units.measure.MomentOfInertia loadMOI, edu.wpi.first.units.measure.Time dt) Simulates a step in the motor's motion based on the applied forces.
-
Field Details
-
mechanismAngularPosition
public edu.wpi.first.units.measure.Angle mechanismAngularPosition -
mechanismAngularVelocity
public edu.wpi.first.units.measure.AngularVelocity mechanismAngularVelocity
-
-
Constructor Details
-
SimMotorState
public SimMotorState(edu.wpi.first.units.measure.Angle mechanismAngularPosition, edu.wpi.first.units.measure.AngularVelocity mechanismAngularVelocity) Constructs a new sim motor state with initial angle and velocity
- Parameters:
mechanismAngularPosition
- the final angular position of the motor, in radiansmechanismAngularVelocity
- the final angular velocity of the motor, in radians per second
-
-
Method Details
-
step
public void step(edu.wpi.first.units.measure.Torque finalElectricTorque, edu.wpi.first.units.measure.Torque finalFrictionTorque, edu.wpi.first.units.measure.MomentOfInertia loadMOI, edu.wpi.first.units.measure.Time dt) Simulates a step in the motor's motion based on the applied forces.
This method calculates the new angular position and velocity of the motor after applying electric and frictional torques over a time step.
The method follows these steps:
- Convert all units to SI units for calculation.
- Apply the electric torque to the current angular velocity.
- Compute the change in angular velocity due to friction.
- If friction reverses the direction of angular velocity, the velocity is set to zero.
- Integrate the angular velocity to find the new position.
- Parameters:
finalElectricTorque
- the final applied electric torque, in Newton-metersfinalFrictionTorque
- the final frictional torque, in Newton-metersloadMOI
- the moment of inertia of the load, in kilogram square metersdt
- the time step for the simulation, in seconds
-