Skip to content

Commit 18666f2

Browse files
committed
fixing the problem on the factor lidar map, required both poses to provide gradients. Created a well defined problem wit 3 points and a simple translation
1 parent 0ad333a commit 18666f2

3 files changed

Lines changed: 25 additions & 9 deletions

File tree

src/timeCont/examples/test_factor_lidar_map2pose_interpolation.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,41 @@ int main() {
121121

122122
SE3tc T_origin(state_origin);
123123
SE3tc T_target(state_target);
124-
matData_t t_obs = observation(4);
124+
matData_t t_obs = observation(3);
125125

126126
std::cout << "Origin time: " << T_origin.time() << std::endl;
127127
std::cout << "Target time: " << T_target.time() << std::endl;
128128
std::cout << "Observation time: " << t_obs << std::endl;//this should be in [target,origin]. it must coincide, so carafull with sweeping this variable.
129129

130130
//to really test it works properly, I think you want to solve this graph
131-
graph.add_factor(factor);
132-
//graph.print(true);
131+
observation << 1.5, 1.0, 0.0, 1.0;
132+
map_point << 1.5, 2.0, 0.20;
133+
std::shared_ptr<Factor> factor_1 = std::make_shared<FactorLidarMap2PoseInterpolation>(
134+
observation, map_point, nodeOrigin, nodeTarget, offset_lidar_imu, obsInf, Factor::robustFactorType::QUADRATIC);
135+
graph.add_factor(factor_1);
136+
137+
observation << -1.5, 1.0, 0.0, 1.0;
138+
map_point << -1.5, 2.0, 0.20;
139+
std::shared_ptr<Factor> factor_2 = std::make_shared<FactorLidarMap2PoseInterpolation>(
140+
observation, map_point, nodeOrigin, nodeTarget, offset_lidar_imu, obsInf, Factor::robustFactorType::QUADRATIC);
141+
graph.add_factor(factor_2);
142+
143+
observation << 1.5, 2.0, 0.0, 1.0;
144+
map_point << 1.5, 3.0, 0.20;
145+
std::shared_ptr<Factor> factor_3 = std::make_shared<FactorLidarMap2PoseInterpolation>(
146+
observation, map_point, nodeOrigin, nodeTarget, offset_lidar_imu, obsInf, Factor::robustFactorType::QUADRATIC);
147+
graph.add_factor(factor_3);
133148

134149
// solve function in fg_solve.cpp. There are defauls params, but not using them
150+
graph.print(true);
135151
auto iters =
136152
graph.solve(FGraphSolve::optimMethod::LM,
137153
20,
138154
1e-5,
139155
1e-6,
140156
true);
141157

142-
std::cout << "\nSolved, chi2 = " << graph.chi2() << std::endl;
158+
std::cout << "\nSolved, chi2 = " << graph.chi2() << ", iters = " << iters <<std::endl;
143159

144160
graph.print(true);
145161

src/timeCont/factors/factorLidarMap2PoseInterpolation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ FactorLidarMap2PoseInterpolation::FactorLidarMap2PoseInterpolation(
3434
const Mat3 &obsInf,
3535
Factor::robustFactorType robust_type):
3636

37-
Factor(3,9,robust_type), obs_(observation), W_(obsInf), map_point_(map_point), point_obs_imu_frame_(Mat31::Zero()),
37+
Factor(3,18,robust_type), obs_(observation), W_(obsInf), map_point_(map_point), point_obs_imu_frame_(Mat31::Zero()),
3838
T_offset_lidar_imu_(offset_lidar_imu), thau_taw_(0.0)
3939
{
4040
if (nodeOrigin->get_id() < nodeTarget->get_id())
@@ -62,7 +62,7 @@ void FactorLidarMap2PoseInterpolation::interpolate_pose(const SE3tc &T_origin, c
6262
{
6363
matData_t t1 = T_origin.time();
6464
matData_t t2 = T_target.time();
65-
thau_taw_ = (t2 - t_obs)/(t2-t1);
65+
thau_taw_ = (t_obs - t1)/(t2-t1);
6666

6767
SE3 T_org = SE3(T_origin.T_SE3());
6868
SE3 T_tar = SE3(T_target.T_SE3());
@@ -89,8 +89,8 @@ void FactorLidarMap2PoseInterpolation::evaluate_jacobians()
8989
{
9090
J_.setZero();
9191
Mat3 R_taw = T_taw_.R();
92-
J_.topLeftCorner<3,3>() = -thau_taw_ * R_taw * hat3(point_obs_imu_frame_);
93-
J_.block<3,3>(0,3) = thau_taw_ * R_taw;
92+
J_.block<3,3>(0,9) = -thau_taw_ * R_taw * hat3(point_obs_imu_frame_);
93+
J_.block<3,3>(0,9+3) = thau_taw_ * R_taw;
9494
}
9595

9696

src/timeCont/mrob/factors/factorLidarMap2PoseInterpolation.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FactorLidarMap2PoseInterpolation : public Factor
6666
Mat41 obs_; // obs = [X, Y, Z, t] lidar observation
6767
Mat31 r_; //residual [TP - Z(:3)]
6868
Mat3 W_;//inverse of observation covariance (information matrix)
69-
Mat<3,9> J_;//Joint Jacobian
69+
Mat<3,18> J_;//Joint Jacobian
7070
SE3 T_taw_; // interpolated pose
7171
Mat31 map_point_, point_obs_imu_frame_; // map point
7272
SE3 T_offset_lidar_imu_; // offset from lidar to imu XXX: I think it is the other way, from IMU to LiDAR. Plase check

0 commit comments

Comments
 (0)