Skip to content

Commit 1367a66

Browse files
committed
resolve merge conflicts
2 parents 783c015 + 7b0de66 commit 1367a66

File tree

13 files changed

+202
-64
lines changed

13 files changed

+202
-64
lines changed

docker/Dockerfile.humble

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ RUN sudo apt-get update \
3737
RUN sudo apt-get install -y python3-colcon-common-extensions
3838

3939
# install visualizer deps
40-
RUN sudo apt-get install -y python3-pip
41-
RUN pip3 install flask folium flask_socketio utm
4240
RUN sudo apt install -y libgoogle-glog-dev
4341
# build ros env
4442
RUN mkdir ws
@@ -48,4 +46,3 @@ RUN sudo chown $USER:$USER ~/.bashrc \
4846
&& /bin/sh -c 'echo ". /opt/ros/humble/setup.bash" >> ~/.bashrc' \
4947
&& /bin/sh -c 'echo "source ~/ws/install/setup.bash" >> ~/.bashrc' \
5048
&& echo 'export PS1="\[$(tput setaf 2; tput bold)\]\u\[$(tput setaf 7)\]@\[$(tput setaf 3)\]\h\[$(tput setaf 7)\]:\[$(tput setaf 4)\]\W\[$(tput setaf 7)\]$ \[$(tput sgr0)\]"' >> ~/.bashrc
51-

docker/run-humble.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ docker run -it --rm \
77
-v "/dev:/dev" \
88
-v "/tmp/.X11-unix:/tmp/.X11-unix" \
99
-v "`pwd`/../glider:/home/`whoami`/ws/src/glider" \
10-
-v "/home/`whoami`/Data/evmapper:/home/`whoami`/data" \
10+
-v "/home/`whoami`/Data:/home/`whoami`/data" \
1111
-e DISPLAY=$DISPLAY \
1212
-e QT_X11_NO_MITSHM=1 \
1313
-e XAUTHORITY=$XAUTH \
14-
--name glider-ros-humble \
15-
glider-ros:humble \
14+
--name glider-ros-jazzy \
15+
glider-ros:jazzy \
1616
bash
1717
xhost -

