![]() |
WPILibC++ 2025.3.2
|
Represents a simulated elevator mechanism. More...
#include <frc/simulation/ElevatorSim.h>
Public Types | |
| template<typename Distance > | |
| using | Velocity_t |
| template<typename Distance > | |
| using | Acceleration_t |
Public Member Functions | |
| ElevatorSim (const LinearSystem< 2, 1, 2 > &plant, const DCMotor &gearbox, units::meter_t minHeight, units::meter_t maxHeight, bool simulateGravity, units::meter_t startingHeight, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0}) | |
| Constructs a simulated elevator mechanism. | |
| ElevatorSim (const DCMotor &gearbox, double gearing, units::kilogram_t carriageMass, units::meter_t drumRadius, units::meter_t minHeight, units::meter_t maxHeight, bool simulateGravity, units::meter_t startingHeight, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0}) | |
| Constructs a simulated elevator mechanism. | |
| template<typename Distance > requires std::same_as<units::meter, Distance> || std::same_as<units::radian, Distance> | |
| ElevatorSim (decltype(1_V/Velocity_t< Distance >(1)) kV, decltype(1_V/Acceleration_t< Distance >(1)) kA, const DCMotor &gearbox, units::meter_t minHeight, units::meter_t maxHeight, bool simulateGravity, units::meter_t startingHeight, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0}) | |
| Constructs a simulated elevator mechanism. | |
| void | SetState (units::meter_t position, units::meters_per_second_t velocity) |
| Sets the elevator's state. | |
| bool | WouldHitLowerLimit (units::meter_t elevatorHeight) const |
| Returns whether the elevator would hit the lower limit. | |
| bool | WouldHitUpperLimit (units::meter_t elevatorHeight) const |
| Returns whether the elevator would hit the upper limit. | |
| bool | HasHitLowerLimit () const |
| Returns whether the elevator has hit the lower limit. | |
| bool | HasHitUpperLimit () const |
| Returns whether the elevator has hit the upper limit. | |
| units::meter_t | GetPosition () const |
| Returns the position of the elevator. | |
| units::meters_per_second_t | GetVelocity () const |
| Returns the velocity of the elevator. | |
| units::ampere_t | GetCurrentDraw () const |
| Returns the elevator current draw. | |
| void | SetInputVoltage (units::volt_t voltage) |
| Sets the input voltage for the elevator. | |
| 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. | |
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 elevator. | |
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 elevator mechanism.
| using frc::sim::ElevatorSim::Acceleration_t |
| using frc::sim::ElevatorSim::Velocity_t |
| frc::sim::ElevatorSim::ElevatorSim | ( | const LinearSystem< 2, 1, 2 > & | plant, |
| const DCMotor & | gearbox, | ||
| units::meter_t | minHeight, | ||
| units::meter_t | maxHeight, | ||
| bool | simulateGravity, | ||
| units::meter_t | startingHeight, | ||
| const std::array< double, 2 > & | measurementStdDevs = {0.0, 0.0} ) |
Constructs a simulated elevator mechanism.
| plant | The linear system that represents the elevator. This system can be created with LinearSystemId::ElevatorSystem(). |
| gearbox | The type of and number of motors in your elevator gearbox. |
| minHeight | The minimum allowed height of the elevator. |
| maxHeight | The maximum allowed height of the elevator. |
| simulateGravity | Whether gravity should be simulated or not. |
| startingHeight | The starting height of the elevator. |
| measurementStdDevs | The standard deviation of the measurements. |
| frc::sim::ElevatorSim::ElevatorSim | ( | const DCMotor & | gearbox, |
| double | gearing, | ||
| units::kilogram_t | carriageMass, | ||
| units::meter_t | drumRadius, | ||
| units::meter_t | minHeight, | ||
| units::meter_t | maxHeight, | ||
| bool | simulateGravity, | ||
| units::meter_t | startingHeight, | ||
| const std::array< double, 2 > & | measurementStdDevs = {0.0, 0.0} ) |
Constructs a simulated elevator mechanism.
| gearbox | The type of and number of motors in your elevator gearbox. |
| gearing | The gearing of the elevator (numbers greater than 1 represent reductions). |
| carriageMass | The mass of the elevator carriage. |
| drumRadius | The radius of the drum that your cable is wrapped around. |
| minHeight | The minimum allowed height of the elevator. |
| maxHeight | The maximum allowed height of the elevator. |
| simulateGravity | Whether gravity should be simulated or not. |
| startingHeight | The starting height of the elevator. |
| measurementStdDevs | The standard deviation of the measurements. |
| frc::sim::ElevatorSim::ElevatorSim | ( | decltype(1_V/Velocity_t< Distance >(1)) | kV, |
| decltype(1_V/Acceleration_t< Distance >(1)) | kA, | ||
| const DCMotor & | gearbox, | ||
| units::meter_t | minHeight, | ||
| units::meter_t | maxHeight, | ||
| bool | simulateGravity, | ||
| units::meter_t | startingHeight, | ||
| const std::array< double, 2 > & | measurementStdDevs = {0.0, 0.0} ) |
Constructs a simulated elevator mechanism.
| kV | The velocity gain. |
| kA | The acceleration gain. |
| gearbox | The type of and number of motors in your elevator gearbox. |
| minHeight | The minimum allowed height of the elevator. |
| maxHeight | The maximum allowed height of the elevator. |
| simulateGravity | Whether gravity should be simulated or not. |
| startingHeight | The starting height of the elevator. |
| measurementStdDevs | The standard deviation of the measurements. |
| units::ampere_t frc::sim::ElevatorSim::GetCurrentDraw | ( | ) | const |
Returns the elevator current draw.
| units::meter_t frc::sim::ElevatorSim::GetPosition | ( | ) | const |
Returns the position of the elevator.
| units::meters_per_second_t frc::sim::ElevatorSim::GetVelocity | ( | ) | const |
Returns the velocity of the elevator.
| bool frc::sim::ElevatorSim::HasHitLowerLimit | ( | ) | const |
Returns whether the elevator has hit the lower limit.
| bool frc::sim::ElevatorSim::HasHitUpperLimit | ( | ) | const |
Returns whether the elevator has hit the upper limit.
| void frc::sim::ElevatorSim::SetInputVoltage | ( | units::volt_t | voltage | ) |
Sets the input voltage for the elevator.
| voltage | The input voltage. |
|
inline |
Sets the system state.
| state | The new state. |
| void frc::sim::ElevatorSim::SetState | ( | units::meter_t | position, |
| units::meters_per_second_t | velocity ) |
Sets the elevator's state.
The new position will be limited between the minimum and maximum allowed heights.
| position | The new position |
| velocity | The new velocity |
|
overrideprotected |
Updates the state estimate of the elevator.
| currentXhat | The current state estimate. |
| u | The system inputs (voltage). |
| dt | The time difference between controller updates. |
| bool frc::sim::ElevatorSim::WouldHitLowerLimit | ( | units::meter_t | elevatorHeight | ) | const |
Returns whether the elevator would hit the lower limit.
| elevatorHeight | The elevator height. |
| bool frc::sim::ElevatorSim::WouldHitUpperLimit | ( | units::meter_t | elevatorHeight | ) | const |
Returns whether the elevator would hit the upper limit.
| elevatorHeight | The elevator height. |