gps_pvt 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/README.md +86 -0
- data/Rakefile +86 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ext/gps_pvt/Coordinate/Coordinate_wrap.cxx +6613 -0
- data/ext/gps_pvt/GPS/GPS_wrap.cxx +16019 -0
- data/ext/gps_pvt/SylphideMath/SylphideMath_wrap.cxx +21050 -0
- data/ext/gps_pvt/extconf.rb +70 -0
- data/ext/ninja-scan-light/tool/navigation/EGM.h +2971 -0
- data/ext/ninja-scan-light/tool/navigation/GPS.h +2432 -0
- data/ext/ninja-scan-light/tool/navigation/GPS_Solver.h +479 -0
- data/ext/ninja-scan-light/tool/navigation/GPS_Solver_Base.h +1081 -0
- data/ext/ninja-scan-light/tool/navigation/GPS_Solver_MultiFrequency.h +199 -0
- data/ext/ninja-scan-light/tool/navigation/GPS_Solver_RAIM.h +210 -0
- data/ext/ninja-scan-light/tool/navigation/MagneticField.h +928 -0
- data/ext/ninja-scan-light/tool/navigation/NTCM.h +211 -0
- data/ext/ninja-scan-light/tool/navigation/RINEX.h +1781 -0
- data/ext/ninja-scan-light/tool/navigation/WGS84.h +186 -0
- data/ext/ninja-scan-light/tool/navigation/coordinate.h +406 -0
- data/ext/ninja-scan-light/tool/param/bit_array.h +145 -0
- data/ext/ninja-scan-light/tool/param/complex.h +558 -0
- data/ext/ninja-scan-light/tool/param/matrix.h +4049 -0
- data/ext/ninja-scan-light/tool/param/matrix_fixed.h +665 -0
- data/ext/ninja-scan-light/tool/param/matrix_special.h +562 -0
- data/ext/ninja-scan-light/tool/param/quaternion.h +765 -0
- data/ext/ninja-scan-light/tool/param/vector3.h +651 -0
- data/ext/ninja-scan-light/tool/swig/Coordinate.i +177 -0
- data/ext/ninja-scan-light/tool/swig/GPS.i +1102 -0
- data/ext/ninja-scan-light/tool/swig/SylphideMath.i +1234 -0
- data/ext/ninja-scan-light/tool/swig/extconf.rb +5 -0
- data/ext/ninja-scan-light/tool/swig/makefile +53 -0
- data/ext/ninja-scan-light/tool/swig/spec/GPS_spec.rb +417 -0
- data/ext/ninja-scan-light/tool/swig/spec/SylphideMath_spec.rb +489 -0
- data/gps_pvt.gemspec +57 -0
- data/lib/gps_pvt/receiver.rb +375 -0
- data/lib/gps_pvt/ubx.rb +148 -0
- data/lib/gps_pvt/version.rb +5 -0
- data/lib/gps_pvt.rb +9 -0
- data/sig/gps_pvt.rbs +4 -0
- metadata +117 -0
@@ -0,0 +1,211 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2017, M.Naruoka (fenrir)
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
* are permitted provided that the following conditions are met:
|
7
|
+
*
|
8
|
+
* - Redistributions of source code must retain the above copyright notice,
|
9
|
+
* this list of conditions and the following disclaimer.
|
10
|
+
* - Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer in the documentation
|
12
|
+
* and/or other materials provided with the distribution.
|
13
|
+
* - Neither the name of the naruoka.org nor the names of its contributors
|
14
|
+
* may be used to endorse or promote products derived from this software
|
15
|
+
* without specific prior written permission.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
19
|
+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
21
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
+
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
23
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
24
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
25
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
26
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
28
|
+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
*
|
30
|
+
*/
|
31
|
+
|
32
|
+
#ifndef __NTCM_H__
|
33
|
+
#define __NTCM_H__
|
34
|
+
|
35
|
+
#include <cmath>
|
36
|
+
|
37
|
+
#include "WGS84.h"
|
38
|
+
#include "MagneticField.h"
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Global TEC model NTCM-GL
|
42
|
+
*
|
43
|
+
* @see N. Jakowski, M.M. Hoque, and C. Mayer, �gA new global TEC model for
|
44
|
+
* estimating transionospheric radio wave propagation errors,�h Journal of
|
45
|
+
* Geodesy, 10.1007/s00190-011-0455-1, 2011
|
46
|
+
*/
|
47
|
+
template <class FloatT>
|
48
|
+
class NTCM_GL_Generic {
|
49
|
+
public:
|
50
|
+
typedef FloatT float_t;
|
51
|
+
static const float_t C[];
|
52
|
+
|
53
|
+
static const float_t lt_D;
|
54
|
+
static const float_t P_F1;
|
55
|
+
static float_t f1(
|
56
|
+
const float_t <,
|
57
|
+
const float_t &phi, const float_t &delta){
|
58
|
+
float_t
|
59
|
+
v_D((lt - lt_D) / 24 * M_PI * 2),
|
60
|
+
v_SD(lt / 12 * M_PI * 2),
|
61
|
+
v_TD(lt / 8 * M_PI * 2);
|
62
|
+
float_t
|
63
|
+
cos_Chi_star(std::sin(phi) * std::sin(delta) + std::cos(phi) * std::cos(delta)),
|
64
|
+
cos_Chi_star2(cos_Chi_star - std::sin(delta) * phi * 2 / M_PI),
|
65
|
+
cos_Chi_star3(std::sqrt(cos_Chi_star + P_F1));
|
66
|
+
return cos_Chi_star3
|
67
|
+
+ (C[0] * std::cos(v_D)
|
68
|
+
+ C[1] * std::cos(v_SD) + C[2] * std::sin(v_SD)
|
69
|
+
+ C[3] * std::cos(v_TD) + C[4] * std::sin(v_TD)) * cos_Chi_star;
|
70
|
+
}
|
71
|
+
|
72
|
+
static const float_t doy_A, doy_SA;
|
73
|
+
static float_t f2(const float_t &doy){
|
74
|
+
float_t
|
75
|
+
v_A((doy - doy_A) / 365.25 * M_PI * 2),
|
76
|
+
v_SA((doy - doy_SA) / 365.25 * M_PI * 4);
|
77
|
+
return C[5] * std::cos(v_A) + C[6] * std::cos(v_SA) + 1;
|
78
|
+
}
|
79
|
+
|
80
|
+
static float_t f3(const float_t &phi_m){
|
81
|
+
return C[7] * std::cos(phi_m) + 1;
|
82
|
+
}
|
83
|
+
|
84
|
+
static const float_t phi_c1, sigma_c1;
|
85
|
+
static const float_t phi_c2, sigma_c2;
|
86
|
+
static float_t f4(const float_t &phi_m) {
|
87
|
+
float_t
|
88
|
+
ec1(std::pow((phi_m - phi_c1) / sigma_c1, 2) * -0.5),
|
89
|
+
ec2(std::pow((phi_m - phi_c2) / sigma_c2, 2) * -0.5);
|
90
|
+
return C[8] * std::exp(ec1) + C[9] * std::exp(ec2) + 1;
|
91
|
+
}
|
92
|
+
|
93
|
+
static float_t f5(const float_t &f_10_7){
|
94
|
+
return C[10] + (C[11] * f_10_7);
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Calculate vertical Total electron count (TEC)
|
99
|
+
* This function is a implementation in accordance with the paper description.
|
100
|
+
*
|
101
|
+
* @param lt Local time in hours [0,24)
|
102
|
+
* @param phi Geographic latitude in radians
|
103
|
+
* @param delta Declination of the Sun
|
104
|
+
* @param doy Day of year in days [0,365.25)
|
105
|
+
* @param phi_m Geomagnetic latitude in radians
|
106
|
+
* @param f_10_7 Solar activity index
|
107
|
+
*/
|
108
|
+
static float_t tec_vert(
|
109
|
+
const float_t <, const float_t &phi, const float_t &delta,
|
110
|
+
const float_t &doy,
|
111
|
+
const float_t &phi_m,
|
112
|
+
const float_t &f_10_7){
|
113
|
+
return f1(lt, phi, delta) * f2(doy) * f3(phi_m) * f4(phi_m) * f5(f_10_7);
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Calculate vertical Total electron count (TEC)
|
118
|
+
* This function invokes the original tec_vert with conversion
|
119
|
+
*
|
120
|
+
* @param phi Geographic latitude in radians
|
121
|
+
* @param lambda Geographic longitude in radians
|
122
|
+
* @param year_utc UTC floating-point year (2000.0 means 2000/1/1 00:00:00)
|
123
|
+
* @param mag_model Magnetic field model to calculate geomagnetic latitude, which requires mag_model.DOF >= 1 at least
|
124
|
+
* @param f_10_7 Solar activity index
|
125
|
+
*/
|
126
|
+
static float_t tec_vert(
|
127
|
+
const float_t &phi, const float_t lambda,
|
128
|
+
const float_t &year_utc,
|
129
|
+
const typename MagneticFieldGeneric<FloatT>::model_t &mag_model,
|
130
|
+
const float_t &f_10_7){
|
131
|
+
|
132
|
+
float_t year_int, year_frac(std::modf(year_utc, &year_int));
|
133
|
+
int year(year_int);
|
134
|
+
|
135
|
+
int days(365);
|
136
|
+
if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)){days++;} // leap day
|
137
|
+
float_t day_utc, hr_lt((std::modf(year_utc * days, &day_utc) * 24) + (lambda / M_PI * 12));
|
138
|
+
if(hr_lt < 0){hr_lt += 24;}
|
139
|
+
else if(hr_lt >= 24){hr_lt -= 24;}
|
140
|
+
|
141
|
+
float_t phi_m(
|
142
|
+
MagneticFieldGeneric<float_t>::geomagnetic_latlng(
|
143
|
+
mag_model,
|
144
|
+
WGS84Generic<float_t>::geocentric_latitude(phi), lambda).latitude);
|
145
|
+
|
146
|
+
// sun declination
|
147
|
+
// @see https://en.wikipedia.org/wiki/Position_of_the_Sun#Declination_of_the_Sun_as_seen_from_Earth
|
148
|
+
float_t delta(std::asin(
|
149
|
+
std::sin(-23.44 / 180 * M_PI) * std::cos(M_PI * 2 * (year_frac + (10.0 / 365)))));
|
150
|
+
|
151
|
+
return tec_vert(hr_lt, phi, delta, year_frac * 365.25, phi_m, f_10_7);
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Calculate vertical Total electron count (TEC)
|
156
|
+
* This function invokes the original tec_vert with conversion
|
157
|
+
*
|
158
|
+
* @param phi Geographic latitude in radians
|
159
|
+
* @param lambda Geographic longitude in radians
|
160
|
+
* @param year_utc UTC floating-point year
|
161
|
+
* @param f_10_7 Solar activity index
|
162
|
+
*/
|
163
|
+
static float_t tec_vert(
|
164
|
+
const float_t &phi, const float_t lambda,
|
165
|
+
const float_t &year_utc,
|
166
|
+
const float_t &f_10_7){
|
167
|
+
|
168
|
+
return tec_vert(phi, lambda, year_utc,
|
169
|
+
IGRF12Generic<float_t>::get_model(year_utc, 1),
|
170
|
+
f_10_7);
|
171
|
+
}
|
172
|
+
};
|
173
|
+
|
174
|
+
template <class FloatT>
|
175
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::C[] = {
|
176
|
+
0.89656,
|
177
|
+
0.16984,
|
178
|
+
-0.02166,
|
179
|
+
0.05928,
|
180
|
+
0.00738,
|
181
|
+
0.13912,
|
182
|
+
-0.17593,
|
183
|
+
-0.34545,
|
184
|
+
1.1167,
|
185
|
+
1.1573,
|
186
|
+
-4.3356,
|
187
|
+
0.17775
|
188
|
+
};
|
189
|
+
|
190
|
+
template <class FloatT>
|
191
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::lt_D = 14;
|
192
|
+
template <class FloatT>
|
193
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::P_F1 = 0.4;
|
194
|
+
|
195
|
+
template <class FloatT>
|
196
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::doy_A = 18;
|
197
|
+
template <class FloatT>
|
198
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::doy_SA = 6;
|
199
|
+
|
200
|
+
template <class FloatT>
|
201
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::phi_c1 = M_PI / 180 * 16;
|
202
|
+
template <class FloatT>
|
203
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::phi_c2 = M_PI / 180 * -10;
|
204
|
+
template <class FloatT>
|
205
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::sigma_c1 = M_PI / 180 * 12;
|
206
|
+
template <class FloatT>
|
207
|
+
const typename NTCM_GL_Generic<FloatT>::float_t NTCM_GL_Generic<FloatT>::sigma_c2 = M_PI / 180 * 13;
|
208
|
+
|
209
|
+
typedef NTCM_GL_Generic<double> NTCM_GL;
|
210
|
+
|
211
|
+
#endif /* __NTCM_H__ */
|