40 explicit Trigger(std::function<
bool()> condition)
42 std::move(condition)} {}
51 : m_loop{loop}, m_condition{
std::move(condition)} {}
209 return Trigger(m_loop, [condition = m_condition, rhs = std::move(rhs)] {
210 return condition() && rhs();
220 return Trigger(m_loop, [condition = m_condition, rhs] {
221 return condition() && rhs.m_condition();
231 return Trigger(m_loop, [condition = m_condition, rhs = std::move(rhs)] {
232 return condition() || rhs();
242 return Trigger(m_loop, [condition = m_condition, rhs] {
243 return condition() || rhs.m_condition();
254 return Trigger(m_loop, [condition = m_condition] {
return !condition(); });
267 frc::Debouncer::DebounceType::kRising);
277 std::function<bool()> m_condition;
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:41
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:38
This class provides an easy way to link commands to conditions.
Definition: Trigger.h:31
bool Get() const
Returns the current state of this trigger.
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:56
Trigger operator&&(std::function< bool()> rhs)
Composes two triggers with logical AND.
Definition: Trigger.h:208
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:253
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:219
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:241
Trigger operator||(std::function< bool()> rhs)
Composes two triggers with logical OR.
Definition: Trigger.h:230
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:50
Trigger(std::function< bool()> condition)
Creates a new trigger based on the given condition.
Definition: Trigger.h:40
Trigger ToggleOnFalse(Command *command)
Toggles a command when the condition changes from true to the low state.
DebounceType
Type of debouncing to perform.
Definition: Debouncer.h:23
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition: EventLoop.h:15
type
Definition: core.h:556
Definition: TrapezoidProfileSubsystem.h:12