Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
hpp-affordance
Commits
7e49de09
Commit
7e49de09
authored
Apr 26, 2016
by
Akseppal
Browse files
add unit tests
parent
26f0fdb1
Changes
4
Hide whitespace changes
Inline
Side-by-side
tests/CMakeLists.txt
View file @
7e49de09
...
...
@@ -51,4 +51,6 @@ endmacro(add_testcase)
# add_affordance_test(test-create-affordance test-main3.cc)
add_testcase (test-operations FALSE)
add_testcase (test-one-triangle FALSE)
add_testcase (test-one-triangle1 FALSE)
add_testcase (test-one-triangle2 FALSE)
add_testcase (test-oriented-triangles FALSE)
tests/test-one-triangle.cc
→
tests/test-one-triangle
1
.cc
View file @
7e49de09
...
...
@@ -21,12 +21,12 @@
#include
<hpp/fcl/BVH/BVH_model.h>
#include
<hpp/fcl/shape/geometric_shape_to_BVH_model.h>
#define BOOST_TEST_MODULE test-one-triangle
#define BOOST_TEST_MODULE test-one-triangle
1
#include
<boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE
(
test_affordance
)
BOOST_AUTO_TEST_CASE
(
one_triangle
)
BOOST_AUTO_TEST_CASE
(
one_triangle
1
)
{
hpp
::
affordance
::
SupportOperationPtr_t
support
(
new
hpp
::
affordance
::
SupportOperation
());
hpp
::
affordance
::
LeanOperationPtr_t
lean
(
new
hpp
::
affordance
::
LeanOperation
(
0.1
));
...
...
tests/test-one-triangle2.cc
0 → 100644
View file @
7e49de09
// Copyright (C) 2016 LAAS-CNRS
// Author: Anna Seppala
//
// This file is part of the hpp-affordance.
//
// hpp-affordance is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// hpp-affordance is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with hpp-affordance. If not, see <http://www.gnu.org/licenses/>.
#include
<hpp/affordance/affordance-extraction.hh>
#include
<hpp/affordance/operations.hh>
#include
<hpp/fcl/BVH/BVH_model.h>
#include
<hpp/fcl/shape/geometric_shape_to_BVH_model.h>
#define BOOST_TEST_MODULE test-one-triangle2
#include
<boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE
(
test_affordance
)
BOOST_AUTO_TEST_CASE
(
one_triangle2
)
{
hpp
::
affordance
::
SupportOperationPtr_t
support
(
new
hpp
::
affordance
::
SupportOperation
());
hpp
::
affordance
::
LeanOperationPtr_t
lean
(
new
hpp
::
affordance
::
LeanOperation
(
0.1
));
std
::
vector
<
hpp
::
affordance
::
OperationBasePtr_t
>
operations
;
operations
.
push_back
(
support
);
operations
.
push_back
(
lean
);
std
::
vector
<
fcl
::
Vec3f
>
vertices
;
std
::
vector
<
fcl
::
Triangle
>
triangles
;
typedef
fcl
::
BVHModel
<
fcl
::
OBBRSS
>
Model
;
boost
::
shared_ptr
<
Model
>
model
(
new
Model
());
fcl
::
Vec3f
vert1
(
-
1
,
0
,
0
);
fcl
::
Vec3f
vert2
(
1
,
0
,
1
);
fcl
::
Vec3f
vert3
(
1
,
0
,
-
1
);
vertices
.
push_back
(
vert1
);
vertices
.
push_back
(
vert2
);
vertices
.
push_back
(
vert3
);
fcl
::
Triangle
tri
(
0
,
1
,
2
);
triangles
.
push_back
(
tri
);
fcl
::
Matrix3f
R
;
fcl
::
Quaternion3f
quat
(
1
,
0
,
0
,
0
);
quat
.
toRotation
(
R
);
fcl
::
Vec3f
T
(
0
,
0
,
0
);
fcl
::
Transform3f
pose
(
R
,
T
);
model
->
beginModel
();
model
->
addSubModel
(
vertices
,
triangles
);
model
->
endModel
();
boost
::
shared_ptr
<
fcl
::
CollisionObject
>
obj
(
new
fcl
::
CollisionObject
(
model
,
pose
));
hpp
::
affordance
::
SemanticsDataPtr_t
h
=
hpp
::
affordance
::
affordanceAnalysis
(
obj
,
operations
);
BOOST_CHECK_MESSAGE
(
h
->
affordances_
.
size
()
==
2
,
"strictly two affordance types should exist."
);
BOOST_CHECK_MESSAGE
(
h
->
affordances_
[
1
].
size
()
==
1
,
"strictly one lean affordance should have been found."
);
BOOST_CHECK_MESSAGE
(
h
->
affordances_
[
0
].
size
()
==
0
,
"no support affordance should have been found at this point."
);
}
BOOST_AUTO_TEST_SUITE_END
()
tests/test-oriented-triangles.cc
0 → 100644
View file @
7e49de09
// Copyright (C) 2016 LAAS-CNRS
// Author: Anna Seppala
//
// This file is part of the hpp-affordance.
//
// hpp-affordance is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// hpp-affordance is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with hpp-affordance. If not, see <http://www.gnu.org/licenses/>.
#include
<hpp/affordance/affordance-extraction.hh>
#include
<hpp/affordance/operations.hh>
#include
<hpp/fcl/BVH/BVH_model.h>
#include
<hpp/fcl/shape/geometric_shape_to_BVH_model.h>
#define BOOST_TEST_MODULE test-oriented-triangles
#include
<boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE
(
test_affordance
)
BOOST_AUTO_TEST_CASE
(
oriented_triangles
)
{
hpp
::
affordance
::
SupportOperationPtr_t
support
(
new
hpp
::
affordance
::
SupportOperation
());
hpp
::
affordance
::
LeanOperationPtr_t
lean
(
new
hpp
::
affordance
::
LeanOperation
(
0.1
));
std
::
vector
<
hpp
::
affordance
::
OperationBasePtr_t
>
operations
;
operations
.
push_back
(
support
);
operations
.
push_back
(
lean
);
std
::
vector
<
fcl
::
Vec3f
>
vertices
;
std
::
vector
<
fcl
::
Triangle
>
triangles
;
typedef
fcl
::
BVHModel
<
fcl
::
OBBRSS
>
Model
;
fcl
::
Vec3f
vert1
(
-
1
,
0
,
0
);
fcl
::
Vec3f
vert2
(
1
,
0
,
1
);
fcl
::
Vec3f
vert3
(
1
,
0
,
-
1
);
vertices
.
push_back
(
vert1
);
vertices
.
push_back
(
vert2
);
vertices
.
push_back
(
vert3
);
int
size_
=
7
;
int
affFound
=
0
;
int
affNotFound
=
0
;
fcl
::
Vec3f
T
(
0
,
0
,
0
);
fcl
::
Vec3f
axis
(
1
,
0
,
0
);
fcl
::
Matrix3f
R
;
for
(
unsigned
int
i
=
0
;
i
<
size_
;
++
i
)
{
boost
::
shared_ptr
<
Model
>
model
(
new
Model
());
fcl
::
Triangle
tri
(
0
,
1
,
2
);
triangles
.
push_back
(
tri
);
fcl
::
Quaternion3f
quat
;
quat
.
fromAxisAngle
(
axis
,
3.1416
*
float
(
i
)
/
180.0
);
quat
.
toRotation
(
R
);
fcl
::
Transform3f
pose
(
R
,
T
);
model
->
beginModel
();
model
->
addSubModel
(
vertices
,
triangles
);
model
->
endModel
();
boost
::
shared_ptr
<
fcl
::
CollisionObject
>
obj
(
new
fcl
::
CollisionObject
(
model
,
pose
));
hpp
::
affordance
::
SemanticsDataPtr_t
h
=
hpp
::
affordance
::
affordanceAnalysis
(
obj
,
operations
);
if
(
h
->
affordances_
[
1
].
size
()
==
1
&&
h
->
affordances_
[
0
].
size
()
==
0
)
{
affFound
+=
1
;
}
else
{
affNotFound
+=
1
;
}
}
BOOST_CHECK_MESSAGE
(
affFound
==
6
&&
affNotFound
==
1
,
"Strictly six affordances should have been found and one rejected. Now "
<<
affFound
<<
"were found and "
<<
affNotFound
<<
" rejected."
);
}
BOOST_AUTO_TEST_SUITE_END
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment