RIT VEXU Core API
Loading...
Searching...
No Matches
command_controller.h
1
9
10#pragma once
11#include "core/utils/command_structure/auto_command.h"
12#include <queue>
13#include <vector>
14
16 public:
20 CommandController(std::initializer_list<AutoCommand *> cmds) : command_queue(cmds) {}
27 [[deprecated("Use list constructor instead. If you need to make a decision before adding new commands, use Branch "
28 "(https://github.com/RIT-VEX-U/Core/wiki/3-%7C-Utilites#commandcontroller)")]] void
29 add(std::vector<AutoCommand *> cmds);
30 void add(AutoCommand *cmd, double timeout_seconds = 10.0);
31
36
43 [[deprecated("Use list constructor instead. If you need to make a decision before adding new commands, use Branch "
44 "(https://github.com/RIT-VEX-U/Core/wiki/3-%7C-Utilites#commandcontroller)")]] void
45 add(std::vector<AutoCommand *> cmds, double timeout_sec);
52 void add_delay(int ms);
53
58 void add_cancel_func(std::function<bool(void)> true_if_cancel);
59
64 void run();
65
66 /*
67 * returns the amount of commands in the controller
68 */
69 std::string toString();
70
79 bool printPathLogs = true;
80
81 private:
82 std::queue<AutoCommand *> command_queue;
83 bool command_timed_out = false;
84 std::function<bool()> should_cancel = []() { return false; };
85};
void add(std::vector< AutoCommand * > cmds)
Definition command_controller.cpp:28
void run()
Definition command_controller.cpp:66
bool last_command_timed_out()
Definition command_controller.cpp:128
CommandController(std::initializer_list< AutoCommand * > cmds)
Create a CommandController with commands pre added. More can be added with CommandController::add()
Definition command_controller.h: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:60
void add_delay(int ms)
Definition command_controller.cpp:55