RIT VEXU Core API
Loading...
Searching...
No Matches
command_controller.h
1
9
10#pragma once
11#include <queue>
12#include <vector>
13
14#include "core/competition/command_structure/auto_command.h"
15
17 public:
23 CommandController(std::initializer_list<AutoCommand*> cmds);
30 [[deprecated(
31 "Use list constructor instead. If you need to make a decision before adding new "
32 "commands, use Branch "
33 "(https://github.com/RIT-VEX-U/Core/wiki/3-%7C-Utilites#commandcontroller)"
34 )]] void
35 add(std::vector<AutoCommand*> cmds);
36 void add(AutoCommand* cmd, double timeout_seconds = 10.0);
37
42
49 [[deprecated(
50 "Use list constructor instead. If you need to make a decision before adding new "
51 "commands, use Branch "
52 "(https://github.com/RIT-VEX-U/Core/wiki/3-%7C-Utilites#commandcontroller)"
53 )]] void
54 add(std::vector<AutoCommand*> cmds, double timeout_sec);
61 void add_delay(int ms);
62
69 void add_cancel_func(std::function<bool(void)> true_if_cancel);
70
75 void run();
76
78 std::string toString();
79
88 bool printPathLogs = true;
89
90 private:
91 std::queue<AutoCommand*> command_queue;
92 bool command_timed_out = false;
93 std::function<bool()> should_cancel = []() { return false; };
94};
void add(std::vector< AutoCommand * > cmds)
Definition command_controller.cpp:37
void run()
Definition command_controller.cpp:77
bool last_command_timed_out()
Definition command_controller.cpp:143
CommandController(std::initializer_list< AutoCommand * > cmds)
Create a CommandController with commands pre added. More can be added with CommandController::add().
Definition command_controller.cpp:20
void add_cancel_func(std::function< bool(void)> true_if_cancel)
add_cancel_func specifies that when this func evaluates to true, to cancel the command controller
Definition command_controller.cpp:69
void add_delay(int ms)
Definition command_controller.cpp:64
std::string toString()
returns the amount of commands in the controller
Definition command_controller.cpp:139