PathPlannerLib
Loading...
Searching...
No Matches
ScheduleCommandEvent.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 {
10public:
17 ScheduleCommandEvent(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->scheduleCommand(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 < ScheduleCommandEvent > (timestamp, m_command);
33 }
34
35private:
36 std::shared_ptr<frc2::Command> m_command;
37};
38}
Definition: EventScheduler.h:15
void scheduleCommand(std::shared_ptr< frc2::Command > command)
Definition: EventScheduler.cpp:48
Definition: Event.h:10
Definition: ScheduleCommandEvent.h:9
ScheduleCommandEvent(units::second_t timestamp, std::shared_ptr< frc2::Command > command)
Definition: ScheduleCommandEvent.h:17
std::shared_ptr< Event > copyWithTimestamp(units::second_t timestamp) override
Definition: ScheduleCommandEvent.h:30
void cancelEvent(EventScheduler *eventScheduler) override
Definition: ScheduleCommandEvent.h:26
void handleEvent(EventScheduler *eventScheduler) override
Definition: ScheduleCommandEvent.h:22