Skip to content

Commit

Permalink
Separate enableSelfCollision into two concrete functions: `setSelfC…
Browse files Browse the repository at this point in the history
…ollisionCheck`, `setAdjacentBodyCheck`
  • Loading branch information
jslee02 committed May 8, 2016
1 parent 46e531d commit 45e0e0a
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 21 deletions.
63 changes: 54 additions & 9 deletions dart/dynamics/Skeleton.cpp
Expand Up @@ -557,11 +557,8 @@ void Skeleton::setAspectProperties(const AspectProperties& properties)
setMobile(properties.mIsMobile);
setGravity(properties.mGravity);
setTimeStep(properties.mTimeStep);

if(properties.mEnabledSelfCollisionCheck)
enableSelfCollision(properties.mEnabledAdjacentBodyCheck);
else
disableSelfCollision();
setSelfCollisionCheck(properties.mEnabledSelfCollisionCheck);
setAdjacentBodyCheck(properties.mEnabledAdjacentBodyCheck);
}

//==============================================================================
Expand Down Expand Up @@ -636,10 +633,10 @@ void Skeleton::addEntryToSoftBodyNodeNameMgr(SoftBodyNode* _newNode)
}

//==============================================================================
void Skeleton::enableSelfCollision(bool _enableAdjacentBodyCheck)
void Skeleton::enableSelfCollision(bool enableAdjacentBodyCheck)
{
mAspectProperties.mEnabledSelfCollisionCheck = true;
mAspectProperties.mEnabledAdjacentBodyCheck = _enableAdjacentBodyCheck;
mAspectProperties.mEnabledAdjacentBodyCheck = enableAdjacentBodyCheck;
}

//==============================================================================
Expand All @@ -650,17 +647,65 @@ void Skeleton::disableSelfCollision()
}

//==============================================================================
bool Skeleton::isEnabledSelfCollisionCheck() const
void Skeleton::setSelfCollisionCheck(bool enable)
{
mAspectProperties.mEnabledSelfCollisionCheck = enable;
}

//==============================================================================
bool Skeleton::getSelfCollisionCheck() const
{
return mAspectProperties.mEnabledSelfCollisionCheck;
}

//==============================================================================
bool Skeleton::isEnabledAdjacentBodyCheck() const
void Skeleton::enableSelfCollisionCheck()
{
setSelfCollisionCheck(true);
}

//==============================================================================
void Skeleton::disableSelfCollisionCheck()
{
setSelfCollisionCheck(false);
}

//==============================================================================
bool Skeleton::isEnabledSelfCollisionCheck() const
{
return getSelfCollisionCheck();
}

//==============================================================================
void Skeleton::setAdjacentBodyCheck(bool enable)
{
mAspectProperties.mEnabledAdjacentBodyCheck = enable;
}

//==============================================================================
bool Skeleton::getAdjacentBodyCheck() const
{
return mAspectProperties.mEnabledAdjacentBodyCheck;
}

//==============================================================================
void Skeleton::enableAdjacentBodyCheck()
{
setAdjacentBodyCheck(true);
}

//==============================================================================
void Skeleton::disableAdjacentBodyCheck()
{
setAdjacentBodyCheck(false);
}

//==============================================================================
bool Skeleton::isEnabledAdjacentBodyCheck() const
{
return getAdjacentBodyCheck();
}

