@@ -84,32 +84,32 @@ int main() {
84
84
85
85
Serial.begin (115200 ); // the serial monitor is actually always active (for debug use logger.println & tycmd)
86
86
debug.begin (SerialUSB1);
87
-
87
+
88
88
print_logo ();
89
89
90
90
// check to see if there is a crash report, and if so, print it repeatedly over Serial
91
91
// in the future, we'll send this directly over comms
92
92
if (CrashReport) {
93
93
while (1 ) {
94
- logger.println (CrashReport);
95
- logger.println (" \n Reflash to clear CrashReport (and also please fix why it crashed)" );
94
+ logger.println (LogDestination::Serial, CrashReport);
95
+ logger.println (LogDestination::Serial, " \n Reflash to clear CrashReport (and also please fix why it crashed)" );
96
96
delay (1000 );
97
97
}
98
98
}
99
99
100
100
// Execute setup functions
101
101
pinMode (LED_BUILTIN, OUTPUT);
102
-
102
+
103
103
// initialize objects
104
104
can.init ();
105
105
dr16.init ();
106
106
comms_layer.init ();
107
107
ref = sensor_manager.get_ref ();
108
108
109
109
// Config config
110
- logger.println (" Configuring..." );
110
+ logger.println (LogDestination::Serial, " Configuring..." );
111
111
const Config* config = config_layer.configure (&comms_layer);
112
- logger.println (" Configured!" );
112
+ logger.println (LogDestination::Serial, " Configured!" );
113
113
114
114
// configure motors
115
115
can.configure (config->motor_info );
@@ -163,19 +163,19 @@ int main() {
163
163
Timer loop_timer;
164
164
Timer stall_timer;
165
165
Timer control_input_timer;
166
-
166
+
167
167
// start the main loop watchdog
168
168
watchdog.start ();
169
169
170
- logger.println (" Entering main loop...\n " );
170
+ logger.println (LogDestination::Serial, " Entering main loop...\n " );
171
171
172
172
uint8_t log_buffer_copy[LOGGER_BUFFER_SIZE];
173
173
174
174
// Main loop
175
175
while (true ) {
176
176
// start main loop time timer
177
177
stall_timer.start ();
178
-
178
+
179
179
// read sensors
180
180
sensor_manager.read ();
181
181
// read CAN and DR16 -- These are kept out of sensor manager for safety reasons
@@ -194,7 +194,7 @@ int main() {
194
194
195
195
// print loopc every second to verify it is still alive
196
196
if (loopc % 1000 == 0 ) {
197
- Serial .println (loopc);
197
+ logger .println (loopc);
198
198
}
199
199
200
200
// manual controls on firmware
@@ -208,7 +208,7 @@ int main() {
208
208
// clamp to pitch limits
209
209
if (dr16_pos_y < pitch_min) { dr16_pos_y = pitch_min; }
210
210
if (dr16_pos_y > pitch_max) { dr16_pos_y = pitch_max; }
211
-
211
+
212
212
float chassis_vel_x = 0 ;
213
213
float chassis_vel_y = 0 ;
214
214
float chassis_pos_x = 0 ;
@@ -273,19 +273,19 @@ int main() {
273
273
}
274
274
275
275
// print dr16
276
- // Serial .printf("DR16:\n\t");
276
+ // logger .printf("DR16:\n\t");
277
277
// dr16.print();
278
278
279
- // Serial .printf("Target state:\n");
279
+ // logger .printf("Target state:\n");
280
280
// for (int i = 0; i < 8; i++) {
281
- // Serial .printf("\t%d: %f %f %f\n", i, target_state[i][0], target_state[i][1], target_state[i][2]);
281
+ // logger .printf("\t%d: %f %f %f\n", i, target_state[i][0], target_state[i][1], target_state[i][2]);
282
282
// }
283
-
283
+
284
284
// override temp state if needed
285
285
if (comms_layer.get_hive_data ().override_state .active ) {
286
286
// clear the request
287
287
comms_layer.get_hive_data ().override_state .active = false ;
288
-
288
+
289
289
logger.printf (" Overriding state with hive state\n " );
290
290
memcpy (hive_state_offset, comms_layer.get_hive_data ().override_state .state , sizeof (hive_state_offset));
291
291
memcpy (temp_state, hive_state_offset, sizeof (hive_state_offset));
@@ -303,9 +303,9 @@ int main() {
303
303
count_one++;
304
304
}
305
305
306
- // Serial .printf("Estimated state:\n");
306
+ // logger .printf("Estimated state:\n");
307
307
// for (int i = 0; i < 8; i++) {
308
- // Serial .printf("\t%d: %f %f %f\n", i, temp_state[i][0], temp_state[i][1], temp_state[i][2]);
308
+ // logger .printf("\t%d: %f %f %f\n", i, temp_state[i][0], temp_state[i][1], temp_state[i][2]);
309
309
// }
310
310
311
311
// give the sensors the current estimated state
@@ -316,9 +316,9 @@ int main() {
316
316
governor.step_reference (target_state, config->governor_types );
317
317
governor.get_reference (temp_reference);
318
318
319
- // Serial .printf("Reference state:\n");
319
+ // logger .printf("Reference state:\n");
320
320
// for (int i = 0; i < 8; i++) {
321
- // Serial .printf("\t%d: %f %f %f\n", i, temp_reference[i][0], temp_reference[i][1], temp_reference[i][2]);
321
+ // logger .printf("\t%d: %f %f %f\n", i, temp_reference[i][0], temp_reference[i][1], temp_reference[i][2]);
322
322
// }
323
323
324
324
// generate motor outputs from controls
0 commit comments