Package edu.wpi.first.wpilibj.simulation
Class DCMotorSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.LinearSystemSim<N2,N1,N2>
edu.wpi.first.wpilibj.simulation.DCMotorSim
public class DCMotorSim extends LinearSystemSim<N2,N1,N2>
Represents a simulated DC motor mechanism.
-
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 Constructor Description DCMotorSim(LinearSystem<N2,N1,N2> plant, DCMotor gearbox, double gearing)
Creates a simulated DC motor mechanism.DCMotorSim(LinearSystem<N2,N1,N2> plant, DCMotor gearbox, double gearing, Matrix<N2,N1> measurementStdDevs)
Creates a simulated DC motor mechanism.DCMotorSim(DCMotor gearbox, double gearing, double jKgMetersSquared)
Creates a simulated DC motor mechanism.DCMotorSim(DCMotor gearbox, double gearing, double jKgMetersSquared, Matrix<N2,N1> measurementStdDevs)
Creates a simulated DC motor mechanism. -
Method Summary
Modifier and Type Method Description double
getAngularPositionRad()
Returns the DC motor position.double
getAngularPositionRotations()
Returns the DC motor position in rotations.double
getAngularVelocityRadPerSec()
Returns the DC motor velocity.double
getAngularVelocityRPM()
Returns the DC motor velocity in RPM.double
getCurrentDrawAmps()
Returns the DC motor current draw.void
setInputVoltage(double volts)
Sets the input voltage for the DC motor.void
setState(double angularPositionRad, double angularVelocityRadPerSec)
Sets the state of the DC motor.Methods inherited from class edu.wpi.first.wpilibj.simulation.LinearSystemSim
clampInput, getOutput, getOutput, setInput, setInput, setInput, setState, update, updateX
-
Constructor Details
-
DCMotorSim
Creates a simulated DC motor mechanism.- Parameters:
plant
- The linear system representing the DC motor. This system can be created withLinearSystemId.createDCMotorSystem(DCMotor, double, double)
.gearbox
- The type of and number of motors in the DC motor gearbox.gearing
- The gearing of the DC motor (numbers greater than 1 represent reductions).
-
DCMotorSim
public DCMotorSim(LinearSystem<N2,N1,N2> plant, DCMotor gearbox, double gearing, Matrix<N2,N1> measurementStdDevs)Creates a simulated DC motor mechanism.- Parameters:
plant
- The linear system representing the DC motor. This system can be created withgearbox
- The type of and number of motors in the DC motor gearbox.gearing
- The gearing of the DC motor (numbers greater than 1 represent reductions).measurementStdDevs
- The standard deviations of the measurements.
-
DCMotorSim
Creates a simulated DC motor mechanism.- Parameters:
gearbox
- The type of and number of motors in the DC motor gearbox.gearing
- The gearing of the DC motor (numbers greater than 1 represent reductions).jKgMetersSquared
- The moment of inertia of the DC motor. If this is unknown, use theDCMotorSim(LinearSystem, DCMotor, double, Matrix)
constructor.
-
DCMotorSim
public DCMotorSim(DCMotor gearbox, double gearing, double jKgMetersSquared, Matrix<N2,N1> measurementStdDevs)Creates a simulated DC motor mechanism.- Parameters:
gearbox
- The type of and number of motors in the DC motor gearbox.gearing
- The gearing of the DC motor (numbers greater than 1 represent reductions).jKgMetersSquared
- The moment of inertia of the DC motor. If this is unknown, use theDCMotorSim(LinearSystem, DCMotor, double, Matrix)
constructor.measurementStdDevs
- The standard deviations of the measurements.
-
-
Method Details
-
setState
Sets the state of the DC motor.- Parameters:
angularPositionRad
- The new position in radians.angularVelocityRadPerSec
- The new velocity in radians per second.
-
getAngularPositionRad
Returns the DC motor position.- Returns:
- The DC motor position.
-
getAngularPositionRotations
Returns the DC motor position in rotations.- Returns:
- The DC motor position in rotations.
-
getAngularVelocityRadPerSec
Returns the DC motor velocity.- Returns:
- The DC motor velocity.
-
getAngularVelocityRPM
Returns the DC motor velocity in RPM.- Returns:
- The DC motor velocity in RPM.
-
getCurrentDrawAmps
Returns the DC motor current draw.- Overrides:
getCurrentDrawAmps
in classLinearSystemSim<N2,N1,N2>
- Returns:
- The DC motor current draw.
-
setInputVoltage
Sets the input voltage for the DC motor.- Parameters:
volts
- The input voltage.
-