@@ -15,7 +15,7 @@ Glider::Glider(const std::string& path)
1515 Parameters params = Parameters::Load (path);
1616 initializeLogging (params);
1717 factor_manager_ = FactorManager (params);
18-
18+
1919 frame_ = params.frame ;
2020 t_imu_gps_ = params.t_imu_gps ;
2121 r_enu_ned_ = Eigen::Matrix3d::Zero ();
@@ -27,7 +27,7 @@ Glider::Glider(const std::string& path)
2727 LOG (INFO) << " [GLIDER] Using Fixed Lag Smoother: " << std::boolalpha << params.smooth ;
2828 LOG (INFO) << " [GLIDER] Logging to: " << params.log_dir ;
2929 use_dgpsfm_ = params.use_dgpsfm ;
30- vel_threshold_ = params.dgpsfm_threshold ;
30+ dgps_ = Geodetics::DifferentialGpsFromMotion ( params.frame , params. dgpsfm_threshold ) ;
3131
3232 current_odom_ = OdometryWithCovariance::Uninitialized ();
3333
@@ -46,7 +46,34 @@ void Glider::initializeLogging(const Parameters& params) const
4646 if (params.log ) FLAGS_alsologtostderr = 1 ;
4747}
4848
49+
4950void Glider::addGps (int64_t timestamp, Eigen::Vector3d& gps)
51+ {
52+ // route the
53+ if (use_dgpsfm_)
54+ {
55+ addGpsWithHeading (timestamp, gps);
56+ return ;
57+ }
58+
59+ // transform from lat lon To UTM
60+ Eigen::Vector3d meas = Eigen::Vector3d::Zero ();
61+
62+ double easting, northing;
63+ char zone[4 ];
64+ geodetics::LLtoUTM (gps (0 ), gps (1 ), northing, easting, zone);
65+
66+ // keep everything in the enu frame
67+ meas.head (2 ) << easting, northing;
68+ meas (2 ) = gps (2 );
69+
70+ // TODO t_imu_gps_ needs to be rotated!!
71+ meas = meas + t_imu_gps_;
72+
73+ factor_manager_.addGpsFactor (timestamp, meas);
74+ }
75+
76+ void Glider::addGpsWithHeading (int64_t timestamp, Eigen::Vector3d& gps)
5077{
5178 // transform from lat lon To UTM
5279 Eigen::Vector3d meas = Eigen::Vector3d::Zero ();
@@ -62,25 +89,17 @@ void Glider::addGps(int64_t timestamp, Eigen::Vector3d& gps)
6289 // TODO t_imu_gps_ needs to be rotated!!
6390 meas = meas + t_imu_gps_;
6491
65- if (use_dgpsfm_ && current_odom_.isInitialized ( ))
92+ if (factor_manager_. isSystemInitialized () && current_odom_.isMovingFasterThan (dgps_. getVelocityThreshold () ))
6693 {
67- if (factor_manager_.isSystemInitialized () && current_odom_.isMovingFasterThan (vel_threshold_))
68- {
69- LOG (INFO) << " [GLIDER] Adding DGPS heading" ;
70- double heading_ne = geodetics::gpsHeading (last_gps_ (0 ), last_gps_ (1 ), gps (0 ), gps (1 ));
71- double heading_en = geodetics::geodeticToENU (heading_ne);
72- factor_manager_.addGpsFactor (timestamp, meas, heading_en, true );
73- }
74- else
75- {
76- factor_manager_.addGpsFactor (timestamp, meas, 0.0 , false );
77- }
94+ LOG (INFO) << " [GLIDER] Adding DGPS heading" ;
95+ double heading = dgps_.getHeading (gps);
96+ factor_manager_.addGpsFactor (timestamp, meas, heading, true );
7897 }
7998 else
8099 {
81- factor_manager_.addGpsFactor (timestamp, meas);
100+ dgps_.setLastGps (gps);
101+ factor_manager_.addGpsFactor (timestamp, meas, 0.0 , false );
82102 }
83- last_gps_ = gps;
84103}
85104
86105void Glider::addImu (int64_t timestamp, Eigen::Vector3d& accel, Eigen::Vector3d& gyro, Eigen::Vector4d& quat)
@@ -92,8 +111,6 @@ void Glider::addImu(int64_t timestamp, Eigen::Vector3d& accel, Eigen::Vector3d&
92111 Eigen::Vector4d quat_enu = rotateQuaternion (r_enu_ned_, quat);
93112
94113 factor_manager_.addImuFactor (timestamp, accel_enu, gyro_enu, quat_enu);
95- // factor_manager_.addImuFactor(timestamp, accel, gyro, quat);'
96- LOG (FATAL) << " [GLIDER] NED frame not supported yet" ;
97114 }
98115 else if (frame_ == " enu" )
99116 {
0 commit comments