Skip to content

Commit

Permalink
Address reviewer comments
Browse files Browse the repository at this point in the history
    1. Fix typos
    2. Update copyright
    3. Simplify mathematical expression
    4. Test w.r.t. templated scalar.
  • Loading branch information
SeanCurtis-TRI committed Mar 2, 2018
1 parent e753d52 commit 4a1677f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ bool cylinderHalfspaceIntersect(const Cylinder<S>& s1, const Transform3<S>& tf1,
else
{
Vector3<S> C = dir_z * cosa - new_s2.n;
if(std::abs(cosa + 1) < halfspaceIntersectTolerance<S>() || std::abs(cosa - 1) < halfspaceIntersectTolerance<S>())
if(std::abs(cosa) - 1 < halfspaceIntersectTolerance<S>())
C = Vector3<S>(0, 0, 0);
else
{
Expand Down
14 changes: 6 additions & 8 deletions test/test_fcl_cylinder_half_space.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2013-2014, Willow Garage, Inc.
* Copyright (c) 2014-2016, Open Source Robotics Foundation
* All rights reserved.
* Copyright (c) 2018, Toyota Research Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -62,7 +60,7 @@ void test_collision_cylinder_half_space(fcl::GJKSolverType solver_type)
// Pose of half space frame H in the world frame W.
Transform3<S> X_WH = Transform3<S>::Identity();

CollisionObject<S> half_sapce_co(half_space, X_WH);
CollisionObject<S> half_space_co(half_space, X_WH);
CollisionObject<S> cylinder_co(cylinder, X_WC);

fcl::CollisionResult<S> result;
Expand All @@ -71,22 +69,22 @@ void test_collision_cylinder_half_space(fcl::GJKSolverType solver_type)
fcl::CollisionRequest<S> request(num_max_contacts, enable_contact);
request.gjk_solver_type = solver_type;

fcl::collide(&half_sapce_co, &cylinder_co, request, result);
fcl::collide(&half_space_co, &cylinder_co, request, result);
vector<Contact<S>> contacts;
result.getContacts(contacts);

EXPECT_EQ(static_cast<int>(contacts.size()), 1);
EXPECT_NEAR(contacts[0].penetration_depth, 0.051, kTolerance);

// Now perform the same test but with the cylinder's z axis Cz pointing down.
X_WC.linear() = AngleAxisd(M_PI, Vector3d::UnitX()).matrix();
X_WC.translation() = Vector3d(0, 0, 0.049);
X_WC.linear() = AngleAxis<S>(M_PI, Vector3d::UnitX()).matrix();
X_WC.translation() = Vector3<S>(0, 0, 0.049);
cylinder_co.setTransform(X_WC);

result.clear();
contacts.clear();

fcl::collide(&half_sapce_co, &cylinder_co, request, result);
fcl::collide(&half_space_co, &cylinder_co, request, result);
result.getContacts(contacts);

EXPECT_EQ(static_cast<int>(contacts.size()), 1);
Expand Down

0 comments on commit 4a1677f

Please sign in to comment.