Skip to content

Commit 91337d2

Browse files
committed
made imu heading correction with mag a param
1 parent 21aa2f8 commit 91337d2

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

glider/config/graph_params.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ odom_scale_noise: 50.0
1616
lag_time: 10.0
1717
imu_frame: "enu"
1818
scale_odom: true
19+
correct_imu: false

glider/include/glider/core/glider.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Glider
4040
double initial_heading_;
4141
double current_heading_;
4242
bool set_initial_heading_;
43+
bool correct_imu_;
4344
std::string frame_;
4445

4546
Eigen::Matrix3d ned_to_enu_rot_;

glider/include/glider/utils/parameters.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ struct Parameters
3838
std::string frame;
3939

4040
bool scale_odom;
41+
bool correct_imu;
4142
};
4243
}

glider/launch/glider-node.launch.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def generate_launch_description():
1616

1717
use_odom_arg = DeclareLaunchArgument(
1818
'use_odom',
19-
default_value='true',
19+
default_value='false',
2020
description='Use odometry'
2121
)
2222

@@ -53,9 +53,9 @@ def generate_launch_description():
5353
'use_odom': use_odom}
5454
],
5555
remappings=[
56-
('/gps', '/ublox/fix'),
57-
('/imu', '/VN100T/imu'),
58-
('/mag', '/VN100T/mag'),
56+
('/gps', '/ublox_gps_node/fix'),
57+
('/imu', '/zed/zed_node/imu/data'),
58+
('/mag', '/zed/zed_node/imu/mag'),
5959
('/odom', '/Odometry'),
6060
]
6161
)

glider/src/glider.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Glider::Glider(const std::string& path)
1919
origin_x_ = params.origin_x;
2020
origin_y_ = params.origin_y;
2121
frame_ = params.frame;
22+
correct_imu_ = params.correct_imu;
2223

2324
// IMU transformations
2425
ned_to_enu_rot_ << 0.0, 1.0, 0.0,
@@ -33,6 +34,7 @@ Glider::Glider(const std::string& path)
3334
set_initial_heading_ = true;
3435

3536
std::cout << "[GLIDER] Using IMU frame: " << frame_ << std::endl;
37+
std::cout << "[GLIDER] Correcting IMU heading with mag: " << std::boolalpha << correct_imu_ << std::endl;
3638
std::cout << "[GLIDER] Glider initialized" << std::endl;
3739
}
3840

@@ -91,17 +93,31 @@ void Glider::addIMU(int64_t timestamp, Eigen::Vector3d& accel, Eigen::Vector3d&
9193
Eigen::Vector4d vec_enu;
9294
vec_enu << quat_enu.w(), quat_enu.x(), quat_enu.y(), quat_enu.z();
9395

94-
Eigen::Vector4d quat_corr = correctImuOrientation(vec_enu);
95-
9696
Eigen::Vector3d accel_enu = ned_to_enu_rot_ * accel;
9797
Eigen::Vector3d gyro_enu = ned_to_enu_rot_ * gyro;
9898

99-
factor_manager_.addImuFactor(timestamp, accel_enu, gyro_enu, quat_corr);
99+
if (correct_imu_)
100+
{
101+
Eigen::Vector4d quat_corr = correctImuOrientation(vec_enu);
102+
factor_manager_.addImuFactor(timestamp, accel_enu, gyro_enu, quat_corr);
103+
}
104+
else
105+
{
106+
factor_manager_.addImuFactor(timestamp, accel_enu, gyro_enu, vec_enu);
107+
}
108+
100109
}
101110
else if (frame_ == "enu")
102111
{
103-
Eigen::Vector4d quat_corr = correctImuOrientation(quat);
104-
factor_manager_.addImuFactor(timestamp, accel, gyro, quat_corr);
112+
if (correct_imu_)
113+
{
114+
Eigen::Vector4d quat_corr = correctImuOrientation(quat);
115+
factor_manager_.addImuFactor(timestamp, accel, gyro, quat_corr);
116+
}
117+
else
118+
{
119+
factor_manager_.addImuFactor(timestamp, accel, gyro, quat);
120+
}
105121
}
106122
else
107123
{

glider/src/parameters.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Glider::Parameters::Parameters(const std::string& path)
2929
odom_orientation_noise = config["odom_orientation_noise"].as<double>();
3030
odom_translation_noise = config["odom_translation_noise"].as<double>();
3131
odom_scale_noise = config["odom_scale_noise"].as<double>();
32+
correct_imu = config["correct_imu"].as<bool>();
3233

3334
bias_num_measurements = config["bias_num_measurements"].as<int>();
3435

0 commit comments

Comments
 (0)