-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcircle_generator.h
64 lines (52 loc) · 1.61 KB
/
circle_generator.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
62
63
64
#ifndef __CIRCLE_GENERATOR_H__
#define __CIRCLE_GENERATOR_H__
#include <Arduino.h>
extern double autosteer_lat;
extern double autosteer_lon;
extern double autosteer_heading;
extern double autosteer_roll;
extern double autosteer_yawrate;
extern double autosteer_speed;
extern double autosteer_altitude;
extern uint64_t autosteer_datetime;
extern char autosteer_mode;
/* This class is a latitude and longitude generator that
* virtually drives in a big circle to allow us to set
* a circle track on the brown box monitor according.
* This is intended for our pivot circles where the outer-
* most boundary is a known radius from the pivot point.
*/
class CircleGenerator {
protected:
double center_lat;
double center_lon;
double center_alt;
double radius;
double speed;
double yaw_rate; //calculate from speed and radius
double delta_angle;
double current_angle;
unsigned long start_time;
unsigned long timeout;
unsigned long last_message_time;
public:
CircleGenerator() { }
inline void set_circle(double lat, double lon, double drive_radius, double alt) {
center_lat = lat;
center_lon = lon;
center_alt = alt;
radius = drive_radius;
}
inline void set_radius(double radius_meters) {
radius = radius_meters;
}
inline bool finished(unsigned long time) {
return ((time - start_time) > timeout);
}
//reset the generator, calculate everything we need to run
void start(unsigned long begin_time, uint32_t timeout, double speed);
//calculate a new position if enough time has elapsed
//put it in the autosteer_* global variables
bool circle_position(unsigned long time, uint32_t cycle_time);
};
#endif