CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_GPS/AP_GPS_NOVA.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
// Novatel/Tersus/ComNav GPS driver for ArduPilot.
17
// Code by Michael Oborne
18
// Derived from http://www.novatel.com/assets/Documents/Manuals/om-20000129.pdf
19
20
#pragma once
21
22
#include "AP_GPS.h"
23
#include "GPS_Backend.h"
24
25
#if AP_GPS_NOVA_ENABLED
26
class AP_GPS_NOVA : public AP_GPS_Backend
27
{
28
public:
29
AP_GPS_NOVA(AP_GPS &_gps, AP_GPS::Params &_params, AP_GPS::GPS_State &_state, AP_HAL::UARTDriver *_port);
30
31
AP_GPS::GPS_Status highest_supported_status(void) override { return AP_GPS::GPS_OK_FIX_3D_RTK_FIXED; }
32
33
// Methods
34
bool read() override;
35
36
const char *name() const override { return "NOVA"; }
37
38
private:
39
40
bool parse(uint8_t temp);
41
bool process_message();
42
43
static const uint8_t NOVA_PREAMBLE1 = 0xaa;
44
static const uint8_t NOVA_PREAMBLE2 = 0x44;
45
static const uint8_t NOVA_PREAMBLE3 = 0x12;
46
47
// do we have new position information?
48
bool _new_position:1;
49
// do we have new speed information?
50
bool _new_speed:1;
51
52
uint32_t _last_vel_time;
53
54
uint8_t _init_blob_index = 0;
55
uint32_t _init_blob_time = 0;
56
static const char* const _initialisation_blob[4];
57
58
uint32_t crc_error_counter = 0;
59
60
struct PACKED nova_header
61
{
62
// 0
63
uint8_t preamble[3];
64
// 3
65
uint8_t headerlength;
66
// 4
67
uint16_t messageid;
68
// 6
69
uint8_t messagetype;
70
//7
71
uint8_t portaddr;
72
//8
73
uint16_t messagelength;
74
//10
75
uint16_t sequence;
76
//12
77
uint8_t idletime;
78
//13
79
uint8_t timestatus;
80
//14
81
uint16_t week;
82
//16
83
uint32_t tow;
84
//20
85
uint32_t recvstatus;
86
// 24
87
uint16_t resv;
88
//26
89
uint16_t recvswver;
90
};
91
92
struct PACKED psrdop
93
{
94
float gdop;
95
float pdop;
96
float hdop;
97
float htdop;
98
float tdop;
99
float cutoff;
100
uint32_t svcount;
101
// extra data for individual prns
102
};
103
104
struct PACKED bestpos
105
{
106
uint32_t solstat; ///< Solution status
107
uint32_t postype; ///< Position type
108
double lat; ///< latitude (deg)
109
double lng; ///< longitude (deg)
110
double hgt; ///< height above mean sea level (m)
111
float undulation; ///< relationship between the geoid and the ellipsoid (m)
112
uint32_t datumid; ///< datum id number
113
float latsdev; ///< latitude standard deviation (m)
114
float lngsdev; ///< longitude standard deviation (m)
115
float hgtsdev; ///< height standard deviation (m)
116
// 4 bytes
117
uint8_t stnid[4]; ///< base station id
118
float diffage; ///< differential position age (sec)
119
float sol_age; ///< solution age (sec)
120
uint8_t svstracked; ///< number of satellites tracked
121
uint8_t svsused; ///< number of satellites used in solution
122
uint8_t svsl1; ///< number of GPS plus GLONASS L1 satellites used in solution
123
uint8_t svsmultfreq; ///< number of GPS plus GLONASS L2 satellites used in solution
124
uint8_t resv; ///< reserved
125
uint8_t extsolstat; ///< extended solution status - OEMV and greater only
126
uint8_t galbeisigmask;
127
uint8_t gpsglosigmask;
128
};
129
130
struct PACKED bestvel
131
{
132
uint32_t solstat;
133
uint32_t veltype;
134
float latency;
135
float age;
136
double horspd;
137
double trkgnd;
138
// + up
139
double vertspd;
140
float resv;
141
};
142
143
union PACKED msgbuffer {
144
bestvel bestvelu;
145
bestpos bestposu;
146
psrdop psrdopu;
147
uint8_t bytes[256];
148
};
149
150
union PACKED msgheader {
151
nova_header nova_headeru;
152
uint8_t data[28];
153
};
154
155
struct PACKED nova_msg_parser
156
{
157
enum
158
{
159
PREAMBLE1 = 0,
160
PREAMBLE2,
161
PREAMBLE3,
162
HEADERLENGTH,
163
HEADERDATA,
164
DATA,
165
CRC1,
166
CRC2,
167
CRC3,
168
CRC4,
169
} nova_state;
170
171
msgbuffer data;
172
uint32_t crc;
173
msgheader header;
174
uint16_t read;
175
} nova_msg;
176
};
177
#endif
178
179