YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
yams::motorcontrollers::simulation::FollowerSimSupplier Class Reference

#include <FollowerSimSupplier.hpp>

Inheritance diagram for yams::motorcontrollers::simulation::FollowerSimSupplier:
Collaboration diagram for yams::motorcontrollers::simulation::FollowerSimSupplier:

Public Member Functions

 FollowerSimSupplier (SmartMotorController &leader, SmartMotorController &follower, bool inverted)
void UpdateSim () override
bool GetUpdatedSim () override
void FeedUpdateSim () override
void StarveUpdateSim () override
bool IsInputFed () override
void FeedInput () override
void StarveInput () override
void SetMechanismStatorDutyCycle (double) override
wpi::units::volt_t GetMechanismSupplyVoltage () override
wpi::units::volt_t GetMechanismStatorVoltage () override
void SetMechanismStatorVoltage (wpi::units::volt_t) override
wpi::units::turn_t GetMechanismPosition () override
void SetMechanismPosition (wpi::units::turn_t) override
wpi::units::turn_t GetRotorPosition () override
wpi::units::turns_per_second_t GetMechanismVelocity () override
void SetMechanismVelocity (wpi::units::turns_per_second_t) 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) override
void SetRotorVelocity (wpi::units::turns_per_second_t) override
wpi::units::ampere_t GetStatorCurrent () override
wpi::units::ampere_t GetSupplyCurrent () override
Public Member Functions inherited from yams::motorcontrollers::SimSupplier
virtual ~SimSupplier ()=default

Detailed Description

Simulation of a motor whose leader's simulation has its motor too, such as an A301 following another, or a loosely coupled follower of a mechanism's motor controller.

It reads the leader's simulation, with its rotor values from its own gearing and its share of the current, and does not step a simulation of its own. Its current is in the leader's, so BatterySim does not count it again.

Constructor & Destructor Documentation

◆ FollowerSimSupplier()

yams::motorcontrollers::simulation::FollowerSimSupplier::FollowerSimSupplier ( SmartMotorController & leader,
SmartMotorController & follower,
bool inverted )

Read the simulation of a leader whose motor model has this follower's motor.

Parameters
leaderMotor controller whose simulation has the follower's motor. Must outlive this.
followerMotor controller reading it. Must outlive this.
invertedWhether the follower is inverted from its leader.

Member Function Documentation

◆ FeedInput()

void yams::motorcontrollers::simulation::FollowerSimSupplier::FeedInput ( )
inlineoverridevirtual

Mark the input as supplied directly for this loop.

Implements yams::motorcontrollers::SimSupplier.

◆ FeedUpdateSim()

void yams::motorcontrollers::simulation::FollowerSimSupplier::FeedUpdateSim ( )
inlineoverridevirtual

Mark the simulation as stepped for this loop.

Implements yams::motorcontrollers::SimSupplier.

◆ GetMechanismAcceleration()

wpi::units::turns_per_second_squared_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetMechanismAcceleration ( )
overridevirtual

Get the simulated mechanism angular acceleration.

Returns
Mechanism acceleration in turns per second squared.

Implements yams::motorcontrollers::SimSupplier.

◆ GetMechanismPosition()

wpi::units::turn_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetMechanismPosition ( )
overridevirtual

Get the simulated mechanism position.

Returns
Mechanism position in turns.

Implements yams::motorcontrollers::SimSupplier.

◆ GetMechanismStatorVoltage()

wpi::units::volt_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetMechanismStatorVoltage ( )
overridevirtual

Get the voltage applied to the simulated motor.

Returns
Stator voltage in volts.

Implements yams::motorcontrollers::SimSupplier.

◆ GetMechanismSupplyVoltage()

wpi::units::volt_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetMechanismSupplyVoltage ( )
overridevirtual

Get the supply voltage available to the simulated motor controller (bus voltage).

Returns
Supply voltage in volts.

Implements yams::motorcontrollers::SimSupplier.

◆ GetMechanismVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetMechanismVelocity ( )
overridevirtual

Get the simulated mechanism velocity.

Returns
Mechanism velocity in turns per second.

Implements yams::motorcontrollers::SimSupplier.

◆ GetRotorAcceleration()

wpi::units::turns_per_second_squared_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetRotorAcceleration ( )
overridevirtual

Get the simulated rotor angular acceleration.

Returns
Rotor acceleration in turns per second squared.

Implements yams::motorcontrollers::SimSupplier.

◆ GetRotorPosition()

wpi::units::turn_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetRotorPosition ( )
overridevirtual

