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