9#include <initializer_list>
44 explicit Trigger(std::function<
bool()> condition)
46 std::move(condition)} {}
55 : m_loop{loop}, m_condition{
std::move(condition)} {}
213 return Trigger(m_loop, [condition = m_condition, rhs = std::move(rhs)] {
214 return condition() && rhs();
224 return Trigger(m_loop, [condition = m_condition, rhs] {
225 return condition() && rhs.m_condition();
235 return Trigger(m_loop, [condition = m_condition, rhs = std::move(rhs)] {
236 return condition() || rhs();
246 return Trigger(m_loop, [condition = m_condition, rhs] {
247 return condition() || rhs.m_condition();
258 return Trigger(m_loop, [condition = m_condition] {
return !condition(); });
271 frc::Debouncer::DebounceType::kRising);
275 std::function<bool()> m_condition;
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:44
A wrapper around std::unique_ptr<Command> so commands have move-only semantics.
Definition: CommandPtr.h:29
The scheduler responsible for running Commands.
Definition: CommandScheduler.h:36
This class provides an easy way to link commands to conditions.
Definition: Trigger.h:35
Trigger OnFalse(CommandPtr &&command)
Starts the given command whenever the condition changes from true to false.
Trigger()
Create a new trigger that is always false.
Definition: Trigger.h:60
Trigger operator&&(std::function< bool()> rhs)
Composes two triggers with logical AND.
Definition: Trigger.h:212
Trigger WhileTrue(CommandPtr &&command)
Starts the given command when the condition changes to true and cancels it when the condition changes...
Trigger operator!()
Composes a trigger with logical NOT.
Definition: Trigger.h:257
Trigger WhileFalse(Command *command)
Starts the given command when the condition changes to false and cancels it when the condition change...
Trigger OnFalse(Command *command)
Starts the given command whenever the condition changes from true to false.
Trigger operator&&(Trigger rhs)
Composes two triggers with logical AND.
Definition: Trigger.h:223
Trigger Debounce(units::second_t debounceTime, frc::Debouncer::DebounceType type=frc::Debouncer::DebounceType::kRising)
Creates a new debounced trigger from this trigger - it will become active when this trigger has been ...
Trigger OnTrue(CommandPtr &&command)
Starts the given command whenever the condition changes from false to true.
Trigger OnTrue(Command *command)
Starts the given command whenever the condition changes from false to true.
Trigger WhileFalse(CommandPtr &&command)
Starts the given command when the condition changes to false and cancels it when the condition change...
Trigger(const Trigger &other)
Trigger ToggleOnTrue(Command *command)
Toggles a command when the condition changes from false to true.
Trigger operator||(Trigger rhs)
Composes two triggers with logical OR.
Definition: Trigger.h:245
Trigger operator||(std::function< bool()> rhs)
Composes two triggers with logical OR.
Definition: Trigger.h:234
Trigger ToggleOnFalse(CommandPtr &&command)
Toggles a command when the condition changes from true to false.
Trigger WhileTrue(Command *command)
Starts the given command when the condition changes to true and cancels it when the condition changes...
Trigger ToggleOnTrue(CommandPtr &&command)
Toggles a command when the condition changes from false to true.
Trigger(frc::EventLoop *loop, std::function< bool()> condition)
Creates a new trigger based on the given condition.
Definition: Trigger.h:54
Trigger(std::function< bool()> condition)
Creates a new trigger based on the given condition.
Definition: Trigger.h:44
Trigger ToggleOnFalse(Command *command)
Toggles a command when the condition changes from true to the low state.
DebounceType
Definition: Debouncer.h:20
The loop polling BooleanEvent objects and executing the actions bound to them.
Definition: EventLoop.h:15
type
Definition: core.h:575
Definition: ProfiledPIDCommand.h:18
Definition: BFloat16.h:88