1516X Push Back 1.0
1516X's robot code for the 2025-2026 VEX Robotics Competition
Loading...
Searching...
No Matches
warnings.cpp
Go to the documentation of this file.
1#include "pros/rtos.hpp"
2#include "globals.h"
3
5 pros::Task temp_screening([]() {
6 while (true) {
7 std::vector<double> left_temps = leftMotors.get_temperature_all();
8 std::vector<double> right_temps = rightMotors.get_temperature_all();
9
10 bool is_overheating = false;
11
12 const double TEMP_LIMIT = 55.0;
13 for (int i = 0; i < left_temps.size(); i++) {
14 if (left_temps[i] > TEMP_LIMIT) {
15 controller.rumble(".-.");
16 controller.clear_line(0);
17 controller.print(0, 0, "OVERHEAT! L%i", i + 1);
18 pros::delay(1000);
19 controller.clear_line(0);
20 is_overheating = true;
21 break;
22 }
23 }
24
25 if (is_overheating) {
26 pros::delay(10000);
27 return;
28 }
29
30 for (int i = 0; i < right_temps.size(); i++) {
31 if (right_temps[i] > TEMP_LIMIT) {
32 controller.rumble(".-.");
33 controller.clear_line(0);
34 controller.print(0, 0, "OVERHEAT! R%i", i + 1);
35 pros::delay(1000);
36 controller.clear_line(0);
37 is_overheating = true;
38 break;
39 }
40 }
41 pros::delay(200);
42 if(is_overheating) {
43 pros::delay(10000);
44 return;
45 }
46 }
47 });
48}
49
51{
52 pros::Task disconnect_screening([]() {
53 std::vector<pros::Motor> all_motors = pros::Motor::get_all_devices();
54 std::vector<unsigned char> disconnected;
55 std::vector<unsigned char> last_disconnected;
56 bool is_notified = false;
57 uint32_t now = pros::millis();
58
59 constexpr int TASK_DELAY_MILLIS = 1000;
60 constexpr int CONTROLLER_DELAY_MILLIS = 50;
61 while (true) {
62 std::string disc_motors = "MD: ";
63 bool are_motors_disconnected = false;
64
65 for (pros::Motor i : all_motors) {
66 if (!i.is_installed()) {
67 unsigned char port = i.get_port();
68 disconnected.push_back(port);
69 disc_motors = disc_motors + " " + std::to_string(port);
70 are_motors_disconnected = true;
71 }
72 }
73 if (are_motors_disconnected) {
74 controller.clear_line(0);
75 pros::delay(CONTROLLER_DELAY_MILLIS);
76 controller.set_text(0, 0, disc_motors);
77 is_notified = true;
78 pros::delay(CONTROLLER_DELAY_MILLIS);
79 }
80 if (disconnected.size() > last_disconnected.size()) {
81 controller.rumble(". . .");
82 } else if (disconnected.size() < last_disconnected.size()) {
83 controller.rumble("-");
84 } else if (!are_motors_disconnected && is_notified) {
85 controller.clear_line(0);
86 is_notified = false;
87 }
88 last_disconnected = disconnected;
89 disconnected.clear();
90 pros::delay(300);
91 }
92 });
93}
94
96{
97 pros::Task disconnect_screening([]() {
98 std::vector<pros::Distance> all_distance_sensors = {frontDistance, backDistance, leftDistance, rightDistance};
99 std::vector<unsigned char> disconnected;
100 std::vector<unsigned char> last_disconnected;
101 bool is_notified = false;
102
103 constexpr int TASK_DELAY_MILLIS = 1000;
104 constexpr int CONTROLLER_DELAY_MILLIS = 50;
105 while (true) {
106 std::string disc_d_sensors = "DSD: ";
107 bool are_distance_sensors_disconnected = false;
108
109 for (pros::Distance i : all_distance_sensors) {
110 if (!i.is_installed()) {
111 unsigned char port = i.get_port();
112 disconnected.push_back(port);
113 disc_d_sensors = disc_d_sensors + " " + std::to_string(port);
114 are_distance_sensors_disconnected = true;
115 }
116 }
117 if (are_distance_sensors_disconnected) {
118 controller.clear_line(0);
119 pros::delay(CONTROLLER_DELAY_MILLIS);
120 controller.set_text(0, 0, disc_d_sensors);
121 is_notified = true;
122 pros::delay(CONTROLLER_DELAY_MILLIS);
123 }
124 if (disconnected.size() > last_disconnected.size()) {
125 controller.rumble(". . .");
126 } else if (disconnected.size() < last_disconnected.size()) {
127 controller.rumble("-");
128 } else if (!are_distance_sensors_disconnected && is_notified) {
129 controller.clear_line(0);
130 is_notified = false;
131 }
132 last_disconnected = disconnected;
133 disconnected.clear();
134 pros::delay(300);
135 }
136 });
137}
pros::Distance backDistance(11)
pros::Distance frontDistance(13)
pros::Distance leftDistance(12)
pros::Distance rightDistance(6)
pros::MotorGroup rightMotors
pros::MotorGroup leftMotors
Definition globals.cpp:20
pros::Controller controller
void distance_sensor_disconnect_warning()
Definition warnings.cpp:95
void motor_disconnect_warning()
Definition warnings.cpp:50
void temp_warning()
Definition warnings.cpp:4