Get the simulated rotor position.

Returns
Rotor position in turns.

Implements yams::motorcontrollers::SimSupplier.

◆ GetRotorVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetRotorVelocity ( )
overridevirtual

Get the simulated rotor velocity.

Returns
Rotor velocity in turns per second.

Implements yams::motorcontrollers::SimSupplier.

◆ GetStatorCurrent()

wpi::units::ampere_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetStatorCurrent ( )
overridevirtual

Get the simulated stator (motor) current.

Returns
Stator current in amperes.

Implements yams::motorcontrollers::SimSupplier.

◆ GetSupplyCurrent()

wpi::units::ampere_t yams::motorcontrollers::simulation::FollowerSimSupplier::GetSupplyCurrent ( )
overridevirtual

Get the simulated supply (battery) current: duty cycle times stator current, filtered by a 0.1 s single-pole IIR filter.

Returns
Supply current in amperes.

Implements yams::motorcontrollers::SimSupplier.

◆ GetUpdatedSim()

bool yams::motorcontrollers::simulation::FollowerSimSupplier::GetUpdatedSim ( )
inlineoverridevirtual

Whether the simulation has already been stepped this loop.

Returns
true if UpdateSim() stepped the physics since the last StarveUpdateSim().

Implements yams::motorcontrollers::SimSupplier.

◆ IsInputFed()

bool yams::motorcontrollers::simulation::FollowerSimSupplier::IsInputFed ( )
inlineoverridevirtual

Whether an input voltage was supplied directly this loop (e.g. from a hardware sim state).

Returns
true if the input was fed since the simulation last stepped.

Implements yams::motorcontrollers::SimSupplier.

◆ SetMechanismPosition()

void yams::motorcontrollers::simulation::FollowerSimSupplier::SetMechanismPosition ( wpi::units::turn_t angle)
inlineoverridevirtual

Set the simulated mechanism position.

Parameters
angleMechanism position to inject.

Implements yams::motorcontrollers::SimSupplier.

◆ SetMechanismStatorDutyCycle()

void yams::motorcontrollers::simulation::FollowerSimSupplier::SetMechanismStatorDutyCycle ( double dutyCycle)
inlineoverridevirtual

Apply a duty cycle of the supply voltage as the motor input (feeds the input).

Parameters
dutyCycleDuty cycle in [-1, 1].

Implements yams::motorcontrollers::SimSupplier.

◆ SetMechanismStatorVoltage()

void yams::motorcontrollers::simulation::FollowerSimSupplier::SetMechanismStatorVoltage ( wpi::units::volt_t volts)
inlineoverridevirtual

Set the motor input voltage directly, e.g. from a hardware sim state (feeds the input).

Parameters
voltsVoltage to apply.

Implements yams::motorcontrollers::SimSupplier.

◆ SetMechanismVelocity()

void yams::motorcontrollers::simulation::FollowerSimSupplier::SetMechanismVelocity ( wpi::units::turns_per_second_t velocity)
inlineoverridevirtual

Set the simulated mechanism velocity.

Parameters
velocityMechanism velocity to inject.

Implements yams::motorcontrollers::SimSupplier.

◆ SetRotorPosition()

void yams::motorcontrollers::simulation::FollowerSimSupplier::SetRotorPosition ( wpi::units::turn_t angle)
inlineoverridevirtual

Set the simulated rotor position.

Parameters
angleRotor position to inject.

Implements yams::motorcontrollers::SimSupplier.

◆ SetRotorVelocity()

void yams::motorcontrollers::simulation::FollowerSimSupplier::SetRotorVelocity ( wpi::units::turns_per_second_t velocity)
inlineoverridevirtual

Set the simulated rotor velocity.

Parameters
velocityRotor velocity to inject.

Implements yams::motorcontrollers::SimSupplier.

◆ StarveInput()

void yams::motorcontrollers::simulation::FollowerSimSupplier::StarveInput ( )
inlineoverridevirtual

Clear the input-fed flag so UpdateSim() falls back to the duty-cycle supplier.

Implements yams::motorcontrollers::SimSupplier.

◆ StarveUpdateSim()

void yams::motorcontrollers::simulation::FollowerSimSupplier::StarveUpdateSim ( )
inlineoverridevirtual

Clear the stepped flag so the next UpdateSim() steps the physics again.

Implements yams::motorcontrollers::SimSupplier.

◆ UpdateSim()

void yams::motorcontrollers::simulation::FollowerSimSupplier::UpdateSim ( )
inlineoverridevirtual

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.


The documentation for this class was generated from the following file: