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


Public Member Functions | |
| DCMotorSimSupplier (wpi::sim::DCMotorSim &sim, SmartMotorController &smc) | |
| 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 |
| wpi::units::turns_per_second_t | GetMechanismVelocity () override |
| wpi::units::turns_per_second_squared_t | GetMechanismAcceleration () override |
| wpi::units::turn_t | GetRotorPosition () override |
| wpi::units::turns_per_second_t | GetRotorVelocity () override |
| wpi::units::turns_per_second_squared_t | GetRotorAcceleration () override |
| void | SetMechanismPosition (wpi::units::turn_t angle) override |
| void | SetMechanismVelocity (wpi::units::turns_per_second_t velocity) 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 |
SimSupplier backed by a WPILib DCMotorSim.
Suitable for flywheel- and pivot-style mechanisms that use a simple DC motor physics model. The duty cycle is read from the motor controller each iteration unless an input voltage has been fed this loop.
| yams::motorcontrollers::simulation::DCMotorSimSupplier::DCMotorSimSupplier | ( | wpi::sim::DCMotorSim & | sim, |
| SmartMotorController & | smc | ||
| ) |
Create a DCMotorSimSupplier.
The duty cycle, gearing, simulation period and DC motor are read from smc and its config. The supplier's current draw is tracked in BatterySim under smc.
| sim | WPILib simulation to advance each loop (must outlive this supplier). |
| smc | SmartMotorController driving the simulation (must outlive this supplier). |
|
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.
|
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.
|
overridevirtual |
Set the simulated mechanism position.
| angle | Mechanism position to inject. |
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Apply a duty cycle of the supply voltage as the motor input (feeds the input).
| dutyCycle | Duty cycle in [-1, 1]. |
Implements yams::motorcontrollers::SimSupplier.
|
overridevirtual |
Set the motor input voltage directly, e.g. from a hardware sim state (feeds the input).
| volts | Voltage to apply. |
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.