@@ -115,9 +115,9 @@ using symbol_shorthand::S; // switch factor
115
115
bool enable_IMUPreintegration_factor = 0 ; // enable imu pre-integration factor
116
116
bool enable_Pr_factor = 1 ; // enable pseudorange factor
117
117
bool enbale_CVM_factor = 1 ; // enable constant velocity factor
118
- bool enbale_SCP_factor = 0 ; // enable switchable constraint pseudorange factor
118
+ bool enbale_SCP_factor = 1 ; // enable switchable constraint pseudorange factor
119
119
bool enable_GNSS_loose_factor = 0 ; // enbale GNSS loose factor (use WLS solution)
120
- bool enable_IMU_LINEAR_factor = 1 ; // enable imu linear factor (similar to ekf)
120
+ bool enable_IMU_LINEAR_factor = 0 ; // enable imu linear factor (similar to ekf)
121
121
122
122
double _vx = 0 , _vy = 0 , _vz = 0 ; //
123
123
clock_t old_clock = clock();
@@ -162,6 +162,8 @@ nlosExclusion::GNSS_Raw_Array _GNSS_data; // save the GNSS data
162
162
Point3 nomXYZ (-2418954.90428 ,5384679.60663 ,2407391.40139 ); // niutoujiao data
163
163
// Point3 nomXYZ(-2417729.42895,5384849.60804,2408314.07879); // initial position : kowlontoon data
164
164
// Point3 nomXYZ(0, 0, 0); // niutoujiao data
165
+ // Point3 nomXYZ(-2419091.11542, 5385376.36368, 2405705.64485); // whomopo
166
+
165
167
double prediction_pre_t =0 ;
166
168
167
169
@@ -367,48 +369,42 @@ double nstamp = 0;
367
369
368
370
369
371
/* ***in the tightly coupled GNSS/INS integration, transfer imu from body to local frame***/
370
- x = imu_track.orientation .x ;
371
- y = imu_track.orientation .y ;
372
- z = imu_track.orientation .z ;
373
- w = imu_track.orientation .w ;
374
- double imu_roll, imu_pitch, imu_yaw;
375
- tf::Quaternion imu_orientation;
376
- tf::quaternionMsgToTF (input->orientation , imu_orientation);
377
- tf::Matrix3x3 (imu_orientation).getRPY (imu_roll, imu_pitch, imu_yaw);
378
- // cout<<"yaw : = " <<imu_yaw*(180/3.14)<<endl;
379
- // cout<<imu_track.orientation.x<<endl;
380
- // cout<<"imu_track.linear_acceleration.x : = " <<endl<<imu_track.linear_acceleration.x<<endl;
381
- Eigen::Quaterniond q (w,x,y,z);
382
- q.normalized ();
383
- Eigen::Matrix3d rotation_matrix;
384
- rotation_matrix=q.toRotationMatrix ();
372
+
373
+ Eigen::AngleAxisd rollAngle (0 , Eigen::Vector3d::UnitZ ());
374
+ Eigen::AngleAxisd yawAngle (90 , Eigen::Vector3d::UnitY ());
375
+ Eigen::AngleAxisd pitchAngle (0 , Eigen::Vector3d::UnitX ());
376
+
377
+ Eigen::Quaternion<double > q_rotation = rollAngle * yawAngle * pitchAngle;
378
+
379
+ Eigen::Matrix3d rotationMatrix = q_rotation.matrix ();
380
+
385
381
orientation_matrix.resize (3 ,1 );
386
382
orientation_matrix<<imu_track.linear_acceleration .x ,
387
383
imu_track.linear_acceleration .y ,
388
384
imu_track.linear_acceleration .z ;
389
- acceleration_rotation = rotation_matrix .transpose () * orientation_matrix;
385
+ acceleration_rotation = rotationMatrix .transpose () * orientation_matrix;
390
386
391
387
// cout<<"acceleration_rotation : = " <<endl<<acceleration_rotation<<endl;
392
388
imu_track.linear_acceleration .x = acceleration_rotation (0 ,0 );
393
389
imu_track.linear_acceleration .y = acceleration_rotation (1 ,0 );
394
390
imu_track.linear_acceleration .z = acceleration_rotation (2 ,0 );
395
391
396
- /* ***in the tightly coupled GNSS/INS integration, navigation frame is ECEF***/
397
- if (originllh_span.rows () > 1 )
398
- {
399
- double lon = (double )originllh_span (0 ) * D2R;
400
- double lat = (double )originllh_span (1 ) * D2R;
392
+ // / ****in the tightly coupled GNSS/INS integration, navigation frame is ECEF***/
393
+ // if(originllh_span.rows() > 1)
394
+ // {
395
+ // double lon = (double)originllh_span(0) * D2R;
396
+ // double lat = (double)originllh_span(1) * D2R;
401
397
402
398
403
- double e = imu_track.linear_acceleration .x ; // acc in enu
404
- double n = imu_track.linear_acceleration .y ;
405
- double u = imu_track.linear_acceleration .z ;
399
+ // double e = imu_track.linear_acceleration.x; // acc in enu
400
+ // double n = imu_track.linear_acceleration.y;
401
+ // double u = imu_track.linear_acceleration.z;
406
402
407
403
408
- imu_track.linear_acceleration .x = 0 - sin (lon) * e - cos (lon) * sin (lat) * n + cos (lon) * cos (lat) * u; // transfrom the acc from enu to ecef
409
- imu_track.linear_acceleration .y = 0 + cos (lon) * e - sin (lon) * sin (lat) * n + cos (lat) * sin (lon) * u;
410
- imu_track.linear_acceleration .z = 0 + cos (lat) * n + sin (lat) * u;
411
- }
404
+ // imu_track.linear_acceleration.x = 0 - sin(lon) * e - cos(lon) * sin(lat) * n + cos(lon) * cos(lat) * u; // transfrom the acc from enu to ecef
405
+ // imu_track.linear_acceleration.y = 0 + cos(lon) * e - sin(lon) * sin(lat) * n + cos(lat) * sin(lon) * u;
406
+ // imu_track.linear_acceleration.z = 0 + cos(lat) * n + sin(lat) * u;
407
+ // }
412
408
413
409
imu_up =1 ;
414
410
imu_co++;
@@ -473,6 +469,7 @@ void ubloxFix_callback(const sensor_msgs::NavSatFixConstPtr& fix_msg)
473
469
474
470
if (ini_navf.latitude == NULL )
475
471
{
472
+
476
473
ini_navf = navfix_;
477
474
std::cout<<" ini_navf.header -> " <<ini_navf.header <<std::endl;
478
475
originllh.resize (3 , 1 );
@@ -1180,6 +1177,7 @@ void ubloxFix_callback(const sensor_msgs::NavSatFixConstPtr& fix_msg)
1180
1177
1181
1178
if (ini_navf_span.latitude == NULL )
1182
1179
{
1180
+ std::cout << std::setprecision (12 );
1183
1181
ini_navf_span = navfix_;
1184
1182
std::cout<<" ini_navf_span.header -> " <<ini_navf_span.header <<std::endl;
1185
1183
originllh_span.resize (3 , 1 );
@@ -1292,6 +1290,7 @@ int main(int argc, char* argv[])
1292
1290
1293
1291
Values initial_values;
1294
1292
int correction_count = 0 ;
1293
+ int switchable_count = 0 ;
1295
1294
initial_values.insert (X (correction_count), prior_pose);
1296
1295
initial_values.insert (V (correction_count), prior_velocity);
1297
1296
initial_values.insert (B (correction_count), prior_imu_bias);
@@ -1343,11 +1342,17 @@ int main(int argc, char* argv[])
1343
1342
// double accel_noise_sigma = 0.03924;
1344
1343
// double gyro_noise_sigma = 0.0205689024915;
1345
1344
1346
- double accel_noise_sigma = 0.1624 ;
1347
- double gyro_noise_sigma = 0.205689024915 ;
1345
+ // double accel_noise_sigma = 0.1624;
1346
+ // double gyro_noise_sigma = 0.205689024915;
1348
1347
1349
- double accel_bias_rw_sigma = 0.1905 ;
1350
- double gyro_bias_rw_sigma = 0.1454441043 ;
1348
+ // double accel_bias_rw_sigma = 0.1905;
1349
+ // double gyro_bias_rw_sigma = 0.1454441043;
1350
+
1351
+ // We use the sensor specs to build the noise model for the IMU factor.
1352
+ double accel_noise_sigma = 0.0003924 ;
1353
+ double gyro_noise_sigma = 0.000205689024915 ;
1354
+ double accel_bias_rw_sigma = 0.004905 ;
1355
+ double gyro_bias_rw_sigma = 0.000001454441043 ;
1351
1356
1352
1357
Matrix33 measured_acc_cov = Matrix33::Identity (3 ,3 ) * pow (accel_noise_sigma,2 );
1353
1358
Matrix33 measured_omega_cov = Matrix33::Identity (3 ,3 ) * pow (gyro_noise_sigma,2 );
@@ -1390,7 +1395,7 @@ int main(int argc, char* argv[])
1390
1395
// exactly the same, so keeping this for simplicity.
1391
1396
1392
1397
// All priors have been set up, now iterate through the data file.
1393
- ros::Rate rate (20 ); // usually ok when rate(10)
1398
+ ros::Rate rate (10 ); // usually ok when rate(10) 20
1394
1399
while (ros::ok ()) { // ros::ok()
1395
1400
ros::spinOnce ();
1396
1401
rate.sleep ();
@@ -1407,7 +1412,7 @@ int main(int argc, char* argv[])
1407
1412
imu (3 ) = imu_track.angular_velocity .x ;
1408
1413
imu (4 ) = imu_track.angular_velocity .y ;
1409
1414
imu (5 ) = imu_track.angular_velocity .z ;
1410
-
1415
+
1411
1416
1412
1417
// Adding the IMU preintegration.
1413
1418
double delta_clock_imu = float (clock () - old_imu_clock) / CLOCKS_PER_SEC;
@@ -1528,7 +1533,7 @@ int main(int argc, char* argv[])
1528
1533
// Point3 between_point(0.5, 0.5, 0.5);
1529
1534
Point3 between_point (_vx * delta_clock_CVM, _vy * delta_clock_CVM, _vz * delta_clock_CVM);
1530
1535
Pose3 between_pose (between_rotation, between_point);
1531
- Vector3 between_velocity (0.5 , 0.5 , 0.5 );
1536
+ Vector3 between_velocity (0.1 , 0.1 , 0.1 );
1532
1537
noiseModel::Diagonal::shared_ptr between_pose_noise_model = noiseModel::Diagonal::Sigmas ((Vector (6 ) << 0.1 , 0.1 , 0.1 , 5 , 5 , 5 ).finished ()); // rad,rad,rad,m, m, m
1533
1538
noiseModel::Diagonal::shared_ptr between_velocity_noise_model = noiseModel::Isotropic::Sigma (3 ,5 ); // 0.1 m/s
1534
1539
noiseModel::Diagonal::shared_ptr between_bias_noise_model = noiseModel::Isotropic::Sigma (6 ,0.1 );
@@ -1540,12 +1545,13 @@ int main(int argc, char* argv[])
1540
1545
graph->add (BetweenFactor<Vector3>(V (correction_count-1 ),
1541
1546
V (correction_count ),
1542
1547
between_velocity, between_velocity_noise_model));
1548
+ imuBias::ConstantBias small_bias (Vector3 (0.1 , 0.1 , 0.1 ), Vector3 (0.1 , 0.1 , 0.1 ));
1543
1549
graph->add (BetweenFactor<imuBias::ConstantBias>(B (correction_count-1 ),
1544
1550
B (correction_count ),
1545
- zero_bias , bias_noise_model));
1551
+ small_bias , bias_noise_model));
1546
1552
1547
1553
MotionModel_factor MotionModel_factor_ (X (correction_count-1 ),
1548
- X (correction_count ),V (correction_count - 1 ), delta_clock_CVM, noiseModel::Isotropic::Sigma (3 ,5 ));
1554
+ X (correction_count ),V (correction_count- 1 ), delta_clock_CVM, noiseModel::Isotropic::Sigma (3 ,5 ));
1549
1555
graph->add (MotionModel_factor_);
1550
1556
}
1551
1557
0 commit comments