glider/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ include_directories(
5858
add_library(${PROJECT_NAME} SHARED
5959
src/parameters.cpp
6060
src/time.cpp
61+
src/gps_heading.cpp
6162
src/odometry.cpp
6263
src/odometry_with_covariance.cpp
6364
src/factor_manager.cpp

glider/config/glider-params.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
covariances:
2-
accelerometer: 0.00001
3-
gyroscope: 0.00001
4-
integration: 0.001
5-
heading: 0.09
6-
roll_pitch: 0.001
7-
bias: 0.001
8-
gps: 2.0
1+
imu:
2+
covariances:
3+
accelerometer: 0.00001
4+
gyroscope: 0.00001
5+
integration: 0.001
6+
heading: 0.09
7+
roll_pitch: 0.001
8+
bias: 0.001
9+
frame: "enu"
10+
gps:
11+
covariance: 2.0
12+
dgpsfm:
13+
enable: false
14+
integration_threshold: 1.0
15+
covariance: 0.03
916
constants:
1017
gravity: 9.81
1118
bias_num_measurements: 100
1219
initial_num_measurements: 4
13-
frame:
14-
imu: "enu"
1520
logging:
1621
stdout: true
1722
directory: "/tmp/glider"

glider/include/glider/core/factor_manager.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ class FactorManager
7979
* @param timestamp: time of the gps measurement
8080
* @param gps: GPS measurement in the UTM frame */
8181
void addGpsFactor(int64_t timestamp, const Eigen::Vector3d& gps);
82+
/*! @brief adds the gps measurement and a heading from dgps
83+
* @param timestamp: time of the gps measurement
84+
* @param gps: GPS measurement in the UTM frame
85+
* @param heading: heading from dgpsfm in the ENU frame
86+
* @param fuse: whether or not to add the heading measurement
87+
* to the factor graph */
88+
void addGpsFactor(int64_t timestamp, const Eigen::Vector3d& gps, const double& heading, const bool fuse);
8289
/*! @brief adds the imu measurements to the pim and saves the orientation
8390
* @param timestamp: time of the imu measurement
8491
* @param accel: the accelerometer reading
@@ -165,6 +172,8 @@ class FactorManager
165172
gtsam::noiseModel::Isotropic::shared_ptr gps_noise_;
166173
// @brief noise in the orientation estimate from the imu
167174
gtsam::noiseModel::Base::shared_ptr orient_noise_;
175+
// @brief noise in the heading estimate of differential gps
176+
gtsam::noiseModel::Base::shared_ptr dgpsfm_noise_;
168177

169178
// factor graph
170179
// @brief tracks the number of times the optimizer has been called

glider/include/glider/core/glider.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <glog/logging.h>
1414

1515
#include "glider/core/factor_manager.hpp"
16+
#include "glider/utils/gps_heading.hpp"
1617
#include "glider/utils/geodetics.hpp"
1718

1819
namespace Glider
@@ -77,5 +78,15 @@ class Glider
7778
Eigen::Vector3d t_imu_gps_;
7879
// @brief the rotation matrix from ned to enu frame
7980
Eigen::Matrix3d r_enu_ned_;
81+
// @brief whether or not to use differential gps
82+
// from motion for heading
83+
bool use_dgpsfm_;
84+
// @brief save the state estimate from
85+
// the optimizer
86+
OdometryWithCovariance current_odom_;
87+
// @brief save the previous gps measurement for
88+
// dgpsfm
89+
Eigen::Vector3d last_gps_;
90+
double del_threshold_;
8091
};
8192
}

glider/include/glider/utils/gps_heading.hpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,17 @@ namespace geodetics
2323
* @param lon2: the TO longitude in degrees decimal
2424
* @return heading_rad: the heading in radians in the NED frame
2525
*/
26-
double gpsHeading(double lat1, double lon1, double lat2, double lon2)
27-
{
28-
double lat1_rad = lat1 * M_PI / 180.0;
29-
double lon1_rad = lon1 * M_PI / 180.0;
30-
double lat2_rad = lat2 * M_PI / 180.0;
31-
double lon2_rad = lon2 * M_PI / 180.0;
32-
33-
double lon_diff = lon2_rad - lon1_rad;
34-
35-
double y = std::sin(lon_diff) * std::cos(lat2_rad);
36-
double x = std::cos(lat1_rad) * std::sin(lat2_rad) - std::sin(lat1_rad) * std::cos(lat2_rad) * std::cos(lon_diff);
37-
38-
double heading_rad = std::atan2(y,x);
39-
40-
return heading_rad;
41-
}
42-
26+
double gpsHeading(double lat1, double lon1, double lat2, double lon2);
4327
/*! @brief convert a heading in radians to degrees and normalize to [0,360)
4428
* @param heading: the heading in radians, can be ENU or NED frame
4529
* @return heading_deg: normalized heading in degrees in the same frame
4630
* that was input
4731
*/
48-
double headingRadiansToDegrees(double heading)
49-
{
50-
double heading_deg = heading * (180.0 / M_PI);
51-
52-
heading_deg = std::fmod(std::fmod(heading_deg, 360.0) + 360.0, 360.0);
53-
return heading_deg;
54-
}
55-
32+
double headingRadiansToDegrees(double heading);
5633
/*! @brief convert a heading from the geodetic frame (NED) to the ENU frame
5734
* @param geodetic_heading: heading in radians in the geodetic (NED) frame
5835
* @return enu_heading: heading in radians in the ENU frame
5936
*/
60-
double geodeticToENU(double geodetic_heading)
61-
{
62-
double enu_heading = std::fmod((M_PI/2 - geodetic_heading + (2*M_PI)), (2*M_PI));
63-
64-
return enu_heading;
65-
}
37+
double geodeticToENU(double geodetic_heading);
6638
} // namespace geodetics
6739
} // namespace glider

glider/include/glider/utils/parameters.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ struct Parameters
7272
// smooth over.
7373
double lag_time;
7474

75+
// @brief wheather or not to integrate differential gps from motion heading,
76+
// if false orientation from the IMU will be integrated
77+
bool use_dgpsfm;
78+
// @brief velocity in m/s that the robot should be moving at to integrate
79+
// dgpsfm
80+
double dgpsfm_threshold;
81+
// @brief heading noise for differential gps from motion
82+
double dgpsfm_cov;
83+
7584
// @brief translation from the GPS to the IMU
7685
Eigen::Vector3d t_imu_gps;
7786
};

glider/launch/glider-node.launch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def generate_launch_description():
6262
'use_odom': False}
6363
],
6464
remappings=[
65-
('/gps', '/ublox/fix'),
66-
('/imu', '/VN100T/imu'),
65+
('/gps', '/ublox_gps_node/fix'),
66+
('/imu', '/vectornav/imu'),
6767
('/odom', '/Odometry'),
6868
]
6969
)

glider/src/factor_manager.cpp

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ FactorManager::FactorManager(const Parameters& params)
3434
// set noise model
3535
gps_noise_ = gtsam::noiseModel::Isotropic::Sigma(3, params.gps_noise);
3636
orient_noise_ = gtsam::noiseModel::Diagonal::Sigmas(gtsam::Vector3(params.roll_pitch_cov, params.roll_pitch_cov, params.heading_cov));
37-
37+
dgpsfm_noise_ = gtsam::noiseModel::Diagonal::Sigmas(gtsam::Vector3(M_PI/2, M_PI/2, params.dgpsfm_cov));
38+
3839
// set key index
3940
key_index_ = 0;
4041

