Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
11ca7f16
Commit
11ca7f16
authored
8 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Add landmark convergence test
parent
31f79338
No related branches found
No related tags found
1 merge request
!101
Visual SLAM starts to work.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/examples/test_simple_AHP.cpp
+24
-18
24 additions, 18 deletions
src/examples/test_simple_AHP.cpp
with
24 additions
and
18 deletions
src/examples/test_simple_AHP.cpp
+
24
−
18
View file @
11ca7f16
...
@@ -23,13 +23,13 @@
...
@@ -23,13 +23,13 @@
* - A kf at 1m to the left of the origin, kf4
* - A kf at 1m to the left of the origin, kf4
* - A lmk at 1m distance in front of the anchor: L1
* - A lmk at 1m distance in front of the anchor: L1
* - we use this lmk to project it onto kf2, kf3 and kf4 and obtain measured pixels p0, p1 and p2
* - we use this lmk to project it onto kf2, kf3 and kf4 and obtain measured pixels p0, p1 and p2
* - A lmk initialized at kf1, with measurement p0, at a
n
distance of 2m: L2
* - A lmk initialized at kf1, with measurement p0, at a distance of 2m: L2
* - we project the pixels p3 and p4: we observe that they do not match p1 and p2
* - we project the pixels p3 and p4: we observe that they do not match p1 and p2
* - we use the measurements p1 and p2 to solve the optimization problem on L2: L2 should converge to L1.
* - we use the measurements p1 and p2 to solve the optimization problem on L2: L2 should converge to L1.
* - This is a sketch of the situation:
* - This is a sketch of the situation:
* - X, Y are the axes in world frame
* - X, Y are the axes in world frame
* - x, z are the axes in anchor camera frame. We have that X=z, Y=-x.
* - x, z are the axes in anchor camera frame. We have that X=z, Y=-x.
* - Axes Z and y are perpendicular to the drawing; they h
e
ve no effect.
* - Axes Z and y are perpendicular to the drawing; they h
a
ve no effect.
*
*
* X,z
* X,z
* ^
* ^
...
@@ -140,8 +140,8 @@ int main(int argc, char** argv)
...
@@ -140,8 +140,8 @@ int main(int argc, char** argv)
// Features-----------------
// Features-----------------
cv
::
Mat
desc
;
cv
::
Mat
desc
;
cv
::
KeyPoint
kp0
;
cv
::
KeyPoint
kp
_
0
;
std
::
shared_ptr
<
FeaturePointImage
>
feat_0
=
std
::
make_shared
<
FeaturePointImage
>
(
kp0
,
desc
,
Eigen
::
Matrix2s
::
Identity
());
std
::
shared_ptr
<
FeaturePointImage
>
feat_0
=
std
::
make_shared
<
FeaturePointImage
>
(
kp
_
0
,
desc
,
Eigen
::
Matrix2s
::
Identity
());
image_0
->
addFeature
(
feat_0
);
image_0
->
addFeature
(
feat_0
);
cv
::
KeyPoint
kp_1
;
cv
::
KeyPoint
kp_1
;
...
@@ -166,21 +166,17 @@ int main(int argc, char** argv)
...
@@ -166,21 +166,17 @@ int main(int argc, char** argv)
feat_2
->
addConstraint
(
ctr_2
);
feat_2
->
addConstraint
(
ctr_2
);
// Projections----------------------------
// Projections----------------------------
Eigen
::
VectorXs
pix_0
(
ctr_0
->
expectation
()
)
;
Eigen
::
VectorXs
pix_0
=
ctr_0
->
expectation
();
cv
::
KeyPoint
cvPix_0
(
pix_0
(
0
),
pix_0
(
1
),
16
);
kp_0
=
cv
::
KeyPoint
(
pix_0
(
0
),
pix_0
(
1
),
0
);
feat_0
->
setKeypoint
(
cvPix
_0
);
feat_0
->
setKeypoint
(
kp
_0
);
Eigen
::
VectorXs
pix_1
(
ctr_1
->
expectation
()
)
;
Eigen
::
VectorXs
pix_1
=
ctr_1
->
expectation
();
cv
::
KeyPoint
cvPix_1
(
pix_1
(
0
),
pix_1
(
1
),
16
);
kp_1
=
cv
::
KeyPoint
(
pix_1
(
0
),
pix_1
(
1
),
0
);
feat_1
->
setKeypoint
(
cvPix
_1
);
feat_1
->
setKeypoint
(
kp
_1
);
Eigen
::
VectorXs
pix_2
(
ctr_2
->
expectation
());
Eigen
::
VectorXs
pix_2
=
ctr_2
->
expectation
();
cv
::
KeyPoint
cvPix_2
(
pix_2
(
0
),
pix_2
(
1
),
16
);
kp_2
=
cv
::
KeyPoint
(
pix_2
(
0
),
pix_2
(
1
),
0
);
feat_2
->
setKeypoint
(
cvPix_2
);
feat_2
->
setKeypoint
(
kp_2
);
kp0
=
feat_0
->
getKeypoint
();
kp_1
=
feat_1
->
getKeypoint
();
kp_2
=
feat_2
->
getKeypoint
();
std
::
cout
<<
"pixel 0: "
<<
pix_0
.
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"pixel 0: "
<<
pix_0
.
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"pixel 1: "
<<
pix_1
.
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"pixel 1: "
<<
pix_1
.
transpose
()
<<
std
::
endl
;
...
@@ -208,7 +204,7 @@ int main(int argc, char** argv)
...
@@ -208,7 +204,7 @@ int main(int argc, char** argv)
Eigen
::
Vector3s
dir_0
=
K
.
inverse
()
*
pix_0_hmg
;
Eigen
::
Vector3s
dir_0
=
K
.
inverse
()
*
pix_0_hmg
;
Eigen
::
Vector4s
pnt_hmg_0
;
Eigen
::
Vector4s
pnt_hmg_0
;
pnt_hmg_0
<<
dir_0
,
1
/
unknown_distance
;
pnt_hmg_0
<<
dir_0
,
1
/
unknown_distance
;
LandmarkAHP
::
Ptr
lmk_2
(
std
::
make_shared
<
LandmarkAHP
>
(
pnt_hmg_0
,
kf_2
,
camera
,
cv_image
)
);
LandmarkAHP
::
Ptr
lmk_2
(
std
::
make_shared
<
LandmarkAHP
>
(
pnt_hmg_0
,
kf_2
,
camera
,
desc
)
);
problem
->
addLandmark
(
lmk_2
);
problem
->
addLandmark
(
lmk_2
);
// New constraints from kf3 and kf4
// New constraints from kf3 and kf4
...
@@ -249,8 +245,18 @@ int main(int argc, char** argv)
...
@@ -249,8 +245,18 @@ int main(int argc, char** argv)
ceres
::
Solver
::
Summary
summary
=
ceres_manager
.
solve
();
ceres
::
Solver
::
Summary
summary
=
ceres_manager
.
solve
();
std
::
cout
<<
summary
.
FullReport
()
<<
std
::
endl
;
std
::
cout
<<
summary
.
FullReport
()
<<
std
::
endl
;
// Test of convergence over the lmk params
bool
pass
=
(
lmk_2
->
getPoint3D
()
-
lmk_1
->
getPoint3D
()).
isMuchSmallerThan
(
1
,
Constants
::
EPS
);
std
::
cout
<<
"Landmark 2 below should have converged to Landmark 1:"
<<
std
::
endl
;
std
::
cout
<<
"Landmark 1: "
<<
lmk_1
->
getPoint3D
().
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Landmark 1: "
<<
lmk_1
->
getPoint3D
().
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Landmark 2: "
<<
lmk_2
->
getPoint3D
().
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Landmark 2: "
<<
lmk_2
->
getPoint3D
().
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"Landmark convergence test "
<<
(
pass
?
"PASSED"
:
"FAILED"
)
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
if
(
!
pass
)
return
-
1
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment