5 #define ALLOW_DOUBLE_MATH_FUNCTIONS 19 {
Vector2f(-35.3647759314918
f, 149.16265692810987
f),
20 Vector2f(-35.36279922658029
f, 149.16352169591426
f),
21 Vector2f(-35.36214956969903
f, 149.16461410046492
f),
true },
22 {
Vector2f(-35.36438601157189
f, 149.16613916088568
f),
23 Vector2f(-35.364432558610254
f, 149.16287313113048
f),
24 Vector2f(-35.36491510034746
f, 149.16365837225004
f),
false },
45 loc.
lat = pt.x * 1.0e7f;
46 loc.
lng = pt.y * 1.0e7f;
58 hal.
console->
printf(
"Failed waypoint test %u\n", (
unsigned)i);
70 float dist2, bearing2;
79 float brg_error = bearing2-
bearing;
80 if (brg_error > 180) {
82 }
else if (brg_error < -180) {
86 if (fabsf(dist - dist2) > 1.0
f ||
88 hal.
console->
printf(
"Failed offset test brg_error=%f dist_error=%f\n",
89 (
double)brg_error, (
double)(dist - dist2));
96 { 1000.0f, 1000.0f, sqrtf(2.0
f) * 1000.0f, 45.0f },
97 { 1000.0f, -1000.0f, sqrtf(2.0
f) * 1000.0f, -45.0f },
98 { 1000.0f, 0.0f, 1000.0f, 0.0f },
99 { 0.0f, 1000.0f, 1000.0f, 90.0f },
106 loc.
lat = -35 * 1.0e7f;
107 loc.
lng = 149 * 1.0e7f;
134 loc2.
lat += 10000000;
139 loc2.
lng += 10000000;
143 for (int32_t i = 0; i < 100; i++) {
152 for (int32_t i = 0; i < 100; i++) {
162 for (int32_t i = 0; i < 100; i++) {
171 for (int32_t i = 0; i < 100; i++) {
182 static const struct {
186 { 1500 + 100*36000, 1500 },
187 { -1500 - 100*36000, -1500 },
190 static const struct {
194 { 1500 + 100*36000, 1500 },
195 { -1500 - 100*36000, 34500 },
198 static const struct {
202 { 0.2f*
M_PI + 100*
M_PI, 0.2f*M_PI },
203 { -0.2f*
M_PI - 100*
M_PI, -0.2f*M_PI },
244 #define D2R DEG_TO_RAD_DOUBLE 247 static const double MAX_DIST_ERROR_M = 1e-6;
250 static const double MAX_ANGLE_ERROR_SEC = 1e-7;
251 static const double MAX_ANGLE_ERROR_RAD = (MAX_ANGLE_ERROR_SEC * (
D2R / (double)3600.0));
254 static const double EARTH_A = 6378137.0;
256 static const double EARTH_B = 6356752.31424517929553985595703125;
259 #define NUM_COORDS 10 274 ecefs[1] =
Vector3d(-EARTH_A, 0, 0);
276 ecefs[3] =
Vector3d(0, -EARTH_A, 0);
278 ecefs[5] =
Vector3d(0, 0, -EARTH_B);
279 ecefs[6] =
Vector3d(0, 0, (EARTH_B+22));
280 ecefs[7] =
Vector3d(0, 0, -(EARTH_B+22));
281 ecefs[8] =
Vector3d((22+EARTH_A), 0, 0);
282 ecefs[9] =
Vector3d(-(22+EARTH_A), 0, 0);
290 double x_err = fabs(ecef[0] - ecefs[i][0]);
291 double y_err = fabs(ecef[1] - ecefs[i][1]);
292 double z_err = fabs(ecef[2] - ecefs[i][2]);
293 if ((x_err < MAX_DIST_ERROR_M) &&
294 (y_err < MAX_DIST_ERROR_M) &&
295 (z_err < MAX_DIST_ERROR_M)) {
299 hal.
console->
printf(
"(%f - %f) (%f - %f) (%f - %f) => %.10f %.10f %.10f\n",
300 ecef[0], ecefs[i][0], ecef[1], ecefs[i][1], ecef[2], ecefs[i][2], x_err, y_err, z_err);
311 double lat_err = fabs(llh[0] - llhs[i][0]);
312 double lon_err = fabs(llh[1] - llhs[i][1]);
313 double hgt_err = fabs(llh[2] - llhs[i][2]);
314 if ((lat_err < MAX_ANGLE_ERROR_RAD) &&
315 (lon_err < MAX_ANGLE_ERROR_RAD) &&
316 (hgt_err < MAX_DIST_ERROR_M)) {
320 hal.
console->
printf(
"%.10f %.10f %.10f\n", lat_err, lon_err, hgt_err);
Vector2< float > Vector2f
static const struct @130 wrap_360_tests[]
static const struct @127 test_points[]
Vector3< double > Vector3d
AP_HAL::UARTDriver * console
void wgsllh2ecef(const Vector3d &llh, Vector3d &ecef)
auto wrap_360_cd(const T angle) -> decltype(wrap_360(angle, 100.f))
float get_distance(const struct Location &loc1, const struct Location &loc2)
void wgsecef2llh(const Vector3d &ecef, Vector3d &llh)
auto wrap_180_cd(const T angle) -> decltype(wrap_180(angle, 100.f))
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
static void test_wrap_cd(void)
void location_offset(struct Location &loc, float ofs_north, float ofs_east)
static struct Location location_from_point(Vector2f pt)
int32_t lat
param 3 - Latitude * 10**7
int32_t get_bearing_cd(const struct Location &loc1, const struct Location &loc2)
static const struct @131 wrap_PI_tests[]
virtual void printf(const char *,...) FMT_PRINTF(2
static void test_wgs_conversion_functions(void)
static void test_offset(void)
float wrap_PI(const T radian)
static void test_accuracy(void)
static const struct @128 test_offsets[]
int32_t lng
param 4 - Longitude * 10**7
static void test_passed_waypoint(void)
bool location_passed_point(const struct Location &location, const struct Location &point1, const struct Location &point2)
static const struct @129 wrap_180_tests[]
static void test_one_offset(const struct Location &loc, float ofs_north, float ofs_east, float dist, float bearing)