HoloLib
High-performance holonomic (X-Drive) control library for VEX V5
Loading...
Searching...
No Matches
replay.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <functional>
6#include <vector>
7
8namespace hololib {
9
11 /**
12 * @brief A snapshot of joystick and pose data for macro recording/playback.
13 */
14 struct ReplayData {
15 float forwards, sideways, rotation; /**< Raw joystick outputs */
16 Pose pose; /**< Captured pose at the time */
17 };
18
19 /**
20 * @brief Links a controller button to a lambda callback function.
21 */
22 struct ControllerButton {
23 pros::controller_digital_e_t button; /**< The specific controller button */
24 std::function<void()> callback; /**< The callback to execute when pressed */
25 };
26 // List of controller buttons and their callbacks
27 static const std::vector<ControllerButton> controllerButtons;
28
29 /**
30 *@brief Structure to store button records.
31 */
32 struct ButtonRecord {
33 pros::controller_digital_e_t button;
34 uint32_t duration_ms;
35 uint32_t timestamp_ms;
36 };
37
38public:
39 /**
40 *@brief Gets controller input.
41 *@param master The controller to get input from.
42 *@return void
43 */
44 static void getControllerInput(pros::Controller master);
45
46 /**
47 *@brief Logs replay data to a file.
48 *@param master The controller to get input from.
49 *@param timeout_ms The time to log data for.
50 *@return void
51 */
52 static void logReplayData(pros::Controller master, int timeout_ms, std::function<Pose(bool)> poseGetter);
53
54 /**
55 *@brief Runs the driver replay.
56 *@param data The path data to use for the replay.
57 *@param lookahead The lookahead distance for the path.
58 *@return void
59 */
60 static void runDriverReplay(std::vector<PathPoint> data, float lookahead);
61};
62} // namespace hololib
static void logReplayData(pros::Controller master, int timeout_ms, std::function< Pose(bool)> poseGetter)
Logs replay data to a file.
static void runDriverReplay(std::vector< PathPoint > data, float lookahead)
Runs the driver replay.
static void getControllerInput(pros::Controller master)
Gets controller input.
const std::function< hololib::Pose(bool)> poseGetter