YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
ElevatorSimSupplier.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Yet Another Software Suite
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <functional>
7#include <wpi/math/filter/LinearFilter.hpp>
8#include <wpi/simulation/ElevatorSim.hpp>
9#include <wpi/units/angle.hpp>
10#include <wpi/units/angular_acceleration.hpp>
11#include <wpi/units/angular_velocity.hpp>
12#include <wpi/units/current.hpp>
13#include <wpi/units/length.hpp>
14#include <wpi/units/time.hpp>
15#include <wpi/units/velocity.hpp>
16#include <wpi/units/voltage.hpp>
17
21
22namespace yams::motorcontrollers {
23class SmartMotorController;
24} // namespace yams::motorcontrollers
25
27
37 public:
47 ElevatorSimSupplier(wpi::sim::ElevatorSim& sim, SmartMotorController& smc);
48
49 void UpdateSim() override;
50 bool GetUpdatedSim() override;
51 void FeedUpdateSim() override;
52 void StarveUpdateSim() override;
53 bool IsInputFed() override;
54 void FeedInput() override;
55 void StarveInput() override;
56 void SetMechanismStatorDutyCycle(double dutyCycle) override;
57 wpi::units::volt_t GetMechanismSupplyVoltage() override;
58 wpi::units::volt_t GetMechanismStatorVoltage() override;
59 void SetMechanismStatorVoltage(wpi::units::volt_t volts) override;
60
61 wpi::units::turn_t GetMechanismPosition() override;
62 wpi::units::turns_per_second_t GetMechanismVelocity() override;
63 wpi::units::turns_per_second_squared_t GetMechanismAcceleration() override;
64 wpi::units::turn_t GetRotorPosition() override;
65 wpi::units::turns_per_second_t GetRotorVelocity() override;
66 wpi::units::turns_per_second_squared_t GetRotorAcceleration() override;
67
68 void SetMechanismPosition(wpi::units::turn_t angle) override;
69 void SetMechanismVelocity(wpi::units::turns_per_second_t velocity) override;
70 void SetRotorPosition(wpi::units::turn_t angle) override;
71 void SetRotorVelocity(wpi::units::turns_per_second_t velocity) override;
72
73 wpi::units::ampere_t GetStatorCurrent() override;
74 wpi::units::ampere_t GetSupplyCurrent() override;
75
76 private:
77 wpi::sim::ElevatorSim& m_sim;
78 std::function<double()> m_dutyCycleSupplier;
80 wpi::units::second_t m_period;
81 const void* m_batteryKey;
82 wpi::math::LinearFilter<double> m_supplyCurrentFilter;
83 bool m_inputFed{false};
84 bool m_simUpdated{false};
85 wpi::units::volt_t m_lastInputVoltage{0};
86 math::DerivativeTimeFilter m_rotorAccelFilter;
87 wpi::units::meter_t m_circumference;
88};
89
90} // namespace yams::motorcontrollers::simulation
Definition MechanismGearing.hpp:19
Definition DerivativeTimeFilter.hpp:18
Definition SimSupplier.hpp:22
Definition SmartMotorController.hpp:48
Definition ElevatorSimSupplier.hpp:36
wpi::units::turns_per_second_t GetMechanismVelocity() override
wpi::units::volt_t GetMechanismStatorVoltage() override
void SetMechanismStatorVoltage(wpi::units::volt_t volts) override
void SetRotorVelocity(wpi::units::turns_per_second_t velocity) override
wpi::units::turns_per_second_t GetRotorVelocity() override
void SetMechanismStatorDutyCycle(double dutyCycle) override
void SetMechanismVelocity(wpi::units::turns_per_second_t velocity) override
wpi::units::volt_t GetMechanismSupplyVoltage() override
ElevatorSimSupplier(wpi::sim::ElevatorSim &sim, SmartMotorController &smc)
void SetRotorPosition(wpi::units::turn_t angle) override
void SetMechanismPosition(wpi::units::turn_t angle) override
wpi::units::turns_per_second_squared_t GetRotorAcceleration() override
wpi::units::turns_per_second_squared_t GetMechanismAcceleration() override
Definition SimSensorConfig.hpp:15
Definition SimSensorConfig.hpp:15