Skip to content
Snippets Groups Projects
Commit 7338f7b3 authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

wip test

parent 14e0b62b
No related branches found
No related tags found
3 merge requests!20new tag,!19new tag,!17Resolve "TDCP batch implementation"
This commit is part of merge request !17. Comments created here will be created in the context of that merge request.
#include "gtest/utils_gtest.h" #include "gtest/utils_gtest.h"
#include "gnss_utils/tdcp.h"
#include "gnss_utils/snapshot.h"
#include "gnss_utils/utils/satellite.h" #include "gnss_utils/utils/satellite.h"
#include "gnss_utils/utils/transformations.h" #include "gnss_utils/utils/transformations.h"
...@@ -19,7 +21,7 @@ Vector3d computeRandomReceiverLatLonAlt() ...@@ -19,7 +21,7 @@ Vector3d computeRandomReceiverLatLonAlt()
void computeRandomVisibleSatellite(const Vector3d& receiver_latlonalt, void computeRandomVisibleSatellite(const Vector3d& receiver_latlonalt,
Vector3d& sat_ENU, Vector3d& sat_ENU,
Vector3d& sat_ECEF, Vector3d& sat_ECEF,
Vectox_kd& sat_azel, Vector2d& sat_azel,
double range) double range)
{ {
Vector3d t_ECEF_ENU, t_ENU_ECEF; Vector3d t_ECEF_ENU, t_ENU_ECEF;
...@@ -30,7 +32,7 @@ void computeRandomVisibleSatellite(const Vector3d& receiver_latlonalt, ...@@ -30,7 +32,7 @@ void computeRandomVisibleSatellite(const Vector3d& receiver_latlonalt,
computeEnuEcefFromLatLonAlt(receiver_latlonalt, R_ENU_ECEF, t_ENU_ECEF); computeEnuEcefFromLatLonAlt(receiver_latlonalt, R_ENU_ECEF, t_ENU_ECEF);
// random elevation and azimuth // random elevation and azimuth
sat_azel = Vectox_kd::Random(); // in [-1, 1] sat_azel = Vector2d::Random(); // in [-1, 1]
sat_azel(0) *= M_PI; // in [-pi, pi] sat_azel(0) *= M_PI; // in [-pi, pi]
sat_azel(1) = (sat_azel(1)/2 + 0.5) * M_PI / 2; // in [0, pi/2] sat_azel(1) = (sat_azel(1)/2 + 0.5) * M_PI / 2; // in [0, pi/2]
range = VectorXd::Random(1)(0) * 5e2 + 1e3; // in [500, 1500] range = VectorXd::Random(1)(0) * 5e2 + 1e3; // in [500, 1500]
...@@ -53,7 +55,7 @@ TEST(Tdcp, Tdcp) ...@@ -53,7 +55,7 @@ TEST(Tdcp, Tdcp)
Vector3d sat_ENU, sat_ECEF; Vector3d sat_ENU, sat_ECEF;
Vector3d x_r_LLA, x_r_ECEF, x_k_LLA, x_k_ECEF, d_ECEF; Vector3d x_r_LLA, x_r_ECEF, x_k_LLA, x_k_ECEF, d_ECEF;
Matrix3d R_ENU_ECEF; Matrix3d R_ENU_ECEF;
Vectox_kd azel, azel2; Vector2d azel, azel2;
Vector4d d, d_gt; Vector4d d, d_gt;
Matrix4d cov_d; Matrix4d cov_d;
double residual; double residual;
...@@ -87,21 +89,21 @@ TEST(Tdcp, Tdcp) ...@@ -87,21 +89,21 @@ TEST(Tdcp, Tdcp)
{ {
common_sats.insert(j); common_sats.insert(j);
// Satellite 1 (random) // Satellite r (random)
computeRandomVisibleSatellite(x_r_LLA, sat_ENU, sat_ECEF, azel, range); computeRandomVisibleSatellite(x_r_LLA, sat_ENU, sat_ECEF, azel, range);
EXPECT_MATRIX_APPROX(azel, computeAzel(sat_ECEF, x_r_ECEF), 1e-6); EXPECT_MATRIX_APPROX(azel, computeAzel(sat_ECEF, x_r_ECEF), 1e-6);
Satellite sat1({0,j,sat_ECEF, Vector3d::Zero(), 1.0, 0, 0, 1}); Satellite sat_r({0,j,sat_ECEF, Vector3d::Zero(), 1.0, 0, 0, 1});
snapshot1.getSatellites().emplace(j, sat1); snapshot_r->getSatellites().emplace(j, sat_r);
// TODO: compute range and add random clock bias // TODO: compute range and add random clock bias
// Satellite 2 (random) // Satellite k (random)
computeRandomVisibleSatellite(x_k_LLA, sat_ENU, sat_ECEF, azel, range); computeRandomVisibleSatellite(x_k_LLA, sat_ENU, sat_ECEF, azel, range);
EXPECT_MATRIX_APPROX(azel, computeAzel(sat_ECEF, x_k_ECEF), 1e-6); EXPECT_MATRIX_APPROX(azel, computeAzel(sat_ECEF, x_k_ECEF), 1e-6);
Satellite sat2({0,j,sat_ECEF, Vector3d::Zero(), 1.0, 0, 0, 1}); Satellite sat_k({0,j,sat_ECEF, Vector3d::Zero(), 1.0, 0, 0, 1});
snapshot2.getSatellites().emplace(j, sat2); snapshot_k->getSatellites().emplace(j, sat_k);
// TODO: compute range and add random clock bias // TODO: compute range and add random clock bias
} }
...@@ -120,7 +122,7 @@ TEST(Tdcp, Tdcp) ...@@ -120,7 +122,7 @@ TEST(Tdcp, Tdcp)
EXPECT_TRUE(tdcp_ok); EXPECT_TRUE(tdcp_ok);
EXPECT_MATRIX_APPROX(d, d_gt, 1e-9); EXPECT_MATRIX_APPROX(d, d_gt, 1e-9);
EXPECT_LEQ(residual, 1e-9); EXPECT_LE(residual, 1e-9);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment