Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS > Class Template Reference

#include <governor_with_fallback_command.hpp>

Inheritance diagram for tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >:
Collaboration diagram for tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >:

Public Member Functions

 GovernorWithFallbackCommand (std::vector< Subsystem * > subRequirements, Command &commandWhenGovernorsReady, Command &fallbackCommand, const std::array< CommandGovernorInterface *, NUM_CONDITIONS > &commandGovernorList, const bool stopFallbackCommandIfGovernorsReady=false)
 
const char * getName () const override
 
bool isReady () override
 
void initialize () override
 
void execute () override
 
void end (bool interrupted) override
 
bool isFinished () const override
 
- Public Member Functions inherited from tap::control::Command
 Command ()
 
virtual ~Command ()
 
mockable subsystem_scheduler_bitmap_t getRequirementsBitwise () const
 
int getGlobalIdentifier () const
 
mockable void addSubsystemRequirement (Subsystem *requirement)
 

Additional Inherited Members

- Protected Attributes inherited from tap::control::Command
command_scheduler_bitmap_t commandRequirementsBitwise = 0
 

Detailed Description

template<std::size_t NUM_CONDITIONS>
class tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >

A command that alternates between two commands based on the state of a list of governors. One of the two commands is selected in the isReady phase of the Command, at which point that command will be executed until its completion.

Template Parameters
NUM_CONDITIONSThe number of governors in the governor list.

Constructor & Destructor Documentation

◆ GovernorWithFallbackCommand()

template<std::size_t NUM_CONDITIONS>
tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >::GovernorWithFallbackCommand ( std::vector< Subsystem * >  subRequirements,
Command commandWhenGovernorsReady,
Command fallbackCommand,
const std::array< CommandGovernorInterface *, NUM_CONDITIONS > &  commandGovernorList,
const bool  stopFallbackCommandIfGovernorsReady = false 
)
inline

Member Function Documentation

◆ end()

template<std::size_t NUM_CONDITIONS>
void tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >::end ( bool  interrupted)
inlineoverridevirtual

The action to take when the command ends. Called when either the command finishes normally, or when it interrupted/canceled.

Parameters
[in]interruptedwhether the command was interrupted/canceled.

Implements tap::control::Command.

◆ execute()

template<std::size_t NUM_CONDITIONS>
void tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >::execute ( )
inlineoverridevirtual

The main body of a command. Called repeatedly while the command is scheduled by a CommandScheduler.

Implements tap::control::Command.

◆ getName()

template<std::size_t NUM_CONDITIONS>
const char * tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >::getName ( ) const
inlineoverridevirtual
Returns
the name of the command, to be implemented by derived classes.

Implements tap::control::Command.

◆ initialize()

template<std::size_t NUM_CONDITIONS>
void tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >::initialize ( )
inlineoverridevirtual

The initial subroutine of a command. Called once when the command is initially scheduled by a CommandScheduler.

Note that command instances are re-used: a single command could be initialized, run, finished, then later initialized again. Ensure that initialize() resets any state stored in the command!

Implements tap::control::Command.

◆ isFinished()

template<std::size_t NUM_CONDITIONS>
bool tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >::isFinished ( ) const
inlineoverridevirtual

Whether the command has finished. Once a Command finishes, the scheduler will call the end() function and un-schedule it. If a Command is naturally finished (i.e. isFinished() == true), then the CommandScheduler will pass in false to end(). If, for example, another Command is added that in turn stops the Command from executing, then the CommandScheduler will pass in true to end().

Returns
whether the command has finished.

Implements tap::control::Command.

◆ isReady()

template<std::size_t NUM_CONDITIONS>
bool tap::control::governor::GovernorWithFallbackCommand< NUM_CONDITIONS >::isReady ( )
inlineoverridevirtual

A check called right before a command is scheduled to determine whether or not a command should be scheduled. If return is true then the command is scheduled, if false then the command is not scheduled.

Not forced to be overridden, returns true by default.

Reimplemented from tap::control::Command.


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