Skip to content

Commit 70066d0

Browse files
joansolaartivis
authored andcommitted
Add example SAM 3D with self-calibration (#104)
* SAM 3D selfcalib works! * const auto& * Update README.md * small fix readme * Fix printing pose results
1 parent 0abb207 commit 70066d0

File tree

5 files changed

+649
-23
lines changed

5 files changed

+649
-23
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ $ catkin build manif --cmake-args -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON
9696

9797
###### Generate the documentation
9898
```terminal
99-
cd manif
100-
doxygen .doxygen.txt
99+
$ cd manif
100+
$ doxygen .doxygen.txt
101101
```
102102

103103
#### Use **manif** in your project
@@ -208,8 +208,8 @@ Some more general documentation and tips on the use of the library is available
208208
To generate the documentation on your machine, type in the terminal
209209

210210
```terminal
211-
cd manif
212-
doxygen .doxygen.txt
211+
$ cd manif
212+
$ doxygen .doxygen.txt
213213
```
214214

215215
and find it at `manif/doc/html/index.html`.
@@ -220,13 +220,14 @@ find in the section <a href="#publications">Publications</a>.
220220
## Tutorials and application demos
221221

222222
We provide some self-contained and self-explained executables implementing some real problems.
223-
Their source code is located in `[manif]/examples/`.
223+
Their source code is located in `manif/examples/`.
224224
These demos are:
225225

226226
- [`se2_localization.cpp`](examples/se2_localization.cpp): 2D robot localization based on fixed landmarks using SE2 as robot poses. This implements the example V.A in the paper.
227227
- [`se3_localization.cpp`](examples/se3_localization.cpp): 3D robot localization based on fixed landmarks using SE3 as robot poses. This re-implements the example above but in 3D.
228228
- [`se2_sam.cpp`](examples/se2_sam.cpp): 2D smoothing and mapping (SAM) with simultaneous estimation of robot poses and landmark locations, based on SE2 robot poses. This implements a the example V.B in the paper.
229229
- [`se3_sam.cpp`](examples/se3_sam.cpp): 3D smoothing and mapping (SAM) with simultaneous estimation of robot poses and landmark locations, based on SE3 robot poses. This implements a 3D version of the example V.B in the paper.
230+
- [`se3_sam_selfcalib.cpp`](examples/se3_sam_selfcalib.cpp): 3D smoothing and mapping (SAM) with self-calibration, with simultaneous estimation of robot poses, landmark locations and sensor parameters, based on SE3 robot poses. This implements a 3D version of the example V.C in the paper.
230231

231232
## Publications
232233

examples/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_executable(se2_sam se2_sam.cpp)
88

99
add_executable(se3_localization se3_localization.cpp)
1010
add_executable(se3_sam se3_sam.cpp)
11+
add_executable(se3_sam_selfcalib se3_sam_selfcalib.cpp)
1112

1213
set(CXX_11_EXAMPLE_TARGETS
1314

@@ -24,6 +25,7 @@ set(CXX_11_EXAMPLE_TARGETS
2425
# SE3
2526
se3_localization
2627
se3_sam
28+
se3_sam_selfcalib
2729
)
2830

2931
# Link to manif

examples/se2_sam.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ int main()
358358
for (int i = 0; i < NUM_POSES; ++i)
359359
{
360360
// make measurements
361-
for (auto k : pairs[i])
361+
for (const auto& k : pairs[i])
362362
{
363363
// simulate measurement
364364
b = landmarks_simu[k]; // lmk coordinates in world frame
@@ -393,7 +393,7 @@ int main()
393393
// DEBUG INFO
394394
cout << "prior" << std::showpos << endl;
395395
for (const auto& X : poses)
396-
cout << "pose: " << X.log() << endl;
396+
cout << "pose : " << X.translation().transpose() << " " << X.angle() << endl;
397397
for (const auto& b : landmarks)
398398
cout << "lmk : " << b.transpose() << endl;
399399
cout << "-----------------------------------------------" << endl;
@@ -487,10 +487,10 @@ int main()
487487
Xj = poses[j];
488488
u = controls[i];
489489

490-
// expectation
490+
// expectation (use right-minus since motion measurements are local)
491491
d = Xj.rminus(Xi, J_d_xj, J_d_xi); // expected motion = Xj (-) Xi
492492

493-
// residual (use right-minus since motion measurements are local)
493+
// residual
494494
r.segment<DoF>(row) = W * (d - u).coeffs(); // residual
495495

496496
// Jacobian of residual wrt first pose
@@ -506,7 +506,7 @@ int main()
506506
}
507507

508508
// 3. evaluate measurement factors ---------------------------
509-
for (auto k : pairs[i])
509+
for (const auto& k : pairs[i])
510510
{
511511
// recover related states and data
512512
Xi = poses[i];
@@ -517,7 +517,7 @@ int main()
517517
e = Xi.inverse(J_ix_x).act(b, J_e_ix, J_e_b); // expected measurement = Xi.inv * bj
518518
J_e_x = J_e_ix * J_ix_x; // chain rule
519519

520-
// residual (use right-minus since sensor measurements are local)
520+
// residual
521521
r.segment<Dim>(row) = S * (e - y);
522522

523523
// Jacobian of residual wrt pose
@@ -542,7 +542,7 @@ int main()
542542
dX = - (J.transpose() * J).inverse() * J.transpose() * r;
543543

544544
// update all poses
545-
for (int i = 0; i < 3; ++i)
545+
for (int i = 0; i < NUM_POSES; ++i)
546546
{
547547
// we go very verbose here
548548
int row = i * DoF;
@@ -578,15 +578,15 @@ int main()
578578
// solved problem
579579
cout << "posterior" << std::showpos << endl;
580580
for (const auto& X : poses)
581-
cout << "pose: " << X.log() << endl;
581+
cout << "pose : " << X.translation().transpose() << " " << X.angle() << endl;
582582
for (const auto& b : landmarks)
583583
cout << "lmk : " << b.transpose() << endl;
584584
cout << "-----------------------------------------------" << endl;
585585

586586
// ground truth
587587
cout << "ground truth1" << std::showpos << endl;
588588
for (const auto& X : poses_simu)
589-
cout << "pose: " << X.log() << endl;
589+
cout << "pose : " << X.translation().transpose() << " " << X.angle() << endl;
590590
for (const auto& b : landmarks_simu)
591591
cout << "lmk : " << b.transpose() << endl;
592592
cout << "-----------------------------------------------" << endl;

examples/se3_sam.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ int main()
358358
for (int i = 0; i < NUM_POSES; ++i)
359359
{
360360
// make measurements
361-
for (auto k : pairs[i])
361+
for (const auto& k : pairs[i])
362362
{
363363
// simulate measurement
364364
b = landmarks_simu[k]; // lmk coordinates in world frame
@@ -393,7 +393,7 @@ int main()
393393
// DEBUG INFO
394394
cout << "prior" << std::showpos << endl;
395395
for (const auto& X : poses)
396-
cout << "pose: " << X.log() << endl;
396+
cout << "pose : " << X.translation().transpose() << " " << X.asSO3().log() << endl;
397397
for (const auto& b : landmarks)
398398
cout << "lmk : " << b.transpose() << endl;
399399
cout << "-----------------------------------------------" << endl;
@@ -487,10 +487,10 @@ int main()
487487
Xj = poses[j];
488488
u = controls[i];
489489

490-
// expectation
490+
// expectation (use right-minus since motion measurements are local)
491491
d = Xj.rminus(Xi, J_d_xj, J_d_xi); // expected motion = Xj (-) Xi
492492

493-
// residual (use right-minus since motion measurements are local)
493+
// residual
494494
r.segment<DoF>(row) = W * (d - u).coeffs(); // residual
495495

496496
// Jacobian of residual wrt first pose
@@ -506,7 +506,7 @@ int main()
506506
}
507507

508508
// 3. evaluate measurement factors ---------------------------
509-
for (auto k : pairs[i])
509+
for (const auto& k : pairs[i])
510510
{
511511
// recover related states and data
512512
Xi = poses[i];
@@ -517,7 +517,7 @@ int main()
517517
e = Xi.inverse(J_ix_x).act(b, J_e_ix, J_e_b); // expected measurement = Xi.inv * bj
518518
J_e_x = J_e_ix * J_ix_x; // chain rule
519519

520-
// residual (use right-minus since sensor measurements are local)
520+
// residual
521521
r.segment<Dim>(row) = S * (e - y);
522522

523523
// Jacobian of residual wrt pose
@@ -542,7 +542,7 @@ int main()
542542
dX = - (J.transpose() * J).inverse() * J.transpose() * r;
543543

544544
// update all poses
545-
for (int i = 0; i < 3; ++i)
545+
for (int i = 0; i < NUM_POSES; ++i)
546546
{
547547
// we go very verbose here
548548
int row = i * DoF;
@@ -578,15 +578,15 @@ int main()
578578
// solved problem
579579
cout << "posterior" << std::showpos << endl;
580580
for (const auto& X : poses)
581-
cout << "pose: " << X.log() << endl;
581+
cout << "pose : " << X.translation().transpose() << " " << X.asSO3().log() << endl;
582582
for (const auto& b : landmarks)
583583
cout << "lmk : " << b.transpose() << endl;
584584
cout << "-----------------------------------------------" << endl;
585585

586586
// ground truth
587587
cout << "ground truth" << std::showpos << endl;
588588
for (const auto& X : poses_simu)
589-
cout << "pose: " << X.log() << endl;
589+
cout << "pose : " << X.translation().transpose() << " " << X.asSO3().log() << endl;
590590
for (const auto& b : landmarks_simu)
591591
cout << "lmk : " << b.transpose() << endl;
592592
cout << "-----------------------------------------------" << endl;

0 commit comments

Comments
 (0)