YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
NovaSimSupplier.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 <thrifty/core/MotorControlRequest.h>
7#include <thrifty/nova/Nova.h>
8
9#include <memory>
10#include <optional>
11#include <wpi/math/trajectory/TrapezoidProfile.hpp>
12#include <wpi/units/time.hpp>
13
15
17
29 public:
37 NovaSimSupplier(std::shared_ptr<SimSupplier> mechanism, thrifty::Nova& nova,
38 wpi::units::second_t period);
39
46 void SetControlRequest(const thrifty::MotorControlRequest& request);
47
49 const std::optional<thrifty::MotorControlRequest>& GetControlRequest() const;
50
52 double GetDutyCycle() const;
53
54 void UpdateSim() override;
55 bool GetUpdatedSim() override;
56 void FeedUpdateSim() override;
57 void StarveUpdateSim() override;
58 bool IsInputFed() override;
59 void FeedInput() override;
60 void StarveInput() override;
62 void SetMechanismStatorDutyCycle(double dutyCycle) override;
63 wpi::units::volt_t GetMechanismSupplyVoltage() override;
64 wpi::units::volt_t GetMechanismStatorVoltage() override;
66 void SetMechanismStatorVoltage(wpi::units::volt_t volts) override;
67 wpi::units::turn_t GetMechanismPosition() override;
68 void SetMechanismPosition(wpi::units::turn_t angle) override;
69 wpi::units::turn_t GetRotorPosition() override;
70 wpi::units::turns_per_second_t GetMechanismVelocity() override;
71 void SetMechanismVelocity(wpi::units::turns_per_second_t velocity) override;
72 wpi::units::turns_per_second_t GetRotorVelocity() override;
73 wpi::units::turns_per_second_squared_t GetMechanismAcceleration() override;
74 wpi::units::turns_per_second_squared_t GetRotorAcceleration() override;
75 void SetRotorPosition(wpi::units::turn_t angle) override;
76 void SetRotorVelocity(wpi::units::turns_per_second_t velocity) override;
77 wpi::units::ampere_t GetStatorCurrent() override;
78 wpi::units::ampere_t GetSupplyCurrent() override;
79
80 private:
82 void ApplyVoltage(double volts);
83
84 std::shared_ptr<SimSupplier> m_mechanism;
85 thrifty::Nova& m_nova;
86 double m_periodSeconds;
87 std::optional<thrifty::MotorControlRequest> m_request;
88 double m_dutyCycle{0.0};
90 double m_integral{0.0};
92 std::optional<double> m_lastError;
94 std::optional<wpi::math::TrapezoidProfile<wpi::units::turns>::State> m_profileState;
95};
96
97} // namespace yams::motorcontrollers::simulation
Definition SimSupplier.hpp:22
wpi::units::turns_per_second_squared_t GetRotorAcceleration() override
const std::optional< thrifty::MotorControlRequest > & GetControlRequest() const
wpi::units::ampere_t GetSupplyCurrent() override
void SetRotorVelocity(wpi::units::turns_per_second_t velocity) override
NovaSimSupplier(std::shared_ptr< SimSupplier > mechanism, thrifty::Nova &nova, wpi::units::second_t period)
void SetMechanismPosition(wpi::units::turn_t angle) override
void SetMechanismStatorDutyCycle(double dutyCycle) override
wpi::units::turns_per_second_t GetRotorVelocity() override
wpi::units::volt_t GetMechanismSupplyVoltage() override
void SetControlRequest(const thrifty::MotorControlRequest &request)
wpi::units::volt_t GetMechanismStatorVoltage() override
void SetMechanismVelocity(wpi::units::turns_per_second_t velocity) override
void SetRotorPosition(wpi::units::turn_t angle) override
wpi::units::turns_per_second_t GetMechanismVelocity() override
wpi::units::turn_t GetRotorPosition() override
wpi::units::ampere_t GetStatorCurrent() override
void SetMechanismStatorVoltage(wpi::units::volt_t volts) override
wpi::units::turns_per_second_squared_t GetMechanismAcceleration() override
wpi::units::turn_t GetMechanismPosition() override
Definition SimSensorConfig.hpp:15