Skip to content

Commit 04c725f

Browse files
authored
Merge pull request #16 from KumarRobotics/feature/ned-frame
Feature-ned-frame
2 parents dc12384 + 05478bd commit 04c725f

File tree

11 files changed

+56
-23
lines changed

11 files changed

+56
-23
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
![Jazzy CI](https://github.com/KumarRobotics/glider/actions/workflows/jazzy-ci.yml/badge.svg?branch=ros2)
55

66
Glider is a G-INS system built on [GTSAM](https://github.com/borglab/gtsam). It currently takes in GPS and 9-DOF IMU and provides a full
7-
state estimate up to the rate of you IMU. Glider is highly configurable and more features are coming soon.
7+
state estimate up to the rate of you IMU. Glider is designed to be configured to your system.
88

99
## Hardware Setup
10-
You're setup needs a GPS and a 9-DOF IMU, that is an IMU that provides a full orientation. The IMU orientation should be provided in the `IMU` frame
10+
You're setup needs a GPS and a 9-DOF IMU, that is an IMU that provides a full orientation. The IMU orientation should be provided in the IMU's frame
1111
as this is standard for robotics, but we are working on supporting the NED frame. We use a VectorNav VN100T IMU. It is important make sure your IMU magnetometer is calibrated, if it is not aligned correctly the heading output of glider will be incorrect.
1212

1313
## ROS2 Setup
@@ -29,10 +29,10 @@ You can configure glider itself in `config/glider-params.yaml`, this is where yo
2929
- `covariances.heading`: covariance of the IMU's magnetometer heading in radians, 0.09 radians is about 5 degrees.
3030
- `covariances.roll_pitch`: covariance of the roll and pitch angles in radians.
3131
- `covariances.bias`: covariance of the bias estimate.
32-
- `frame`: What frame the IMU is in, currently only support ENU but NED support is coming .
33-
### GPS Parameters
32+
- `frame`: What frame the IMU is in, either `enu` or `ned`.
33+
#### GPS Parameters
3434
- `gps.covariance`: covariance of the gps position estimate.
35-
### Other Parameters
35+
#### Other Parameters
3636
- `constants.gravity`: gravity in your IMU's frame.
3737
- `constants.bias_num_measurements`: number of IMU measurements to use to initially estimate the bias.
3838
- `constants.initial_num_measurements`: number of times to let the factor graph optimize before glider starts reporting odometry.
@@ -44,12 +44,14 @@ You can configure glider itself in `config/glider-params.yaml`, this is where yo
4444
### Building and Running Unit Tests
4545
We use GTest to run unit tests. You can build the tests with
4646
```
47-
cmake -S . -B build
47+
cd glider
48+
cmake -S . -B build -DBUILD_TESTS=ON
4849
cmake --build build
4950
```
5051
and run with:
5152
```
5253
cd build
5354
ctest
5455
```
56+
Note these tests are run on PR's and pushes to the primary branch.
5557

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ frame:
1414
imu: "enu"
1515
logging:
1616
stdout: true
17+
directory: "/home/jason/.ros/log/glider"
1718
optimizer:
1819
smooth: true
1920
lag_time: 5.0

glider/include/glider/core/glider.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class Glider
5959
* parameters
6060
* @params: the laoded params from the yaml file */
6161
void initializeLogging(const Parameters& params) const;
62+
/*! @brief rotate a quaternion by a rotation matrix
63+
* @params rot: the rotation matrix you want to rotate the quaterniuon by
64+
* @param quat: the orientation we want to rotate
65+
* @return the rotated orientation as quaternion as a Vector4d in
66+
* (w, x, y, z) format */
67+
Eigen::Vector4d rotateQuaternion(const Eigen::Matrix3d& rot, const Eigen::Vector4d& quat) const;
6268

6369
// @brief the factor manager, handles the factor graph
6470
FactorManager factor_manager_;
@@ -69,5 +75,7 @@ class Glider
6975
// @brief the relative translation from the gps to
7076
// the imu
7177
Eigen::Vector3d t_imu_gps_;
78+
// @brief the rotation matrix from ned to enu frame
79+
Eigen::Matrix3d r_enu_ned_;
7280
};
7381
}

