66// *** DEFINE COURSE HERE ***
77const long EMERGENCY_TIMEOUT_MS = 1 * 60 * 1000 ;
88Waypoint waypoints[] = {
9+ // Waypoint{10, 0, 0.3},
910 // Left 10m square
11+ /*
1012 Waypoint{8, 0, 0.3},
1113 Waypoint{10, 2, 0.3},
1214 Waypoint{10, 8, 0.3},
1315 Waypoint{8, 10, 0.3},
1416 Waypoint{2, 10, 0.3},
1517 Waypoint{0, 8, 0.3},
1618 Waypoint{0, -3, 3},
19+ */
1720
1821 // Right 10m square
1922 /*
@@ -27,7 +30,6 @@ Waypoint waypoints[] = {
2730 */
2831
2932 // Figure 8
30- /*
3133 Waypoint{3 , -3 , 0.3 },
3234 Waypoint{6 , 0 , 0.3 },
3335 Waypoint{9 , 3 , 0.3 },
@@ -37,7 +39,6 @@ Waypoint waypoints[] = {
3739 Waypoint{3 , 3 , 0.3 },
3840 Waypoint{0 , 0 , 0.3 },
3941 Waypoint{-4 , 0 , 3 },
40- */
4142};
4243
4344// PIN ASSIGNMENTS
@@ -49,14 +50,14 @@ const int WHEEL_ENCODER_INT = 0; // pin 2
4950
5051// TODO: Move into a class
5152const long MOCK_WHEEL_ENCODER_PIN = 8 ;
52- const bool MOCK_IMU = true ;
53+ const bool MOCK_IMU = false ;
5354void handleMockSensors ();
5455
5556// Create helper objects
56- PositionTracker tracker (LOG_LEVEL_INFO );
57- WaypointManager manager (LOG_LEVEL_INFO );
58- Navigator navigator (LOG_LEVEL_DEBUG );
59- int logLevel = LOG_LEVEL_INFO ;
57+ PositionTracker tracker (LOG_LEVEL_SILENT );
58+ WaypointManager manager (LOG_LEVEL_SILENT );
59+ Navigator navigator (LOG_LEVEL_SILENT );
60+ int logLevel = LOG_LEVEL_SILENT ;
6061
6162// Global values for wheel encoder and IMU
6263volatile long gWheelEncoderTicks = 0 ;
@@ -140,16 +141,19 @@ void loop() {
140141}
141142
142143// If IMU data available read it
143- // TODO: Consider moving this to PositionTracker and just have it read and wait for data
144144void serialEvent () {
145145 if (!MOCK_IMU) {
146- gRoll = Serial.parseFloat ();
147- gPitch = Serial.parseFloat ();
148- gYaw = Serial.parseFloat ();
146+ float roll = Serial.parseFloat ();
147+ float pitch = Serial.parseFloat ();
148+ float yaw = Serial.parseFloat ();
149149 char garbage[20 ];
150150 Serial.readBytesUntil (' \0 ' , garbage, 20 );
151151 // Serial.print("gYaw: ");
152152 // Serial.println(gYaw);
153+ // NOTE: Sometimes the IMU spikes changes so limit the size we believe for a given fast loop rad
154+ // if (abs(yaw - gYaw) < IMU_MAX_DELTA_DEGREES) {
155+ gYaw = yaw;
156+ // }
153157 }
154158}
155159
0 commit comments