-
Notifications
You must be signed in to change notification settings - Fork 1
/
navigator.h
61 lines (47 loc) · 1.25 KB
/
navigator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef Navigator_h
#define Navigator_h
#include "Arduino.h"
#include <Servo.h>
#include "speed_calibration.h"
#include "steering_calibration.h"
#include "data_types.h"
// Angle (radians) under which we won't make steering corrections
const float ORIENTATION_DELTA = 1.0 * PI / 180.0;
// Distance (m) at which we slow down
const float APPROACH_DELTA = 1.0;
enum SPEED {
SPEED_STOPPED,
SPEED_LOW,
SPEED_HIGH
};
enum STEERING {
STEERING_LEFT_FULL,
STEERING_LEFT_HALF,
STEERING_CENTER,
STEERING_RIGHT_HALF,
STEERING_RIGHT_FULL
};
class Navigator
{
public:
Navigator(int logLevel);
void attachSpeedServo(int pin);
void attachSteeringServo(int pin);
// Start navigation amongst waypoints
void reset();
void fullStop();
// Tells the navigator to update its course given a position and target waypoint
bool update(Position p, Waypoint w);
SPEED getSpeed();
STEERING getSteering();
private:
int logLevel = 0;
SPEED speed = SPEED_STOPPED;
STEERING steering = STEERING_CENTER;
Servo speedServo, steeringServo;
void adjustSpeed(float distance);
void adjustSteering(float orientation, float targetOrientation);
void setSpeed(SPEED speed);
void setSteering(float servoValue);
};
#endif