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.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 that represents the DC motor.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 that represents the DC motor.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).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
-
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.
-