41103C 26/27
Documentation for 41103C 1/3 for the 2026/2027 Vex V5 Season Override
Loading...
Searching...
No Matches
robot_hardware.hpp
1#ifndef ROBOT_HARDWARE_HPP
2#define ROBOT_HARDWARE_HPP
3
4#include "api.h"
5#include "macro.hpp"
6#include "odom.hpp"
7
8#include <cstdint>
9#include <memory>
10#include <vector>
11
12using pros_adi_port = uint8_t;
13using pros_standard_port = int8_t;
14
16
17// negative port is reversed
18enum StandardPorts : pros_standard_port
19{
20 LEFT_FRONT = -14,
21 LEFT_REAR = -15,
22 RIGHT_FRONT = 11,
23 RIGHT_REAR = 12,
24
25 IMU_PORT = 5,
26 AI_VISION_PORT = 9,
27 INTAKE_PORT = -16,
28 CASCADE_RIGHT_PORT = -19,
29 CASCADE_LEFT_PORT = 20,
30 SCORE_OPEN_PORT = -1, // Ratchet Wrist
31 SCORE_ROLL_PORT = -2, // Ratchet Open/Close
32
33 VERTICAL_ODOM_PORT = 3,
34 HORIZONTAL_ODOM_PORT = 4,
35 CASCADE_ENCODER_PORT = 6,
36 OPTICAL_PORT = 8
37};
38constexpr pros_standard_port motor_left_front = LEFT_FRONT;
39constexpr pros_standard_port motor_left_rear = LEFT_REAR;
40constexpr pros_standard_port motor_right_front = RIGHT_FRONT;
41constexpr pros_standard_port motor_right_rear = RIGHT_REAR;
42constexpr pros_standard_port imu = IMU_PORT;
43constexpr pros_standard_port aivision = AI_VISION_PORT;
44constexpr pros_standard_port motor_intake_11W = INTAKE_PORT;
45constexpr pros_standard_port motor_cascade_11WR = CASCADE_RIGHT_PORT;
46constexpr pros_standard_port motor_cascade_11WL = CASCADE_LEFT_PORT;
47constexpr pros_standard_port motor_score_open = SCORE_OPEN_PORT;
48constexpr pros_standard_port motor_score_roll = SCORE_ROLL_PORT;
49constexpr pros_standard_port odom_vertical = VERTICAL_ODOM_PORT;
50constexpr pros_standard_port odom_horizontal = HORIZONTAL_ODOM_PORT;
51constexpr pros_standard_port cascade_encoder = CASCADE_ENCODER_PORT;
52constexpr pros_standard_port optical = OPTICAL_PORT;
53
54enum ThreeWire
55{
56};
57
58struct MWrap
59{
60 std::unique_ptr<pros::Motor> motor;
61 pros_standard_port port;
62 pros::motor_gearset_e_t gearset;
63
64 MWrap()
65 : motor(nullptr),
66 port(0),
67 gearset(pros::E_MOTOR_GEAR_BLUE)
68 {
69 }
70
71 explicit MWrap(pros_standard_port motorPort,
72 pros::motor_gearset_e_t motorGear = pros::E_MOTOR_GEAR_BLUE)
73 : motor(nullptr),
74 port(motorPort),
75 gearset(motorGear)
76 {
77 }
78
79 ~MWrap(void);
80
81 void MWrap_Init()
82 {
83 if (motor) {
84 return;
85 }
86
87 motor = std::make_unique<pros::Motor>(port);
88 motor->set_brake_mode(pros::MotorBrake::brake);
89 motor->set_gearing(gearset);
90 }
91
92 void operator=(pros::Motor motorValue)
93 {
94 motor = std::make_unique<pros::Motor>(motorValue);
95 }
96
97 void set(int speed);
98};
99
100struct MGWrap
101{
102 std::vector<MWrap*> motors;
103 float powerScale;
104
105 MGWrap()
106 : powerScale(1.0f)
107 {
108 }
109
110 MGWrap(MWrap* first, MWrap* second, MWrap* third,
111 float scale = 1.0f);
112
113 void set(int speed)
114 {
115 const int output = static_cast<int>(speed * powerScale);
116 for (MWrap* motor : motors) {
117 if (motor != nullptr) {
118 motor->set(output);
119 }
120 }
121 }
122};
123
124struct Hardware
125{
126 struct
127 {
128 MWrap MOTOR_L1;
129 MWrap MOTOR_L2;
130 MWrap MOTOR_R1;
131 MWrap MOTOR_R2;
132 MWrap MOTOR_INTAKE_11W;
133 MWrap MOTOR_CASCADE_11WR;
134 MWrap MOTOR_CASCADE_11WL;
135 MWrap MOTOR_SCORE_OPEN;
136 MWrap MOTOR_SCORE_ROLL;
137 } Motors;
138
139 struct
140 {
141 MGWrap DT_L;
142 MGWrap DT_R;
143 MGWrap MOTORGROUP_INTAKE;
144 } MGroups;
145
146 struct
147 {
148 std::unique_ptr<pros::adi::Pneumatics> PNEUMATIC;
149 } Pneumatics;
150
151 struct
152 {
153 std::unique_ptr<pros::Rotation> VerticalWheel;
154 std::unique_ptr<pros::Rotation> HorizontalWheel;
155 } Odom;
156
157 struct
158 {
159 std::unique_ptr<pros::Imu> IMU;
160 std::unique_ptr<pros::Rotation> CascadeEncoder;
161 std::unique_ptr<pros::Optical> ToggleOptical;
162 } Sensors;
163
164 struct
165 {
166 std::unique_ptr<FlipToggleHeight> flipToggleHeight;
167 } Macros;
168
169 std::unique_ptr<pros::Controller> PRIMARY_CONTROLLER;
170 std::unique_ptr<pros::Controller> SECONDARY_CONTROLLER;
171
172 Hardware(void);
173 ~Hardware(void);
174
175 void LoadPeripherals(void);
176 void init(void);
177
178 Hardware(const Hardware&) = delete;
179 Hardware& operator=(const Hardware&) = delete;
180};
181
182extern Hardware devices;
183
184#endif
Definition macro.hpp:12
Definition robot_hardware.hpp:125
Definition robot_hardware.hpp:101
Definition robot_hardware.hpp:59