-
Notifications
You must be signed in to change notification settings - Fork 96
/
gps.h
59 lines (46 loc) · 1.95 KB
/
gps.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
/* To use these functions:
1. Start with a KalmanFilter created by alloc_filter_velocity2d.
2. At fixed intervals, call update_velocity2d with the lat/long.
3. At any time, to get an estimate for the current position,
bearing, or speed, use the functions:
get_lat_long
get_bearing
get_mph
*/
#ifndef __GPS_H__
#define __GPS_H__
#include <stdio.h>
#include "kalman.h"
/* Create a GPS filter that only tracks two dimensions of position and
velocity.
The inherent assumption is that changes in velocity are randomly
distributed around 0.
Noise is a parameter you can use to alter the expected noise.
1.0 is the original, and the higher it is, the more a path will be
"smoothed".
Free with free_filter after using. */
KalmanFilter alloc_filter_velocity2d(double noise);
/* Set the seconds per timestep in the velocity2d model. */
void set_seconds_per_timestep(KalmanFilter f,
double seconds_per_timestep);
/* Update the velocity2d model with new gps data. */
void update_velocity2d(KalmanFilter f, double lat, double lon,
double seconds_since_last_update);
/* Read a lat,long pair from a file.
Format is lat,long<ignored>
Return whether there was a lat,long to be read */
int read_lat_long(FILE* file, double* lat, double* lon);
/* Extract a lat long from a velocity2d Kalman filter. */
void get_lat_long(KalmanFilter f, double* lat, double* lon);
/* Extract velocity with lat-long-per-second units from a velocity2d
Kalman filter. */
void get_velocity(KalmanFilter f, double* delta_lat, double* delta_lon);
/* Extract a bearing from a velocity2d Kalman filter.
0 = north, 90 = east, 180 = south, 270 = west */
double get_bearing(KalmanFilter f);
/* Convert a lat, long, delta lat, and delta long into mph.*/
double calculate_mph(double lat, double lon,
double delta_lat, double delta_lon);
/* Extract speed in miles per hour from a velocity2d Kalman filter. */
double get_mph(KalmanFilter f);
#endif