|
YAMS
Yet Another Mechanism System
|
#include <NovaSimSupplier.hpp>


Public Member Functions | |
| NovaSimSupplier (std::shared_ptr< SimSupplier > mechanism, thrifty::Nova &nova, wpi::units::second_t period) | |
| void | SetControlRequest (const thrifty::MotorControlRequest &request) |
| const std::optional< thrifty::MotorControlRequest > & | GetControlRequest () const |
| double | GetDutyCycle () const |
| void | UpdateSim () override |
| bool | GetUpdatedSim () override |
| void | FeedUpdateSim () override |
| void | StarveUpdateSim () override |
| bool | IsInputFed () override |
| void | FeedInput () override |
| void | StarveInput () override |
| void | SetMechanismStatorDutyCycle (double dutyCycle) override |
| wpi::units::volt_t | GetMechanismSupplyVoltage () override |
| wpi::units::volt_t | GetMechanismStatorVoltage () override |
| void | SetMechanismStatorVoltage (wpi::units::volt_t volts) override |
| wpi::units::turn_t | GetMechanismPosition () override |
| void | SetMechanismPosition (wpi::units::turn_t angle) override |
| wpi::units::turn_t | GetRotorPosition () override |
| wpi::units::turns_per_second_t | GetMechanismVelocity () override |
| void | SetMechanismVelocity (wpi::units::turns_per_second_t velocity) override |
| wpi::units::turns_per_second_t | GetRotorVelocity () override |
| wpi::units::turns_per_second_squared_t | GetMechanismAcceleration () override |
| wpi::units::turns_per_second_squared_t | GetRotorAcceleration () override |
| void | SetRotorPosition (wpi::units::turn_t angle) override |
| void | SetRotorVelocity (wpi::units::turns_per_second_t velocity) override |
| wpi::units::ampere_t | GetStatorCurrent () override |
| wpi::units::ampere_t | GetSupplyCurrent () override |
| Public Member Functions inherited from yams::motorcontrollers::SimSupplier | |
| virtual | ~SimSupplier ()=default |
A simulated Thrifty Nova driving a mechanism's SimSupplier. ThriftyLib's simulation ignores the Nova's closed loop, so this runs it as the Nova would, with the gains read back from the Nova: the voltage position and velocity loops with the PID slot's gains and its F times the target, and the motion profile with its slot's kS, kV, kA and kG. It keeps within the Nova's soft limits, and, with its absolute wrapping on, takes a position the short way, one mechanism rotation apart. Targets and gains are in mechanism rotations, as on a Nova with its sensor-to-mechanism ratio set, and the integral and derivative gains are per second, as the Nova's are. Open loop output, a duty cycle or a voltage, is passed on to the mechanism.
| yams::motorcontrollers::simulation::NovaSimSupplier::NovaSimSupplier | ( | std::shared_ptr< SimSupplier > | mechanism, |
| thrifty::Nova & | nova, | ||
| wpi::units::second_t | period ) |
Create a simulated Nova.
| mechanism | Mechanism the Nova drives. |
| nova | Nova whose gains are simulated. |
| period | Simulation period. |
|
overridevirtual |
Mark the input as supplied directly for this loop.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Mark the simulation as stepped for this loop.
Implements yams::motorcontrollers::SimSupplier.
| const std::optional< thrifty::MotorControlRequest > & yams::motorcontrollers::simulation::NovaSimSupplier::GetControlRequest | ( | ) | const |
| double yams::motorcontrollers::simulation::NovaSimSupplier::GetDutyCycle | ( | ) | const |
|
overridevirtual |
Get the simulated mechanism angular acceleration.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the simulated mechanism position.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the voltage applied to the simulated motor.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the supply voltage available to the simulated motor controller (bus voltage).
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the simulated mechanism velocity.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the simulated rotor angular acceleration.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the simulated rotor position.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the simulated rotor velocity.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the simulated stator (motor) current.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Get the simulated supply (battery) current: duty cycle times stator current, filtered by a 0.1 s single-pole IIR filter.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Whether the simulation has already been stepped this loop.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Whether an input voltage was supplied directly this loop (e.g. from a hardware sim state).
Implements yams::motorcontrollers::SimSupplier.
| void yams::motorcontrollers::simulation::NovaSimSupplier::SetControlRequest | ( | const thrifty::MotorControlRequest & | request | ) |
Run a closed loop control request, as the Nova does when it is sent one. The integral, and the motion profile, carry on while requests of the same type are sent.
| request | Voltage position, voltage velocity or motion profile request. |
|
overridevirtual |
Set the simulated mechanism position.
| angle | Mechanism position to inject. |
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Open loop: the Nova stops its closed loop.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Open loop: the Nova stops its closed loop.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Set the simulated mechanism velocity.
| velocity | Mechanism velocity to inject. |
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Set the simulated rotor position.
| angle | Rotor position to inject. |
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Set the simulated rotor velocity.
| velocity | Rotor velocity to inject. |
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Clear the input-fed flag so UpdateSim() falls back to the duty-cycle supplier.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Clear the stepped flag so the next UpdateSim() steps the physics again.
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Advance the simulation by one loop iteration.
When the input has not been fed this loop (see FeedInput()), the motor duty cycle times the supply voltage is applied as the input and the battery voltage is updated. The physics are only stepped if the simulation has not already been updated this loop (see GetUpdatedSim()); stepping marks it updated, so a mechanism and its motor controller calling UpdateSim() in the same loop step the physics once.
Implements yams::motorcontrollers::SimSupplier.