9#include <units/length.h>
10#include <units/mass.h>
11#include <units/velocity.h>
22 template <
typename Distance>
24 units::compound_unit<Distance, units::inverse<units::seconds>>>;
26 template <
typename Distance>
28 units::compound_unit<Distance, units::inverse<units::seconds>>,
29 units::inverse<units::seconds>>>;
46 units::meter_t minHeight, units::meter_t maxHeight,
47 bool simulateGravity, units::meter_t startingHeight,
48 const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
67 units::kilogram_t carriageMass, units::meter_t drumRadius,
68 units::meter_t minHeight, units::meter_t maxHeight,
69 bool simulateGravity, units::meter_t startingHeight,
70 const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
85 template <
typename Distance>
86 requires std::same_as<units::meter, Distance> ||
87 std::same_as<units::radian, Distance>
90 const DCMotor& gearbox, units::meter_t minHeight,
91 units::meter_t maxHeight,
bool simulateGravity,
92 units::meter_t startingHeight,
93 const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
102 void SetState(units::meter_t position, units::meters_per_second_t velocity);
171 units::second_t dt)
override;
175 units::meter_t m_minHeight;
176 units::meter_t m_maxHeight;
177 bool m_simulateGravity;
Holds the constants for a DC motor.
Definition DCMotor.h:20
A plant defined using state-space notation.
Definition LinearSystem.h:35
Represents a simulated elevator mechanism.
Definition ElevatorSim.h:20
bool HasHitUpperLimit() const
Returns whether the elevator has hit the upper limit.
units::meters_per_second_t GetVelocity() const
Returns the velocity of the elevator.
void SetInputVoltage(units::volt_t voltage)
Sets the input voltage for the elevator.
units::unit_t< units::compound_unit< units::compound_unit< Distance, units::inverse< units::seconds > >, units::inverse< units::seconds > > > Acceleration_t
Definition ElevatorSim.h:27
units::unit_t< units::compound_unit< Distance, units::inverse< units::seconds > > > Velocity_t
Definition ElevatorSim.h:23
units::ampere_t GetCurrentDraw() const
Returns the elevator current draw.
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.
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.
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.
Vectord< 2 > UpdateX(const Vectord< 2 > ¤tXhat, const Vectord< 1 > &u, units::second_t dt) override
Updates the state estimate of the elevator.
units::meter_t GetPosition() const
Returns the position of the elevator.
bool WouldHitLowerLimit(units::meter_t elevatorHeight) const
Returns whether the elevator would hit the lower limit.
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.
This class helps simulate linear systems.
Definition LinearSystemSim.h:30
void SetState(const Vectord< States > &state)
Sets the system state.
Definition LinearSystemSim.h:118
Eigen::Vector< double, Size > Vectord
Definition EigenCore.h:12