PathPlannerLib
Loading...
Searching...
No Matches
CancelCommandEvent.h
1#pragma once
2
3#include "pathplanner/lib/events/Event.h"
4#include "pathplanner/lib/events/EventScheduler.h"
5#include <memory>
6#include <frc2/command/Command.h>
7
8namespace pathplanner {
9class CancelCommandEvent: public Event {
10public:
17 CancelCommandEvent(units::second_t timestamp,
18 std::shared_ptr<frc2::Command> command) : Event(timestamp), m_command(
19 command) {
20 }
21
22 inline void handleEvent(EventScheduler *eventScheduler) override {
23 eventScheduler->cancelCommand(m_command);
24 }
25
26 inline void cancelEvent(EventScheduler *eventScheduler) override {
27 // Do nothing
28 }
29
30 inline std::shared_ptr<Event> copyWithTimestamp(units::second_t timestamp)
31 override {
32 return std::make_shared < CancelCommandEvent > (timestamp, m_command);
33 }
34
35private:
36 std::shared_ptr<frc2::Command> m_command;
37};
38}
Definition: CancelCommandEvent.h:9
CancelCommandEvent(units::second_t timestamp, std::shared_ptr< frc2::Command > command)
Definition: CancelCommandEvent.h:17
std::shared_ptr< Event > copyWithTimestamp(units::second_t timestamp) override
Definition: CancelCommandEvent.h:30
void handleEvent(EventScheduler *eventScheduler) override
Definition: CancelCommandEvent.h:22
void cancelEvent(EventScheduler *eventScheduler) override
Definition: CancelCommandEvent.h:26
Definition: EventScheduler.h:15
void cancelCommand(std::shared_ptr< frc2::Command > command)
Definition: EventScheduler.cpp:70
Definition: Event.h:10