ConditionalCommand

class ConditionalCommand : public Command

This class creates a conditional command that changes what runs based on a conditional input

Public Functions

inline ConditionalCommand(Command *primary, Command *secondary, const std::function<bool()> &run_primary)

Create a new ConditionalCommand.

Parameters:
  • primary – The Command that is run when runPrimary is true on initialization

  • secondary – The Command that is run when runPrimary is false on initialization

  • run_primary – Conditional to determine which Command is run

inline virtual void initialize() override

Evaluates the conditional and initialized the selected Command.

inline virtual void execute() override

Runs execute on the selected Command.

inline virtual bool isFinished() override

Checks if the selected command is finished.

Returns:

selected->isFinished()

inline virtual void end(const bool interrupted) override

Runs the selected function’s end command

inline virtual std::vector<Subsystem*> getRequirements() override

This class only captures the requirements of the running command.