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
126cd3d7
Verified
Commit
126cd3d7
authored
5 years ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
test/capsule: add failing tests
parent
47ec0a70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/capsule_capsule.cpp
+107
-0
107 additions, 0 deletions
test/capsule_capsule.cpp
with
107 additions
and
0 deletions
test/capsule_capsule.cpp
+
107
−
0
View file @
126cd3d7
...
...
@@ -99,6 +99,113 @@ BOOST_AUTO_TEST_CASE(collision_capsule_capsule_trivial)
}
}
BOOST_AUTO_TEST_CASE
(
collision_capsule_capsule_aligned
)
{
const
double
radius
=
0.01
;
const
double
length
=
0.2
;
CollisionGeometryPtr_t
c1
(
new
Capsule
(
radius
,
length
));
CollisionGeometryPtr_t
c2
(
new
Capsule
(
radius
,
length
));
int
num_tests
=
1e6
;
Transform3f
tf1
;
Transform3f
tf2
;
Eigen
::
Vector3d
p1
=
Eigen
::
Vector3d
::
Zero
();
Eigen
::
Vector3d
p2_no_collision
=
Eigen
::
Vector3d
(
0.
,
0.
,
2
*
(
length
/
2.
+
radius
)
+
1e-3
);
// because capsule are along the Z axis
for
(
int
i
=
0
;
i
<
num_tests
;
++
i
)
{
Eigen
::
Matrix3d
rot
=
Eigen
::
Quaterniond
::
UnitRandom
().
toRotationMatrix
();
tf1
.
setTranslation
(
p1
);
tf1
.
setRotation
(
rot
);
tf2
.
setTranslation
(
p2_no_collision
);
tf2
.
setRotation
(
rot
);
CollisionObject
capsule_o1
(
c1
,
tf1
);
CollisionObject
capsule_o2
(
c2
,
tf2
);
// Enable computation of nearest points
CollisionRequest
collisionRequest
;
CollisionResult
capsule_collisionResult
;
size_t
capsule_num_collisions
=
collide
(
&
capsule_o1
,
&
capsule_o2
,
collisionRequest
,
capsule_collisionResult
);
BOOST_CHECK
(
capsule_num_collisions
==
0
);
}
Eigen
::
Vector3d
p2_with_collision
=
Eigen
::
Vector3d
(
0.
,
0.
,
std
::
min
(
length
/
2.
,
radius
)
*
(
1.
-
1e-2
));
for
(
int
i
=
0
;
i
<
num_tests
;
++
i
)
{
Eigen
::
Matrix3d
rot
=
Eigen
::
Quaterniond
::
UnitRandom
().
toRotationMatrix
();
tf1
.
setTranslation
(
p1
);
tf1
.
setRotation
(
rot
);
tf2
.
setTranslation
(
p2_with_collision
);
tf2
.
setRotation
(
rot
);
CollisionObject
capsule_o1
(
c1
,
tf1
);
CollisionObject
capsule_o2
(
c2
,
tf2
);
// Enable computation of nearest points
CollisionRequest
collisionRequest
;
CollisionResult
capsule_collisionResult
;
size_t
capsule_num_collisions
=
collide
(
&
capsule_o1
,
&
capsule_o2
,
collisionRequest
,
capsule_collisionResult
);
BOOST_CHECK
(
capsule_num_collisions
>
0
);
}
p2_no_collision
=
Eigen
::
Vector3d
(
0.
,
0.
,
2
*
(
length
/
2.
+
radius
)
+
1e-3
);
Transform3f
geom1_placement
(
Eigen
::
Matrix3d
::
Identity
(),
Eigen
::
Vector3d
::
Zero
());
Transform3f
geom2_placement
(
Eigen
::
Matrix3d
::
Identity
(),
p2_no_collision
);
for
(
int
i
=
0
;
i
<
num_tests
;
++
i
)
{
Eigen
::
Matrix3d
rot
=
Eigen
::
Quaterniond
::
UnitRandom
().
toRotationMatrix
();
Eigen
::
Vector3d
trans
=
Eigen
::
Vector3d
::
Random
();
Transform3f
displacement
(
rot
,
trans
);
Transform3f
tf1
=
displacement
*
geom1_placement
;
Transform3f
tf2
=
displacement
*
geom2_placement
;
CollisionObject
capsule_o1
(
c1
,
tf1
);
CollisionObject
capsule_o2
(
c2
,
tf2
);
// Enable computation of nearest points
CollisionRequest
collisionRequest
;
CollisionResult
capsule_collisionResult
;
size_t
capsule_num_collisions
=
collide
(
&
capsule_o1
,
&
capsule_o2
,
collisionRequest
,
capsule_collisionResult
);
BOOST_CHECK
(
capsule_num_collisions
==
0
);
}
// p2_with_collision = Eigen::Vector3d(0.,0.,std::min(length/2.,radius)*(1.-1e-2));
p2_with_collision
=
Eigen
::
Vector3d
(
0.
,
0.
,
0.01
);
geom2_placement
.
setTranslation
(
p2_with_collision
);
for
(
int
i
=
0
;
i
<
num_tests
;
++
i
)
{
Eigen
::
Matrix3d
rot
=
Eigen
::
Quaterniond
::
UnitRandom
().
toRotationMatrix
();
Eigen
::
Vector3d
trans
=
Eigen
::
Vector3d
::
Random
();
Transform3f
displacement
(
rot
,
trans
);
Transform3f
tf1
=
displacement
*
geom1_placement
;
Transform3f
tf2
=
displacement
*
geom2_placement
;
CollisionObject
capsule_o1
(
c1
,
tf1
);
CollisionObject
capsule_o2
(
c2
,
tf2
);
// Enable computation of nearest points
CollisionRequest
collisionRequest
;
CollisionResult
capsule_collisionResult
;
size_t
capsule_num_collisions
=
collide
(
&
capsule_o1
,
&
capsule_o2
,
collisionRequest
,
capsule_collisionResult
);
BOOST_CHECK
(
capsule_num_collisions
>
0
);
}
}
BOOST_AUTO_TEST_CASE
(
distance_capsulecapsule_origin
)
{
CollisionGeometryPtr_t
s1
(
new
Capsule
(
5
,
10
));
...
...
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