![]() |
WPILibC++ 2025.3.2
|
Represents a simulated arm mechanism. More...
#include <frc/simulation/SingleJointedArmSim.h>
Public Member Functions | |
| SingleJointedArmSim (const LinearSystem< 2, 1, 2 > &system, const DCMotor &gearbox, double gearing, units::meter_t armLength, units::radian_t minAngle, units::radian_t maxAngle, bool simulateGravity, units::radian_t startingAngle, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0}) | |
| Creates a simulated arm mechanism. | |
| SingleJointedArmSim (const DCMotor &gearbox, double gearing, units::kilogram_square_meter_t moi, units::meter_t armLength, units::radian_t minAngle, units::radian_t maxAngle, bool simulateGravity, units::radian_t startingAngle, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0}) | |
| Creates a simulated arm mechanism. | |
| void | SetState (units::radian_t angle, units::radians_per_second_t velocity) |
| Sets the arm's state. | |
| bool | WouldHitLowerLimit (units::radian_t armAngle) const |
| Returns whether the arm would hit the lower limit. | |
| bool | WouldHitUpperLimit (units::radian_t armAngle) const |
| Returns whether the arm would hit the upper limit. | |
| bool | HasHitLowerLimit () const |
| Returns whether the arm has hit the lower limit. | |
| bool | HasHitUpperLimit () const |
| Returns whether the arm has hit the upper limit. | |
| units::radian_t | GetAngle () const |
| Returns the current arm angle. | |
| units::radians_per_second_t | GetVelocity () const |
| Returns the current arm velocity. | |
| units::ampere_t | GetCurrentDraw () const |
| Returns the arm current draw. | |
| void | SetInputVoltage (units::volt_t voltage) |
| Sets the input voltage for the arm. | |
| void | SetState (const Vectord< States > &state) |
| Sets the system state. | |
Public Member Functions inherited from frc::sim::LinearSystemSim< 2, 1, 2 > | |
| LinearSystemSim (const LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={}) | |
| Creates a simulated generic linear system. | |
| virtual | ~LinearSystemSim ()=default |
| void | Update (units::second_t dt) |
| Updates the simulation. | |
| const Vectord< Outputs > & | GetOutput () const |
| Returns the current output of the plant. | |
| double | GetOutput (int row) const |
| Returns an element of the current output of the plant. | |
| void | SetInput (const Vectord< Inputs > &u) |
| Sets the system inputs (usually voltages). | |
| void | SetInput (int row, double value) |
| Sets the system inputs. | |
| const Vectord< Inputs > & | GetInput () const |
| Returns the current input of the plant. | |
| double | GetInput (int row) const |
| Returns an element of the current input of the plant. | |
| void | SetState (const Vectord< States > &state) |
| Sets the system state. | |
Static Public Member Functions | |
| static constexpr units::kilogram_square_meter_t | EstimateMOI (units::meter_t length, units::kilogram_t mass) |
| Calculates a rough estimate of the moment of inertia of an arm given its length and mass. | |
Protected Member Functions | |
| Vectord< 2 > | UpdateX (const Vectord< 2 > ¤tXhat, const Vectord< 1 > &u, units::second_t dt) override |
| Updates the state estimate of the arm. | |
Protected Member Functions inherited from frc::sim::LinearSystemSim< 2, 1, 2 > | |
| virtual Vectord< States > | UpdateX (const Vectord< States > ¤tXhat, const Vectord< Inputs > &u, units::second_t dt) |
| Updates the state estimate of the system. | |
| void | ClampInput (double maxInput) |
| Clamp the input vector such that no element exceeds the given voltage. | |
Additional Inherited Members | |
Protected Attributes inherited from frc::sim::LinearSystemSim< 2, 1, 2 > | |
| LinearSystem< States, Inputs, Outputs > | m_plant |
| The plant that represents the linear system. | |
| Vectord< States > | m_x |
| State vector. | |
| Vectord< Inputs > | m_u |
| Input vector. | |
| Vectord< Outputs > | m_y |
| Output vector. | |
| std::array< double, Outputs > | m_measurementStdDevs |
| The standard deviations of measurements, used for adding noise to the measurements. | |
Represents a simulated arm mechanism.
| frc::sim::SingleJointedArmSim::SingleJointedArmSim | ( | const LinearSystem< 2, 1, 2 > & | system, |
| const DCMotor & | gearbox, | ||
| double | gearing, | ||
| units::meter_t | armLength, | ||
| units::radian_t | minAngle, | ||
| units::radian_t | maxAngle, | ||
| bool | simulateGravity, | ||
| units::radian_t | startingAngle, | ||
| const std::array< double, 2 > & | measurementStdDevs = {0.0, 0.0} ) |
Creates a simulated arm mechanism.
| system | The system representing this arm. This system can be created with LinearSystemId::SingleJointedArmSystem(). |
| gearbox | The type and number of motors on the arm gearbox. |
| gearing | The gear ratio of the arm (numbers greater than 1 represent reductions). |
| armLength | The length of the arm. |
| minAngle | The minimum angle that the arm is capable of. |
| maxAngle | The maximum angle that the arm is capable of. |
| simulateGravity | Whether gravity should be simulated or not. |
| startingAngle | The initial position of the arm. |
| measurementStdDevs | The standard deviations of the measurements. |
| frc::sim::SingleJointedArmSim::SingleJointedArmSim | ( | const DCMotor & | gearbox, |
| double | gearing, | ||
| units::kilogram_square_meter_t | moi, | ||
| units::meter_t | armLength, | ||
| units::radian_t | minAngle, | ||
| units::radian_t | maxAngle, | ||
| bool | simulateGravity, | ||
| units::radian_t | startingAngle, | ||
| const std::array< double, 2 > & | measurementStdDevs = {0.0, 0.0} ) |
Creates a simulated arm mechanism.
| gearbox | The type and number of motors on the arm gearbox. |
| gearing | The gear ratio of the arm (numbers greater than 1 represent reductions). |
| moi | The moment of inertia of the arm. This can be calculated from CAD software. |
| armLength | The length of the arm. |
| minAngle | The minimum angle that the arm is capable of. |
| maxAngle | The maximum angle that the arm is capable of. |
| simulateGravity | Whether gravity should be simulated or not. |
| startingAngle | The initial position of the arm. |
| measurementStdDevs | The standard deviation of the measurement noise. |
|
inlinestaticconstexpr |
Calculates a rough estimate of the moment of inertia of an arm given its length and mass.
| length | The length of the arm. |
| mass | The mass of the arm. |
| units::radian_t frc::sim::SingleJointedArmSim::GetAngle | ( | ) | const |
Returns the current arm angle.
| units::ampere_t frc::sim::SingleJointedArmSim::GetCurrentDraw | ( | ) | const |
Returns the arm current draw.
| units::radians_per_second_t frc::sim::SingleJointedArmSim::GetVelocity | ( | ) | const |
Returns the current arm velocity.
| bool frc::sim::SingleJointedArmSim::HasHitLowerLimit | ( | ) | const |
Returns whether the arm has hit the lower limit.
| bool frc::sim::SingleJointedArmSim::HasHitUpperLimit | ( | ) | const |
Returns whether the arm has hit the upper limit.
| void frc::sim::SingleJointedArmSim::SetInputVoltage | ( | units::volt_t | voltage | ) |
Sets the input voltage for the arm.
| voltage | The input voltage. |
|
inline |
Sets the system state.
| state | The new state. |
| void frc::sim::SingleJointedArmSim::SetState | ( | units::radian_t | angle, |
| units::radians_per_second_t | velocity ) |
Sets the arm's state.
The new angle will be limited between the minimum and maximum allowed limits.
| angle | The new angle. |
| velocity | The new angular velocity. |
|
overrideprotected |
Updates the state estimate of the arm.
| currentXhat | The current state estimate. |
| u | The system inputs (voltage). |
| dt | The time difference between controller updates. |
| bool frc::sim::SingleJointedArmSim::WouldHitLowerLimit | ( | units::radian_t | armAngle | ) | const |
Returns whether the arm would hit the lower limit.
| armAngle | The arm height. |
| bool frc::sim::SingleJointedArmSim::WouldHitUpperLimit | ( | units::radian_t | armAngle | ) | const |
Returns whether the arm would hit the upper limit.
| armAngle | The arm height. |