glider/include/glider/utils/parameters.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ struct Parameters
6161
// @brief if true this logs to stdout and log file otherwise it logs
6262
// just to a file
6363
bool log;
64+
// @brief the directory to save the log file, glog needs an
65+
// absolute path
66+
std::string log_dir;
6467

6568
// @brief if true optimize using a fixed lag smoother, otherwise
6669
// optimize with iSAM2

glider/launch/glider-node.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def generate_launch_description():
4848
graph_params_file = PathJoinSubstitution([
4949
glider_share,
5050
'config',
51-
'graph-params.yaml'
51+
'glider-params.yaml'
5252
])
5353

5454
# Create the glider node

glider/src/glider.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Glider::Glider(const std::string& path)
1818

1919
frame_ = params.frame;
2020
t_imu_gps_ = params.t_imu_gps;
21+
r_enu_ned_ = Eigen::Matrix3d::Zero();
22+
r_enu_ned_ << 0.0, 1.0, 0.0,
23+
1.0, 0.0, 0.0,
24+
0.0, 0.0, -1.0;
2125

2226
LOG(INFO) << "[GLIDER] Using IMU frame: " << frame_;
2327
LOG(INFO) << "[GLIDER] Using Fixed Lag Smoother: " << std::boolalpha << params.smooth;
@@ -29,7 +33,7 @@ void Glider::initializeLogging(const Parameters& params) const
2933
// initialize GLog
3034
google::InitGoogleLogging("Glider");
3135
// TODO fix hard coding
32-
FLAGS_log_dir = "/home/jason/.ros/log/glider";
36+
FLAGS_log_dir = params.log_dir;
3337
if (params.log) FLAGS_alsologtostderr = 1;
3438
}
3539

@@ -57,7 +61,11 @@ void Glider::addImu(int64_t timestamp, Eigen::Vector3d& accel, Eigen::Vector3d&
5761
if (frame_ == "ned")
5862
{
5963
//TODO what transforms need to happen here
60-
factor_manager_.addImuFactor(timestamp, accel, gyro, quat);
64+
Eigen::Vector3d accel_enu = r_enu_ned_ * accel;
65+
Eigen::Vector3d gyro_enu = r_enu_ned_ * gyro;
66+
Eigen::Vector4d quat_enu = rotateQuaternion(r_enu_ned_, quat);
67+
68+
factor_manager_.addImuFactor(timestamp, accel_enu, gyro_enu, quat_enu);
6169
}
6270
else if (frame_ == "enu")
6371
{
@@ -96,4 +104,14 @@ OdometryWithCovariance Glider::optimize(int64_t timestamp)
96104
return OdometryWithCovariance::Uninitialized();
97105
}
98106
}
107+
108+
Eigen::Vector4d Glider::rotateQuaternion(const Eigen::Matrix3d& rot, const Eigen::Vector4d& quat) const
109+
{
110+
Eigen::Quaterniond q_ned(quat(0), quat(1), quat(2), quat(3));
111+
Eigen::Quaterniond q_ned_enu(rot);
112+
113+
Eigen::Quaterniond q_enu = q_ned_enu * q_ned;
114+
115+
return Eigen::Vector4d(q_enu.w(), q_enu.x(), q_enu.y(), q_enu.z());
116+
}
99117
}

glider/src/parameters.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Glider::Parameters::Parameters(const std::string& path)
3131
frame = config["frame"]["imu"].as<std::string>();
3232

3333
log = config["logging"]["stdout"].as<bool>();
34+
log_dir = config["logging"]["directory"].as<std::string>();
3435

3536
smooth = config["optimizer"]["smooth"].as<bool>();
3637
lag_time = config["optimizer"]["lag_time"].as<double>();