@@ -153,14 +154,78 @@ void FactorManager::addGpsFactor(int64_t timestamp, const Eigen::Vector3d& gps)
153154
gtsam::Point3 meas(gps(0), gps(1), gps(2));
154155
gtsam::Rot3 rot = gtsam::Rot3::Quaternion(orient_(0), orient_(1), orient_(2), orient_(3));
155156

156-
// add measurements to factor graph
157+
// add gps measurement to factor graph as gtsam object
157158
graph_.add(gtsam::GPSFactor(X(key_index_), gps, gps_noise_));
158159
graph_.addExpressionFactor(gtsam::rotation(X(key_index_)), rot, orient_noise_);
160+
161+
// increment key index
162+
key_index_++;
163+
}
164+
165+
void FactorManager::addGpsFactor(int64_t timestamp, const Eigen::Vector3d& gps, const double& heading, const bool fuse)
166+
{
167+
// wait until the imu is initialized
168+
if (!imu_initialized_) return;
169+
170+
double time = nanosecIntToDouble(timestamp);
171+
172+
if (key_index_ == 0)
173+
{
174+
// set the initial NavState
175+
// The initial orientation is the the initial orientation from the imu initialization
176+
// The initial position is from the gps
177+
// Initial velocity is set to zero
178+
gtsam::Pose3 initial_pose = gtsam::Pose3(initial_orientation_, gtsam::Point3(gps(0), gps(1), gps(2)));
179+
gtsam::NavState initial_navstate(initial_pose, gtsam::Point3(0.0, 0.0, 0.0)); // TODO why do I need this??
180+
181+
// save the initial values
182+
initials_.insert(X(key_index_), initial_pose);
183+
initials_.insert(V(key_index_), gtsam::Point3(0.0, 0.0, 0.0));
184+
initials_.insert(B(key_index_), bias_);
185+
186+
// save the timestamps for the smoother
187+
smoother_timestamps_[X(key_index_)] = time;
188+
smoother_timestamps_[V(key_index_)] = time;
189+
smoother_timestamps_[B(key_index_)] = time;
190+
191+
// add prior factors to the graph
192+
graph_.add(gtsam::PriorFactor<gtsam::Pose3>(X(key_index_), initial_pose, gtsam::noiseModel::Isotropic::Sigma(6, 0.001)));
193+
graph_.add(gtsam::PriorFactor<gtsam::Point3>(V(key_index_), gtsam::Point3(0.0, 0.0, 0.0), gtsam::noiseModel::Isotropic::Sigma(3, 0.001)));
194+
graph_.add(gtsam::PriorFactor<gtsam::imuBias::ConstantBias>(B(key_index_), bias_, gtsam::noiseModel::Isotropic::Sigma(6, 0.001)));
195+
196+
key_index_++;
197+
gps_initialized_ = true;
198+
LOG(INFO) << "[GLIDER] GPS Initialized";
199+
return;
200+
}
201+
202+
// add the pim to the graph under a mutex
203+
std::unique_lock<std::mutex> lock(mutex_);
204+
graph_.add(gtsam::CombinedImuFactor(X(key_index_-1), V(key_index_-1), X(key_index_), V(key_index_), B(key_index_-1), B(key_index_), *pim_));
205+
lock.unlock();
206+
207+
// insert new initial values
208+
initials_.insert(X(key_index_), current_state_.getPose<gtsam::Pose3>());
209+
initials_.insert(V(key_index_), current_state_.getVelocity<gtsam::Vector3>());
210+
initials_.insert(B(key_index_), bias_);
211+
212+
// save the time for the smoother
213+
smoother_timestamps_[X(key_index_)] = time;
214+
smoother_timestamps_[V(key_index_)] = time;
215+
smoother_timestamps_[B(key_index_)] = time;
216+
217+
// add gps measurement to factor graph as gtsam object
218+
gtsam::Point3 meas(gps(0), gps(1), gps(2));
219+
gtsam::Rot3 rot = gtsam::Rot3::Ypr(heading, 0.0, 0.0);
220+
221+
graph_.add(gtsam::GPSFactor(X(key_index_), gps, gps_noise_));
222+
if (fuse) graph_.addExpressionFactor(gtsam::rotation(X(key_index_)), rot, dgpsfm_noise_);
159223

160224
// increment key index
161225
key_index_++;
162226
}
163227

228+
164229
void FactorManager::addImuFactor(int64_t timestamp, const Eigen::Vector3d& accel, const Eigen::Vector3d& gyro, const Eigen::Vector4d& orient)
165230
{
166231
// if the imu is not initialized, pass the meaurements to initialize it

0 commit comments

Comments
 (0)