Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
coal
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
Coal
coal
Commits
b308deef
Unverified
Commit
b308deef
authored
9 months ago
by
Louis Montaut
Browse files
Options
Downloads
Patches
Plain Diff
readme: update python example to use coal
parent
09ee974a
No related branches found
No related tags found
No related merge requests found
Pipeline
#41968
failed
9 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+13
-13
13 additions, 13 deletions
README.md
with
13 additions
and
13 deletions
README.md
+
13
−
13
View file @
b308deef
...
@@ -103,8 +103,8 @@ std::shared_ptr<coal::ConvexBase> loadConvexMesh(const std::string& file_name) {
...
@@ -103,8 +103,8 @@ std::shared_ptr<coal::ConvexBase> loadConvexMesh(const std::string& file_name) {
}
}
int
main
()
{
int
main
()
{
// Create the
hppfc
l shapes.
// Create the
coa
l shapes.
//
Hppfc
l supports many primitive shapes: boxes, spheres, capsules, cylinders, ellipsoids, cones, planes,
//
Coa
l supports many primitive shapes: boxes, spheres, capsules, cylinders, ellipsoids, cones, planes,
// halfspace and convex meshes (i.e. convex hulls of clouds of points).
// halfspace and convex meshes (i.e. convex hulls of clouds of points).
// It also supports BVHs (bounding volumes hierarchies), height-fields and octrees.
// It also supports BVHs (bounding volumes hierarchies), height-fields and octrees.
std
::
shared_ptr
<
coal
::
Ellipsoid
>
shape1
=
std
::
make_shared
<
coal
::
Ellipsoid
>
(
0.7
,
1.0
,
0.8
);
std
::
shared_ptr
<
coal
::
Ellipsoid
>
shape1
=
std
::
make_shared
<
coal
::
Ellipsoid
>
(
0.7
,
1.0
,
0.8
);
...
@@ -161,7 +161,7 @@ int main() {
...
@@ -161,7 +161,7 @@ int main() {
Here is the C++ example from above translated in python using HPP-FCL's python bindings:
Here is the C++ example from above translated in python using HPP-FCL's python bindings:
```
python
```
python
import
numpy
as
np
import
numpy
as
np
import
hppfc
l
import
coa
l
# Optional:
# Optional:
# The Pinocchio library is a rigid body algorithms library and has a handy SE3 module.
# The Pinocchio library is a rigid body algorithms library and has a handy SE3 module.
# It can be installed as simply as `conda -c conda-forge install pinocchio`.
# It can be installed as simply as `conda -c conda-forge install pinocchio`.
...
@@ -169,36 +169,36 @@ import hppfcl
...
@@ -169,36 +169,36 @@ import hppfcl
import
pinocchio
as
pin
import
pinocchio
as
pin
def
loadConvexMesh
(
file_name
:
str
):
def
loadConvexMesh
(
file_name
:
str
):
loader
=
hppfc
l
.
MeshLoader
()
loader
=
coa
l
.
MeshLoader
()
bvh
:
hppfc
l
.
BVHModelBase
=
loader
.
load
(
file_name
)
bvh
:
coa
l
.
BVHModelBase
=
loader
.
load
(
file_name
)
bvh
.
buildConvexHull
(
True
,
"
Qt
"
)
bvh
.
buildConvexHull
(
True
,
"
Qt
"
)
return
bvh
.
convex
return
bvh
.
convex
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
# Create
hppfc
l shapes
# Create
coa
l shapes
shape1
=
hppfc
l
.
Ellipsoid
(
0.7
,
1.0
,
0.8
)
shape1
=
coa
l
.
Ellipsoid
(
0.7
,
1.0
,
0.8
)
shape2
=
loadConvexMesh
(
"
../path/to/mesh/file.obj
"
)
shape2
=
loadConvexMesh
(
"
../path/to/mesh/file.obj
"
)
# Define the shapes' placement in 3D space
# Define the shapes' placement in 3D space
T1
=
hppfc
l
.
Transform3s
()
T1
=
coa
l
.
Transform3s
()
T1
.
setTranslation
(
pin
.
SE3
.
Random
().
translation
)
T1
.
setTranslation
(
pin
.
SE3
.
Random
().
translation
)
T1
.
setRotation
(
pin
.
SE3
.
Random
().
rotation
)
T1
.
setRotation
(
pin
.
SE3
.
Random
().
rotation
)
T2
=
hppfc
l
.
Transform3s
();
T2
=
coa
l
.
Transform3s
();
# Using np arrays also works
# Using np arrays also works
T1
.
setTranslation
(
np
.
random
.
rand
(
3
))
T1
.
setTranslation
(
np
.
random
.
rand
(
3
))
T2
.
setRotation
(
pin
.
SE3
.
Random
().
rotation
)
T2
.
setRotation
(
pin
.
SE3
.
Random
().
rotation
)
# Define collision requests and results
# Define collision requests and results
col_req
=
hppfc
l
.
CollisionRequest
()
col_req
=
coa
l
.
CollisionRequest
()
col_res
=
hppfc
l
.
CollisionResult
()
col_res
=
coa
l
.
CollisionResult
()
# Collision call
# Collision call
hppfc
l
.
collide
(
shape1
,
T1
,
shape2
,
T2
,
col_req
,
col_res
)
coa
l
.
collide
(
shape1
,
T1
,
shape2
,
T2
,
col_req
,
col_res
)
# Accessing the collision result once it has been populated
# Accessing the collision result once it has been populated
print
(
"
Is collision?
"
,
{
col_res
.
isCollision
()})
print
(
"
Is collision?
"
,
{
col_res
.
isCollision
()})
if
col_res
.
isCollision
():
if
col_res
.
isCollision
():
contact
:
hppfc
l
.
Contact
=
col_res
.
getContact
(
0
)
contact
:
coa
l
.
Contact
=
col_res
.
getContact
(
0
)
print
(
"
Penetration depth:
"
,
contact
.
penetration_depth
)
print
(
"
Penetration depth:
"
,
contact
.
penetration_depth
)
print
(
"
Distance between the shapes including the security margin:
"
,
contact
.
penetration_depth
+
col_req
.
security_margin
)
print
(
"
Distance between the shapes including the security margin:
"
,
contact
.
penetration_depth
+
col_req
.
security_margin
)
print
(
"
Witness point shape1:
"
,
contact
.
getNearestPoint1
())
print
(
"
Witness point shape1:
"
,
contact
.
getNearestPoint1
())
...
...
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