glider/test/test_factor_manager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
TEST(FactorManagerTestSuite, ImuInitialization)
1111
{
1212
// initialized glider factor manager and params
13-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
13+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
1414
Glider::FactorManager manager(params);
1515

1616
// provide measurements for initialization
@@ -43,7 +43,7 @@ TEST(FactorManagerTestSuite, ImuInitialization)
4343
TEST(FactorManagerTestSuite, PimParameters)
4444
{
4545
// initialized glider factor manager and params
46-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
46+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
4747
Glider::FactorManager manager(params);
4848

4949
// provide measurements for initialization
@@ -87,7 +87,7 @@ TEST(FactorManagerTestSuite, KeyIndex)
8787
double lon = -75.199197;
8888

8989
// initialized glider factor manager and params
90-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
90+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
9191
Glider::FactorManager manager(params);
9292

9393
ASSERT_EQ(manager.getKeyIndex(), 0);
@@ -115,7 +115,7 @@ TEST(FactorManagerTestSuite, GPSInitialization)
115115
double lon = -75.199197;
116116

117117
// initialized glider factor manager and params
118-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
118+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
119119
Glider::FactorManager manager(params);
120120

121121
// provide imu measurements for initialization
@@ -143,7 +143,7 @@ TEST(FactorManagerTestSuite, SystemInitialization)
143143
double lon = -75.199197;
144144

145145
// initialized glider factor manager and params
146-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
146+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
147147
Glider::FactorManager manager(params);
148148

149149
// assert system is NOT initialized

glider/test/test_glider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
TEST(GliderTestSuite, AddTo)
1313
{
14-
Glider::Glider glider("../config/graph-params.yaml");
14+
Glider::Glider glider("../config/glider-params.yaml");
1515

1616
Eigen::Vector3d accel(0.0, 0.0, 9.81);
1717
Eigen::Vector3d gyro(0.0, 0.0, 0.0);

glider/test/test_odometry_w_cov.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static const double GZ = 0.0;
4040
TEST(OdometryWithCovarianceTestSuite, TestInitialization)
4141
{
4242
// initialized glider factor manager and params
43-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
43+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
4444
Glider::FactorManager manager(params);
4545

4646
Glider::OdometryWithCovariance odom;
@@ -71,7 +71,7 @@ TEST(OdometryWithCovarianceTestSuite, TestInitialization)
7171
TEST(OdometryWithCovarainceTestSuite, TestCovariances)
7272
{
7373
// initialized glider factor manager and params
74-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
74+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
7575
Glider::FactorManager manager(params);
7676

7777
Glider::OdometryWithCovariance odom;
@@ -125,7 +125,7 @@ TEST(OdometryWithCovarainceTestSuite, TestCovariances)
125125
TEST(OdometryWithCovarianceTestSuite, TestBiases)
126126
{
127127
// initialized glider factor manager and params
128-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
128+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
129129
Glider::FactorManager manager(params);
130130

131131
Glider::OdometryWithCovariance odom;
@@ -193,7 +193,7 @@ TEST(OdometryWithCovarianceTestSuite, TestBiases)
193193
TEST(OdometryWithCovarianceTestSuite, TestKeyIndex)
194194
{
195195
// initialized glider factor manager and params
196-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
196+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
197197
Glider::FactorManager manager(params);
198198

199199
Glider::OdometryWithCovariance odom;
@@ -230,7 +230,7 @@ TEST(OdometryWithCovarianceTestSuite, TestKeyIndex)
230230
TEST(OdometryWithCovarianceTestSuite, TestMovementStatus)
231231
{
232232
// initialized glider factor manager and params
233-
Glider::Parameters params = Glider::Parameters::Load("../config/graph-params.yaml");
233+
Glider::Parameters params = Glider::Parameters::Load("../config/glider-params.yaml");
234234
Glider::FactorManager manager(params);
235235

236236
Glider::OdometryWithCovariance odom;

0 commit comments

Comments
 (0)