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
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
ConstructorDescriptionDCMotorSim
(LinearSystem<N2, N1, N2> plant, DCMotor gearbox, double... measurementStdDevs) Creates a simulated DC motor mechanism. -
Method Summary
Modifier and TypeMethodDescriptionReturns the DC motor's acceleration.double
Returns the DC motor's acceleration in Radians Per Second Squared.Returns the DC motor's position.double
Returns the DC motor's position.double
Returns the DC motor's position in rotations.Returns the DC motor's velocity.double
Returns the DC motor's velocity.double
Returns the DC motor's velocity in RPM.double
Returns the DC motor's current draw.Returns the gearbox for the DC motor.double
Returns the gear ratio of the DC motor.double
Gets the input voltage for the DC motor.double
Returns the moment of inertia of the DC motor.double
Returns the DC motor's torque in Newton-Meters.void
setAngle
(double angularPositionRad) Sets the DC motor's angular position.void
setAngularVelocity
(double angularVelocityRadPerSec) Sets the DC motor's angular velocity.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.
-
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)
orLinearSystemId.createDCMotorSystem(double, double)
. IfLinearSystemId.createDCMotorSystem(double, double)
is used, the distance unit must be radians.gearbox
- The type of and number of motors in the DC motor gearbox.measurementStdDevs
- The standard deviations of the measurements. Can be omitted if no noise is desired. If present must have 2 elements. The first element is for position. The second element is for velocity.
-
-
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.
-
setAngle
Sets the DC motor's angular position.- Parameters:
angularPositionRad
- The new position in radians.
-
setAngularVelocity
Sets the DC motor's angular velocity.- Parameters:
angularVelocityRadPerSec
- The new velocity in radians per second.
-
getGearing
Returns the gear ratio of the DC motor.- Returns:
- the DC motor's gear ratio.
-
getJKgMetersSquared
Returns the moment of inertia of the DC motor.- Returns:
- The DC motor's moment of inertia.
-
getGearbox
Returns the gearbox for the DC motor.- Returns:
- The DC motor's gearbox.
-
getAngularPositionRad
Returns the DC motor's position.- Returns:
- The DC motor's position.
-
getAngularPositionRotations
Returns the DC motor's position in rotations.- Returns:
- The DC motor's position in rotations.
-
getAngularPosition
Returns the DC motor's position.- Returns:
- The DC motor's position
-
getAngularVelocityRadPerSec
Returns the DC motor's velocity.- Returns:
- The DC motor's velocity.
-
getAngularVelocityRPM
Returns the DC motor's velocity in RPM.- Returns:
- The DC motor's velocity in RPM.
-
getAngularVelocity
Returns the DC motor's velocity.- Returns:
- The DC motor's velocity
-
getAngularAccelerationRadPerSecSq
Returns the DC motor's acceleration in Radians Per Second Squared.- Returns:
- The DC motor's acceleration in Radians Per Second Squared.
-
getAngularAcceleration
Returns the DC motor's acceleration.- Returns:
- The DC motor's acceleration.
-
getTorqueNewtonMeters
Returns the DC motor's torque in Newton-Meters.- Returns:
- The DC motor's torque in Newton-Meters.
-
getCurrentDrawAmps
Returns the DC motor's current draw.- Returns:
- The DC motor's current draw.
-
getInputVoltage
Gets the input voltage for the DC motor.- Returns:
- The DC motor's input voltage.
-
setInputVoltage
Sets the input voltage for the DC motor.- Parameters:
volts
- The input voltage.
-