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
3d9f904a
Commit
3d9f904a
authored
7 years ago
by
Dinesh Atchuthan
Browse files
Options
Downloads
Patches
Plain Diff
added gtest for ConstraintAbs(P/O/V)
parent
38a5f8a7
No related branches found
No related tags found
1 merge request
!149
Constraint abs
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/CMakeLists.txt
+4
-0
4 additions, 0 deletions
src/test/CMakeLists.txt
src/test/gtest_constraint_absolute.cpp
+124
-0
124 additions, 0 deletions
src/test/gtest_constraint_absolute.cpp
with
128 additions
and
0 deletions
src/test/CMakeLists.txt
+
4
−
0
View file @
3d9f904a
...
...
@@ -90,6 +90,10 @@ target_link_libraries(gtest_trajectory ${PROJECT_NAME})
# ------- Now Derived classes ----------
# ConstraintAbs(P/O/V) classes test
wolf_add_gtest
(
gtest_constraint_absolute gtest_constraint_absolute.cpp
)
target_link_libraries
(
gtest_constraint_absolute
${
PROJECT_NAME
}
)
# ConstraintFix3D class test
wolf_add_gtest
(
gtest_constraint_fix_3D gtest_constraint_fix_3D.cpp
)
target_link_libraries
(
gtest_constraint_fix_3D
${
PROJECT_NAME
}
)
...
...
This diff is collapsed.
Click to expand it.
src/test/gtest_constraint_absolute.cpp
0 → 100644
+
124
−
0
View file @
3d9f904a
/**
* \file gtest_constraint_absolute.cpp
*
* Created on: Dec 9, 2017
* \author: datchuth
*/
#include
"utils_gtest.h"
#include
"constraint_absolute_position.h"
#include
"constraint_absolute_orientation.h"
#include
"constraint_absolute_velocity.h"
#include
"capture_motion.h"
#include
"ceres_wrapper/ceres_manager.h"
using
namespace
Eigen
;
using
namespace
wolf
;
using
std
::
cout
;
using
std
::
endl
;
Vector10s
pose9toPose10
(
Vector9s
_pose9
)
{
return
(
Vector10s
()
<<
_pose9
.
head
<
3
>
()
,
v2q
(
_pose9
.
segment
<
3
>
(
3
)).
coeffs
(),
_pose9
.
tail
<
3
>
()).
finished
();
}
// Input pose9 and covariance
Vector9s
pose
(
Vector9s
::
Random
());
Vector10s
pose10
=
pose9toPose10
(
pose
);
Vector9s
data_var
((
Vector9s
()
<<
0.2
,
0.2
,
0.2
,
0.2
,
0.2
,
0.2
,
0.2
,
0.2
,
0.2
).
finished
());
Eigen
::
Matrix
<
wolf
::
Scalar
,
9
,
9
>
data_cov
=
data_var
.
asDiagonal
();
// perturbated priors
Vector10s
x0
=
pose9toPose10
(
pose
+
Vector9s
::
Random
()
*
0.25
);
// Problem and solver
ProblemPtr
problem
=
Problem
::
create
(
"POV 3D"
);
CeresManager
ceres_mgr
(
problem
);
// Two frames
FrameBasePtr
frm0
=
problem
->
emplaceFrame
(
KEY_FRAME
,
problem
->
zeroState
(),
TimeStamp
(
0
));
// Capture, feature and constraint
CaptureBasePtr
cap0
=
frm0
->
addCapture
(
std
::
make_shared
<
CaptureMotion
>
(
0
,
nullptr
,
pose10
,
10
,
9
,
nullptr
));
//FeatureBasePtr fea0 = cap0->addFeature(std::make_shared<FeatureBase>("FIX", pose10.head<3>(), data_cov.topLeftCorner<3,3>()));
////////////////////////////////////////////////////////
TEST
(
ConstraintAbsP
,
ctr_abs_p_check
)
{
FeatureBasePtr
fea0
=
cap0
->
addFeature
(
std
::
make_shared
<
FeatureBase
>
(
"FIX"
,
pose10
.
head
<
3
>
(),
data_cov
.
topLeftCorner
<
3
,
3
>
()));
ConstraintAbsPPtr
ctr0
=
std
::
static_pointer_cast
<
ConstraintAbsP
>
(
fea0
->
addConstraint
(
std
::
make_shared
<
ConstraintAbsP
>
(
fea0
)));
ASSERT_TRUE
(
problem
->
check
(
0
));
}
TEST
(
ConstraintAbsP
,
ctr_abs_p_solve
)
{
FeatureBasePtr
fea0
=
cap0
->
addFeature
(
std
::
make_shared
<
FeatureBase
>
(
"FIX"
,
pose10
.
head
<
3
>
(),
data_cov
.
topLeftCorner
<
3
,
3
>
()));
ConstraintAbsPPtr
ctr0
=
std
::
static_pointer_cast
<
ConstraintAbsP
>
(
fea0
->
addConstraint
(
std
::
make_shared
<
ConstraintAbsP
>
(
fea0
)));
// Fix frame 0, perturb frm1
frm0
->
unfix
();
frm0
->
setState
(
x0
);
// solve for frm0
std
::
string
brief_report
=
ceres_mgr
.
solve
(
1
);
//only position is constrained
ASSERT_MATRIX_APPROX
(
frm0
->
getState
().
head
<
3
>
(),
pose10
.
head
<
3
>
(),
1e-6
);
}
TEST
(
ConstraintAbsO
,
ctr_abs_o_check
)
{
FeatureBasePtr
fea0
=
cap0
->
addFeature
(
std
::
make_shared
<
FeatureBase
>
(
"FIX"
,
pose10
.
segment
<
4
>
(
3
),
data_cov
.
block
<
3
,
3
>
(
3
,
3
)));
ConstraintAbsOPtr
ctr0
=
std
::
static_pointer_cast
<
ConstraintAbsO
>
(
fea0
->
addConstraint
(
std
::
make_shared
<
ConstraintAbsO
>
(
fea0
)));
ASSERT_TRUE
(
problem
->
check
(
0
));
}
TEST
(
ConstraintAbsO
,
ctr_abs_o_solve
)
{
FeatureBasePtr
fea0
=
cap0
->
addFeature
(
std
::
make_shared
<
FeatureBase
>
(
"FIX"
,
pose10
.
segment
<
4
>
(
3
),
data_cov
.
block
<
3
,
3
>
(
3
,
3
)));
ConstraintAbsOPtr
ctr0
=
std
::
static_pointer_cast
<
ConstraintAbsO
>
(
fea0
->
addConstraint
(
std
::
make_shared
<
ConstraintAbsO
>
(
fea0
)));
// Fix frame 0, perturb frm1
frm0
->
unfix
();
frm0
->
setState
(
x0
);
// solve for frm0
std
::
string
brief_report
=
ceres_mgr
.
solve
(
1
);
//only orientation is constrained
ASSERT_MATRIX_APPROX
(
frm0
->
getState
().
segment
<
4
>
(
3
),
pose10
.
segment
<
4
>
(
3
),
1e-6
);
}
TEST
(
ConstraintAbsV
,
ctr_abs_v_check
)
{
FeatureBasePtr
fea0
=
cap0
->
addFeature
(
std
::
make_shared
<
FeatureBase
>
(
"FIX"
,
pose10
.
tail
<
3
>
(),
data_cov
.
bottomRightCorner
<
3
,
3
>
()));
ConstraintAbsVPtr
ctr0
=
std
::
static_pointer_cast
<
ConstraintAbsV
>
(
fea0
->
addConstraint
(
std
::
make_shared
<
ConstraintAbsV
>
(
fea0
)));
ASSERT_TRUE
(
problem
->
check
(
0
));
}
TEST
(
ConstraintAbsV
,
ctr_abs_v_solve
)
{
FeatureBasePtr
fea0
=
cap0
->
addFeature
(
std
::
make_shared
<
FeatureBase
>
(
"FIX"
,
pose10
.
tail
<
3
>
(),
data_cov
.
bottomRightCorner
<
3
,
3
>
()));
ConstraintAbsVPtr
ctr0
=
std
::
static_pointer_cast
<
ConstraintAbsV
>
(
fea0
->
addConstraint
(
std
::
make_shared
<
ConstraintAbsV
>
(
fea0
)));
// Fix frame 0, perturb frm1
frm0
->
unfix
();
frm0
->
setState
(
x0
);
// solve for frm0
std
::
string
brief_report
=
ceres_mgr
.
solve
(
1
);
//only velocity is constrained
ASSERT_MATRIX_APPROX
(
frm0
->
getState
().
tail
<
3
>
(),
pose10
.
tail
<
3
>
(),
1e-6
);
}
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
This diff is collapsed.
Click to expand it.
Dinesh Atchuthan
@AtDinesh
mentioned in issue
#147 (closed)
·
7 years ago
mentioned in issue
#147 (closed)
mentioned in issue #147
Toggle commit list
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