Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hpp-fcl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Guilhem Saurel
hpp-fcl
Commits
2517ed88
Commit
2517ed88
authored
5 years ago
by
Gabriele Buondonno
Browse files
Options
Downloads
Patches
Plain Diff
[test] Python unit tests
parent
3eeb888e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/CMakeLists.txt
+5
-0
5 additions, 0 deletions
test/CMakeLists.txt
test/python_unit/CMakeLists.txt
+7
-0
7 additions, 0 deletions
test/python_unit/CMakeLists.txt
test/python_unit/geometric_shapes.py
+81
-0
81 additions, 0 deletions
test/python_unit/geometric_shapes.py
with
93 additions
and
0 deletions
test/CMakeLists.txt
+
5
−
0
View file @
2517ed88
...
...
@@ -57,3 +57,8 @@ endif(HPP_FCL_HAVE_OCTOMAP)
## Benchmark
add_executable
(
test-benchmark benchmark.cpp
)
target_link_libraries
(
test-benchmark hpp-fcl
${
Boost_LIBRARIES
}
utility
)
## Python tests
IF
(
BUILD_PYTHON_INTERFACE
)
ADD_SUBDIRECTORY
(
python_unit
)
ENDIF
(
BUILD_PYTHON_INTERFACE
)
This diff is collapsed.
Click to expand it.
test/python_unit/CMakeLists.txt
0 → 100644
+
7
−
0
View file @
2517ed88
SET
(
${
PROJECT_NAME
}
_PYTHON_TESTS
geometric_shapes
)
FOREACH
(
TEST
${${
PROJECT_NAME
}
_PYTHON_TESTS
}
)
ADD_PYTHON_UNIT_TEST
(
"py-
${
TEST
}
"
"test/python_unit/
${
TEST
}
.py"
"python"
)
ENDFOREACH
(
TEST
${${
PROJECT_NAME
}
_PYTHON_TESTS
}
)
This diff is collapsed.
Click to expand it.
test/python_unit/geometric_shapes.py
0 → 100644
+
81
−
0
View file @
2517ed88
import
unittest
import
eigenpy
eigenpy
.
switchToNumpyMatrix
()
import
hppfcl
import
numpy
as
np
class
TestGeometricShapes
(
unittest
.
TestCase
):
def
test_capsule
(
self
):
capsule
=
hppfcl
.
Capsule
(
1.
,
2.
)
self
.
assertIsInstance
(
capsule
,
hppfcl
.
Capsule
)
self
.
assertIsInstance
(
capsule
,
hppfcl
.
ShapeBase
)
self
.
assertIsInstance
(
capsule
,
hppfcl
.
CollisionGeometry
)
self
.
assertEqual
(
capsule
.
getNodeType
(),
hppfcl
.
NODE_TYPE
.
GEOM_CAPSULE
)
self
.
assertEqual
(
capsule
.
radius
,
1.
)
self
.
assertEqual
(
capsule
.
lz
,
2.
)
capsule
.
radius
=
3.
capsule
.
lz
=
4.
self
.
assertEqual
(
capsule
.
radius
,
3.
)
self
.
assertEqual
(
capsule
.
lz
,
4.
)
def
test_box1
(
self
):
box
=
hppfcl
.
Box
(
np
.
matrix
([
1.
,
2.
,
3.
]).
T
)
self
.
assertIsInstance
(
box
,
hppfcl
.
Box
)
self
.
assertIsInstance
(
box
,
hppfcl
.
ShapeBase
)
self
.
assertIsInstance
(
box
,
hppfcl
.
CollisionGeometry
)
self
.
assertEqual
(
box
.
getNodeType
(),
hppfcl
.
NODE_TYPE
.
GEOM_BOX
)
self
.
assertTrue
(
np
.
array_equal
(
box
.
halfSide
,
np
.
matrix
([.
5
,
1.
,
1.5
]).
T
))
box
.
halfSide
=
np
.
matrix
([
4.
,
5.
,
6.
]).
T
self
.
assertTrue
(
np
.
array_equal
(
box
.
halfSide
,
np
.
matrix
([
4.
,
5.
,
6.
]).
T
))
def
test_box2
(
self
):
box
=
hppfcl
.
Box
(
1.
,
2.
,
3
)
self
.
assertIsInstance
(
box
,
hppfcl
.
Box
)
self
.
assertIsInstance
(
box
,
hppfcl
.
ShapeBase
)
self
.
assertIsInstance
(
box
,
hppfcl
.
CollisionGeometry
)
self
.
assertEqual
(
box
.
getNodeType
(),
hppfcl
.
NODE_TYPE
.
GEOM_BOX
)
self
.
assertEqual
(
box
.
halfSide
[
0
],
0.5
)
self
.
assertEqual
(
box
.
halfSide
[
1
],
1.0
)
self
.
assertEqual
(
box
.
halfSide
[
2
],
1.5
)
box
.
halfSide
[
0
]
=
4.
box
.
halfSide
[
0
]
=
5.
box
.
halfSide
[
0
]
=
6.
# self.assertEqual(box.halfSide[0],4.)
# self.assertEqual(box.halfSide[1],5.)
# self.assertEqual(box.halfSide[2],6.)
def
test_sphere
(
self
):
sphere
=
hppfcl
.
Sphere
(
1.
)
self
.
assertIsInstance
(
sphere
,
hppfcl
.
Sphere
)
self
.
assertIsInstance
(
sphere
,
hppfcl
.
ShapeBase
)
self
.
assertIsInstance
(
sphere
,
hppfcl
.
CollisionGeometry
)
self
.
assertEqual
(
sphere
.
getNodeType
(),
hppfcl
.
NODE_TYPE
.
GEOM_SPHERE
)
self
.
assertEqual
(
sphere
.
radius
,
1.
)
sphere
.
radius
=
2.
self
.
assertEqual
(
sphere
.
radius
,
2.
)
def
test_cylinder
(
self
):
cylinder
=
hppfcl
.
Cylinder
(
1.
,
2.
)
self
.
assertIsInstance
(
cylinder
,
hppfcl
.
Cylinder
)
self
.
assertIsInstance
(
cylinder
,
hppfcl
.
ShapeBase
)
self
.
assertIsInstance
(
cylinder
,
hppfcl
.
CollisionGeometry
)
self
.
assertEqual
(
cylinder
.
getNodeType
(),
hppfcl
.
NODE_TYPE
.
GEOM_CYLINDER
)
self
.
assertEqual
(
cylinder
.
radius
,
1.
)
self
.
assertEqual
(
cylinder
.
lz
,
2.
)
def
test_cone
(
self
):
cone
=
hppfcl
.
Cone
(
1.
,
2.
)
self
.
assertIsInstance
(
cone
,
hppfcl
.
Cone
)
self
.
assertIsInstance
(
cone
,
hppfcl
.
ShapeBase
)
self
.
assertIsInstance
(
cone
,
hppfcl
.
CollisionGeometry
)
self
.
assertEqual
(
cone
.
getNodeType
(),
hppfcl
.
NODE_TYPE
.
GEOM_CONE
)
self
.
assertEqual
(
cone
.
radius
,
1.
)
self
.
assertEqual
(
cone
.
lz
,
2.
)
cone
.
radius
=
3.
cone
.
lz
=
4.
self
.
assertEqual
(
cone
.
radius
,
3.
)
self
.
assertEqual
(
cone
.
lz
,
4.
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
\ No newline at end of file
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