Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_GPS/AP_GPS_NOVA.h
9770 views
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 https://hexagondownloads.blob.core.windows.net/public/Novatel/assets/Documents/Manuals/om-20000129/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
static const uint8_t NOVA_PSRDOP = 174;
93
struct PACKED psrdop
94
{
95
float gdop;
96
float pdop;
97
float hdop;
98
float htdop;
99
float tdop;
100
float cutoff;
101
uint32_t svcount;
102
// extra data for individual prns
103
};
104
105
static const uint8_t NOVA_BESTPOS = 42;
106
struct PACKED bestpos
107
{
108
uint32_t solstat; ///< Solution status
109
uint32_t postype; ///< Position type
110
double lat; ///< latitude (deg)
111
double lng; ///< longitude (deg)
112
double hgt; ///< height above mean sea level (m)
113
float undulation; ///< relationship between the geoid and the ellipsoid (m)
114
uint32_t datumid; ///< datum id number
115
float latsdev; ///< latitude standard deviation (m)
116
float lngsdev; ///< longitude standard deviation (m)
117
float hgtsdev; ///< height standard deviation (m)
118
// 4 bytes
119
uint8_t stnid[4]; ///< base station id
120
float diffage; ///< differential position age (sec)
121
float sol_age; ///< solution age (sec)
122
uint8_t svstracked; ///< number of satellites tracked
123
uint8_t svsused; ///< number of satellites used in solution
124
uint8_t svsl1; ///< number of GPS plus GLONASS L1 satellites used in solution
125
uint8_t svsmultfreq; ///< number of GPS plus GLONASS L2 satellites used in solution
126
uint8_t resv; ///< reserved
127
uint8_t extsolstat; ///< extended solution status - OEMV and greater only
128
uint8_t galbeisigmask;
129
uint8_t gpsglosigmask;
130
};
131
132
static const uint8_t NOVA_BESTVEL = 99;
133
struct PACKED bestvel
134
{
135
uint32_t solstat;
136
uint32_t veltype;
137
float latency;
138
float age;
139
double horspd;
140
double trkgnd;
141
// + up
142
double vertspd;
143
float resv;
144
};
145
146
union PACKED msgbuffer {
147
bestvel bestvelu;
148
bestpos bestposu;
149
psrdop psrdopu;
150
uint8_t bytes[256];
151
};
152
153
union PACKED msgheader {
154
nova_header nova_headeru;
155
uint8_t data[28];
156
};
157
158
struct PACKED nova_msg_parser
159
{
160
enum
161
{
162
PREAMBLE1 = 0,
163
PREAMBLE2,
164
PREAMBLE3,
165
HEADERLENGTH,
166
HEADERDATA,
167
DATA,
168
CRC1,
169
CRC2,
170
CRC3,
171
CRC4,
172
} nova_state;
173
174
msgbuffer data;
175
uint32_t crc;
176
msgheader header;
177
uint16_t read;
178
} nova_msg;
179
};
180
#endif
181
182