11#include "wpi/units/length.hpp"
12#include "wpi/units/mass.hpp"
13#include "wpi/units/velocity.hpp"
21 template <
typename Distance>
22 using Velocity_t = wpi::units::unit_t<wpi::units::compound_unit<
23 Distance, wpi::units::inverse<wpi::units::seconds>>>;
25 template <
typename Distance>
27 wpi::units::compound_unit<Distance,
28 wpi::units::inverse<wpi::units::seconds>>,
29 wpi::units::inverse<wpi::units::seconds>>>;
45 wpi::units::meter_t maxHeight,
bool simulateGravity,
46 wpi::units::meter_t startingHeight,
47 const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
64 wpi::units::kilogram_t carriageMass,
65 wpi::units::meter_t drumRadius, wpi::units::meter_t minHeight,
66 wpi::units::meter_t maxHeight,
bool simulateGravity,
67 wpi::units::meter_t startingHeight,
68 const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
82 template <
typename Distance>
83 requires std::same_as<wpi::units::meter, Distance> ||
84 std::same_as<wpi::units::radian, Distance>
88 wpi::units::meter_t maxHeight,
bool simulateGravity,
89 wpi::units::meter_t startingHeight,
90 const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
101 wpi::units::meters_per_second_t velocity);
171 wpi::units::second_t dt)
override;
175 wpi::units::meter_t m_minHeight;
176 wpi::units::meter_t m_maxHeight;
177 bool m_simulateGravity;
Holds the constants for a DC motor.
Definition DCMotor.hpp:19
A plant defined using state-space notation.
Definition LinearSystem.hpp:35
ElevatorSim(const wpi::math::LinearSystem< 2, 1, 2 > &plant, const wpi::math::DCMotor &gearbox, wpi::units::meter_t minHeight, wpi::units::meter_t maxHeight, bool simulateGravity, wpi::units::meter_t startingHeight, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0})
Constructs a simulated elevator mechanism.
wpi::units::ampere_t GetCurrentDraw() const
Returns the elevator current draw.
wpi::math::Vectord< 2 > UpdateX(const wpi::math::Vectord< 2 > ¤tXhat, const wpi::math::Vectord< 1 > &u, wpi::units::second_t dt) override
Updates the state estimate of the elevator.
bool HasHitUpperLimit() const
Returns whether the elevator has hit the upper limit.
bool WouldHitUpperLimit(wpi::units::meter_t elevatorHeight) const
Returns whether the elevator would hit the upper limit.
void SetState(wpi::units::meter_t position, wpi::units::meters_per_second_t velocity)
Sets the elevator's state.
ElevatorSim(decltype(1_V/Velocity_t< Distance >(1)) kV, decltype(1_V/Acceleration_t< Distance >(1)) kA, const wpi::math::DCMotor &gearbox, wpi::units::meter_t minHeight, wpi::units::meter_t maxHeight, bool simulateGravity, wpi::units::meter_t startingHeight, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0})
Constructs a simulated elevator mechanism.
wpi::units::unit_t< wpi::units::compound_unit< wpi::units::compound_unit< Distance, wpi::units::inverse< wpi::units::seconds > >, wpi::units::inverse< wpi::units::seconds > > > Acceleration_t
Definition ElevatorSim.hpp:26
bool HasHitLowerLimit() const
Returns whether the elevator has hit the lower limit.
bool WouldHitLowerLimit(wpi::units::meter_t elevatorHeight) const
Returns whether the elevator would hit the lower limit.
wpi::units::unit_t< wpi::units::compound_unit< Distance, wpi::units::inverse< wpi::units::seconds > > > Velocity_t
Definition ElevatorSim.hpp:22
ElevatorSim(const wpi::math::DCMotor &gearbox, double gearing, wpi::units::kilogram_t carriageMass, wpi::units::meter_t drumRadius, wpi::units::meter_t minHeight, wpi::units::meter_t maxHeight, bool simulateGravity, wpi::units::meter_t startingHeight, const std::array< double, 2 > &measurementStdDevs={0.0, 0.0})
Constructs a simulated elevator mechanism.
wpi::units::meter_t GetPosition() const
Returns the position of the elevator.
wpi::units::meters_per_second_t GetVelocity() const
Returns the velocity of the elevator.
void SetInputVoltage(wpi::units::volt_t voltage)
Sets the input voltage for the elevator.
LinearSystemSim(const wpi::math::LinearSystem< States, Inputs, Outputs > &system, const std::array< double, Outputs > &measurementStdDevs={})
Definition LinearSystemSim.hpp:37
void SetState(const wpi::math::Vectord< States > &state)
Sets the system state.
Definition LinearSystemSim.hpp:117
Eigen::Vector< double, Size > Vectord
Definition EigenCore.hpp:12
Definition CTREPCMSim.hpp:13