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
cc9ff40c
Commit
cc9ff40c
authored
8 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for FrameBase
parent
5c94d449
No related branches found
No related tags found
1 merge request
!104
Ctest configuration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/gtest_frame_base.cpp
+74
-19
74 additions, 19 deletions
src/test/gtest_frame_base.cpp
with
74 additions
and
19 deletions
src/test/gtest_frame_base.cpp
+
74
−
19
View file @
cc9ff40c
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
#include
"../frame_base.h"
#include
"../frame_base.h"
#include
"../sensor_odom_2D.h"
#include
"../sensor_odom_2D.h"
#include
"../constraint_odom_2D.h"
#include
"../capture_motion.h"
#include
<iostream>
#include
<iostream>
...
@@ -23,37 +25,90 @@ using namespace wolf;
...
@@ -23,37 +25,90 @@ using namespace wolf;
TEST
(
FrameBase
,
GettersAndSetters
)
TEST
(
FrameBase
,
GettersAndSetters
)
{
{
FrameBasePtr
f
=
make_shared
<
FrameBase
>
(
1
,
make_shared
<
StateBlock
>
(
2
),
make_shared
<
StateBlock
>
(
1
));
FrameBasePtr
F
=
make_shared
<
FrameBase
>
(
1
,
make_shared
<
StateBlock
>
(
2
),
make_shared
<
StateBlock
>
(
1
));
// getters
// getters
ASSERT_EQ
(
f
->
id
(),
1
);
ASSERT_EQ
(
F
->
id
(),
1
);
ASSERT_EQ
(
f
->
getTimeStamp
(),
1
);
ASSERT_EQ
(
F
->
getTimeStamp
(),
1
);
TimeStamp
t
;
TimeStamp
t
;
f
->
getTimeStamp
(
t
);
F
->
getTimeStamp
(
t
);
ASSERT_EQ
(
t
,
1
);
ASSERT_EQ
(
t
,
1
);
ASSERT_EQ
(
f
->
getPPtr
()
->
getVector
().
size
(),
2
);
ASSERT_EQ
(
F
->
isFixed
(),
false
);
ASSERT_EQ
(
f
->
getOPtr
()
->
getVector
().
size
(),
1
);
ASSERT_EQ
(
F
->
isKey
(),
false
);
ASSERT_EQ
(
f
->
getVPtr
(),
nullptr
);
ASSERT_EQ
(
f
->
isFixed
(),
false
);
ASSERT_EQ
(
f
->
isKey
(),
false
);
ASSERT_EQ
(
f
->
getStateBlockVec
().
size
(),
3
);
ASSERT_FALSE
(
f
->
getTrajectoryPtr
());
ASSERT_FALSE
(
f
->
getProblem
());
// ASSERT_THROW(f->getPreviousFrame(), std::runtime_error); // protected by assert()
// ASSERT_EQ(f->getStatus(), ST_ESTIMATED); // protected
ASSERT_FALSE
(
f
->
getCaptureOf
(
make_shared
<
SensorOdom2D
>
(
nullptr
,
nullptr
,
1
,
1
)));
ASSERT_TRUE
(
f
->
getCaptureList
().
empty
());
ASSERT_TRUE
(
f
->
getConstrainedByList
().
empty
());
}
}
TEST
(
FrameBase
,
TimeStamp
)
TEST
(
FrameBase
,
StateBlocks
)
{
{
FrameBasePtr
F
=
make_shared
<
FrameBase
>
(
1
,
make_shared
<
StateBlock
>
(
2
),
make_shared
<
StateBlock
>
(
1
));
ASSERT_EQ
(
F
->
getStateBlockVec
().
size
(),
3
);
ASSERT_EQ
(
F
->
getPPtr
()
->
getVector
().
size
(),
2
);
ASSERT_EQ
(
F
->
getOPtr
()
->
getVector
().
size
(),
1
);
ASSERT_EQ
(
F
->
getVPtr
(),
nullptr
);
}
}
TEST
(
FrameBase
,
Links
ToTree
)
TEST
(
FrameBase
,
Links
Basic
)
{
{
FrameBasePtr
F
=
make_shared
<
FrameBase
>
(
1
,
make_shared
<
StateBlock
>
(
2
),
make_shared
<
StateBlock
>
(
1
));
ASSERT_FALSE
(
F
->
getTrajectoryPtr
());
ASSERT_FALSE
(
F
->
getProblem
());
// ASSERT_THROW(f->getPreviousFrame(), std::runtime_error); // protected by assert()
// ASSERT_EQ(f->getStatus(), ST_ESTIMATED); // protected
ASSERT_FALSE
(
F
->
getCaptureOf
(
make_shared
<
SensorOdom2D
>
(
nullptr
,
nullptr
,
1
,
1
)));
ASSERT_TRUE
(
F
->
getCaptureList
().
empty
());
ASSERT_TRUE
(
F
->
getConstrainedByList
().
empty
());
ASSERT_EQ
(
F
->
getHits
()
,
0
);
}
TEST
(
FrameBase
,
LinksToTree
)
{
// Problem with 2 frames and one motion constraint between them
ProblemPtr
P
=
Problem
::
create
(
FRM_PO_2D
);
TrajectoryBasePtr
T
=
P
->
getTrajectoryPtr
();
SensorOdom2D
::
Ptr
S
=
make_shared
<
SensorOdom2D
>
(
make_shared
<
StateBlock
>
(
2
),
make_shared
<
StateBlock
>
(
1
),
1
,
1
);
P
->
getHardwarePtr
()
->
addSensor
(
S
);
FrameBasePtr
F1
=
make_shared
<
FrameBase
>
(
1
,
make_shared
<
StateBlock
>
(
2
),
make_shared
<
StateBlock
>
(
1
));
T
->
addFrame
(
F1
);
FrameBasePtr
F2
=
make_shared
<
FrameBase
>
(
1
,
make_shared
<
StateBlock
>
(
2
),
make_shared
<
StateBlock
>
(
1
));
T
->
addFrame
(
F2
);
CaptureMotion
::
Ptr
C
=
make_shared
<
CaptureMotion
>
(
1
,
S
,
Vector3s
::
Zero
());
F1
->
addCapture
(
C
);
FeatureBasePtr
f
=
make_shared
<
FeatureBase
>
(
"f"
,
1
);
C
->
addFeature
(
f
);
ConstraintOdom2D
::
Ptr
c
=
make_shared
<
ConstraintOdom2D
>
(
f
,
F2
);
f
->
addConstraint
(
c
);
// c-by link F2 -> c not yet established
ASSERT_TRUE
(
F2
->
getConstrainedByList
().
empty
());
// establish link F2 -> c
F2
->
addConstrainedBy
(
c
);
// F1 has one capture and no constraints-by
ASSERT_FALSE
(
F1
->
getCaptureList
().
empty
());
ASSERT_TRUE
(
F1
->
getConstrainedByList
().
empty
());
ASSERT_EQ
(
F1
->
getHits
()
,
0
);
// F2 has no capture and one constraint-by
ASSERT_TRUE
(
F2
->
getCaptureList
().
empty
());
ASSERT_FALSE
(
F2
->
getConstrainedByList
().
empty
());
ASSERT_EQ
(
F2
->
getHits
()
,
1
);
// fix and unfix
F1
->
fix
();
ASSERT_TRUE
(
F1
->
isFixed
());
F1
->
unfix
();
ASSERT_FALSE
(
F1
->
isFixed
());
// set key
F1
->
setKey
();
ASSERT_TRUE
(
F1
->
isKey
());
// Unlink
F1
->
unlinkCapture
(
C
);
ASSERT_TRUE
(
F1
->
getCaptureList
().
empty
());
}
}
...
...
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