Skip to content

Commit e2d4564

Browse files
committed
Checkpoint some shit that actually kinda works.
1 parent be1fc24 commit e2d4564

File tree

6 files changed

+28
-31
lines changed

6 files changed

+28
-31
lines changed

data_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef DataTypes_h
22
#define DataTypes_h
33

4-
const int LOG_LEVEL_SILENT = 1;
4+
const int LOG_LEVEL_SILENT = 0;
55
const int LOG_LEVEL_WARN = 1;
66
const int LOG_LEVEL_INFO = 2;
77
const int LOG_LEVEL_DEBUG = 3;

lisa-arduino.ino

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
// *** DEFINE COURSE HERE ***
77
const long EMERGENCY_TIMEOUT_MS = 1 * 60 * 1000;
88
Waypoint 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
5152
const long MOCK_WHEEL_ENCODER_PIN = 8;
52-
const bool MOCK_IMU = true;
53+
const bool MOCK_IMU = false;
5354
void 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
6263
volatile 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
144144
void 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

position_tracker.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ Position PositionTracker::update() {
2424
//Serial.print(gYaw);
2525
//Serial.print(", rDelta: ");
2626
//Serial.println(rDelta);
27-
// NOTE: Sometimes the IMU spikes changes so limit the size we believe
28-
if (abs(rDelta) > IMU_MAX_DELTA_RADIANS) {
29-
// Skip this position update and get next time
30-
// TODO: Return an error code so we can blink it out
31-
return this->position;
32-
}
33-
// Successful read, store as last read
3427
this->lastYaw = gYaw;
3528

3629
// Figure out wheel encoder delta, update stored value and calculate distance

position_tracker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern volatile float gPitch;
1010
extern volatile float gRoll;
1111
extern volatile float gYaw;
1212

13-
const float IMU_MAX_DELTA_RADIANS = 10.0 * PI / 180.0;
13+
const float IMU_MAX_DELTA_DEGREES = 10.0;
1414

1515
// TODO: Put the actual things measured in here and use to compute M so that it's documented
1616
const float WHEEL_ENCODER_M_DISTANCE_FROM_TICKS = 0.0544737;

speed_calibration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const float SPEED_B_SERVO_FROM_VELOCITY = 659.19;
99

1010
const int SPEED_STOPPED_SERVO = 0;
1111
// NOTE: We can directly set velocity and servo instead of curve evaluation if we like
12-
const float SPEED_LOW_VELOCITY = 0.5;
12+
const float SPEED_LOW_VELOCITY = 1.0;
1313
const int SPEED_LOW_SERVO = max(min(int(SPEED_M_SERVO_FROM_VELOCITY * SPEED_LOW_VELOCITY + SPEED_B_SERVO_FROM_VELOCITY), SPEED_MAX_SERVO), SPEED_MIN_SERVO);
1414
// NOTE: If you bump up the top speed you should also make it do updates in the main loop faster or allow more IMU angle variation, otherwise we turn to fast to track
1515
const float SPEED_HIGH_VELOCITY = 2.0;

steering_calibration.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ const float INCH_TO_M = 0.0254;
1414
// and pick to either turn 0, fixed left or fixed right, where we have the
1515
// direct correlation to left and right determined already.
1616
const float STEERING_CENTER_SERVO = 1608; // Not (STEERING_MAX_SERVO + STEERING_MIN_SERVO) / 2 by experimentation
17-
//const float STEERING_LEFT_SERVO = 1864; // half to max
18-
//const float STEERING_LEFT_TURN_RADIUS_INCH = 146;
19-
//const float STEERING_LEFT_TURN_RADIUS = STEERING_LEFT_TURN_RADIUS_INCH * INCH_TO_M; // m
20-
const float STEERING_LEFT_SERVO = 2120; // max
21-
const float STEERING_LEFT_TURN_RADIUS_INCH = 77;
17+
const float STEERING_LEFT_SERVO = 1864; // half to max
18+
const float STEERING_LEFT_TURN_RADIUS_INCH = 146;
2219
const float STEERING_LEFT_TURN_RADIUS = STEERING_LEFT_TURN_RADIUS_INCH * INCH_TO_M; // m
23-
//const float STEERING_RIGHT_SERVO = 1379; // picked half way to max
24-
//const float STEERING_RIGHT_TURN_RADIUS_INCH = -116;
25-
//const float STEERING_RIGHT_TURN_RADIUS = STEERING_RIGHT_TURN_RADIUS_INCH * INCH_TO_M; // m
26-
const float STEERING_RIGHT_SERVO = 1150; // picked half way to max
27-
const float STEERING_RIGHT_TURN_RADIUS_INCH = -66;
20+
//const float STEERING_LEFT_SERVO = 2120; // max
21+
//const float STEERING_LEFT_TURN_RADIUS_INCH = 77;
22+
//const float STEERING_LEFT_TURN_RADIUS = STEERING_LEFT_TURN_RADIUS_INCH * INCH_TO_M; // m
23+
const float STEERING_RIGHT_SERVO = 1379; // picked half way to max
24+
const float STEERING_RIGHT_TURN_RADIUS_INCH = -116;
2825
const float STEERING_RIGHT_TURN_RADIUS = STEERING_RIGHT_TURN_RADIUS_INCH * INCH_TO_M; // m
26+
//const float STEERING_RIGHT_SERVO = 1150; // picked half way to max
27+
//const float STEERING_RIGHT_TURN_RADIUS_INCH = -66;
28+
//const float STEERING_RIGHT_TURN_RADIUS = STEERING_RIGHT_TURN_RADIUS_INCH * INCH_TO_M; // m
2929

3030
//// Pick our 30 and 10 degree turn radiuses based on what we can hit with both left and right to standardize
3131
//const float TURN_RADIUS_FOR_30_DEGREES = 1.0; // m

0 commit comments

Comments
 (0)