//==============================================================================
void Skeleton::setMobile(bool _isMobile)
{
Expand Down
40 changes: 34 additions & 6 deletions dart/dynamics/Skeleton.hpp
Expand Up @@ -226,17 +226,45 @@ class Skeleton :
/// Get name.
const std::string& getName() const override;

/// Enable self collision check
void enableSelfCollision(bool _enableAdjacentBodyCheck = false);
/// Deprecated. Please use enableSelfCollision() instead.
DEPRECATED(6.0)
void enableSelfCollision(bool enableAdjacentBodyCheck = false);

/// Disable self collision check
/// Deprecated. Please use disableSelfCollisionCheck() instead.
DEPRECATED(6.0)
void disableSelfCollision();

/// Return true if self collision check is enabled
/// Set whether to check self-collision.
void setSelfCollisionCheck(bool enable);

/// Return whether self-collision check is enabled.
bool getSelfCollisionCheck() const;

/// Enable self-collision check.
void enableSelfCollisionCheck();

/// Disable self-collision check.
void disableSelfCollisionCheck();

/// Return true if self-collision check is enabled
bool isEnabledSelfCollisionCheck() const;

/// Return true if self collision check is enabled including adjacent
/// bodies
/// Set whether to check adjacent bodies. This option is effective only when
/// the self-collision check is enabled.
void setAdjacentBodyCheck(bool enable);

/// Return whether adjacent body check is enabled.
bool getAdjacentBodyCheck() const;

/// Enable collision check for adjacent bodies. This option is effective only
/// when the self-collision check is enabled.
void enableAdjacentBodyCheck();

/// Disable collision check for adjacent bodies. This option is effective only
/// when the self-collision check is enabled.
void disableAdjacentBodyCheck();

/// Return true if self-collision check is enabled including adjacent bodies.
bool isEnabledAdjacentBodyCheck() const;

/// Set whether this skeleton will be updated by forward dynamics.
Expand Down
3 changes: 2 additions & 1 deletion tutorials/tutorialBiped-Finished.cpp
Expand Up @@ -311,7 +311,8 @@ SkeletonPtr loadBiped()
biped->getJoint(i)->setPositionLimitEnforced(true);

// Enable self collision check but ignore adjacent bodies
biped->enableSelfCollision();
biped->enableSelfCollisionCheck();
biped->disableAdjacentBodyCheck();

return biped;
}
Expand Down
4 changes: 2 additions & 2 deletions unittests/TestHelpers.hpp
Expand Up @@ -262,7 +262,7 @@ SkeletonPtr createNLinkRobot(int _n, Vector3d dim, TypeOfDOF type,
assert(_n > 0);

SkeletonPtr robot = Skeleton::create();
robot->disableSelfCollision();
robot->disableSelfCollisionCheck();

// Create the first link, the joint with the ground and its shape
BodyNode::Properties node(BodyNode::AspectProperties("link1"));
Expand Down Expand Up @@ -329,7 +329,7 @@ SkeletonPtr createNLinkPendulum(size_t numBodyNodes,
assert(numBodyNodes > 0);

SkeletonPtr robot = Skeleton::create();
robot->disableSelfCollision();
robot->disableSelfCollisionCheck();

// Create the first link, the joint with the ground and its shape
BodyNode::Properties node(BodyNode::AspectProperties("link1"));
Expand Down
6 changes: 3 additions & 3 deletions unittests/testJoints.cpp
Expand Up @@ -516,7 +516,7 @@ void testJointCoulombFrictionForce(double _timeStep)

dynamics::SkeletonPtr pendulum = myWorld->getSkeleton("double_pendulum");
EXPECT_TRUE(pendulum != nullptr);
pendulum->disableSelfCollision();
pendulum->disableSelfCollisionCheck();

dynamics::Joint* joint0 = pendulum->getJoint("joint0");
dynamics::Joint* joint1 = pendulum->getJoint("joint1");
Expand Down Expand Up @@ -635,7 +635,7 @@ SkeletonPtr createPendulum(Joint::ActuatorType actType)
SkeletonPtr pendulum = createNLinkPendulum(1, dim, DOF_ROLL, offset);
EXPECT_NE(pendulum, nullptr);

pendulum->disableSelfCollision();
pendulum->disableSelfCollisionCheck();

for (std::size_t i = 0; i < pendulum->getNumBodyNodes(); ++i)
{
Expand Down Expand Up @@ -829,7 +829,7 @@ TEST_F(JOINTS, JOINT_COULOMB_FRICTION_AND_POSITION_LIMIT)

dynamics::SkeletonPtr pendulum = myWorld->getSkeleton("double_pendulum");
EXPECT_TRUE(pendulum != nullptr);
pendulum->disableSelfCollision();
pendulum->disableSelfCollisionCheck();

dynamics::Joint* joint0 = pendulum->getJoint("joint0");
dynamics::Joint* joint1 = pendulum->getJoint("joint1");
Expand Down

0 comments on commit 45e0e0a

Please sign in to comment.