Skip to content

Commit

Permalink
Fix grouping of skeletons by constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Dec 18, 2021
1 parent 6f9feed commit 9637b02
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dart/constraint/BallJointConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ void BallJointConstraint::applyImpulse(double* _lambda)
dynamics::SkeletonPtr BallJointConstraint::getRootSkeleton() const
{
if (mBodyNode1->isReactive())
return mBodyNode1->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(mBodyNode1->getSkeleton());

if (mBodyNode2)
{
if (mBodyNode2->isReactive())
{
return mBodyNode2->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(mBodyNode2->getSkeleton());
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion dart/constraint/JointConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void JointConstraint::applyImpulse(double* lambda)
//==============================================================================
dynamics::SkeletonPtr JointConstraint::getRootSkeleton() const
{
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
}

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion dart/constraint/JointCoulombFrictionConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void JointCoulombFrictionConstraint::applyImpulse(double* _lambda)
//==============================================================================
dynamics::SkeletonPtr JointCoulombFrictionConstraint::getRootSkeleton() const
{
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
}

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion dart/constraint/JointLimitConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void JointLimitConstraint::applyImpulse(double* lambda)
//==============================================================================
dynamics::SkeletonPtr JointLimitConstraint::getRootSkeleton() const
{
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
}

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion dart/constraint/MimicMotorConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void MimicMotorConstraint::applyImpulse(double* lambda)
//==============================================================================
dynamics::SkeletonPtr MimicMotorConstraint::getRootSkeleton() const
{
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
}

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion dart/constraint/ServoMotorConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void ServoMotorConstraint::applyImpulse(double* lambda)
//==============================================================================
dynamics::SkeletonPtr ServoMotorConstraint::getRootSkeleton() const
{
return mJoint->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(mJoint->getSkeleton()->getSkeleton());
}

//==============================================================================
Expand Down
6 changes: 4 additions & 2 deletions dart/constraint/SoftContactConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,11 @@ double SoftContactConstraint::computeRestitutionCoefficient(
dynamics::SkeletonPtr SoftContactConstraint::getRootSkeleton() const
{
if (mSoftBodyNode1 || mBodyNode1->isReactive())
return mBodyNode1->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(
mBodyNode1->getSkeleton()->getSkeleton());
else
return mBodyNode2->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(
mBodyNode2->getSkeleton()->getSkeleton());
}

//==============================================================================
Expand Down
6 changes: 4 additions & 2 deletions dart/constraint/WeldJointConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,15 @@ void WeldJointConstraint::applyImpulse(double* _lambda)
dynamics::SkeletonPtr WeldJointConstraint::getRootSkeleton() const
{
if (mBodyNode1->isReactive())
return mBodyNode1->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(
mBodyNode1->getSkeleton()->getSkeleton());

if (mBodyNode2)
{
if (mBodyNode2->isReactive())
{
return mBodyNode2->getSkeleton()->mUnionRootSkeleton.lock();
return ConstraintBase::getRootSkeleton(
mBodyNode2->getSkeleton()->getSkeleton());
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/DegreeOfFreedomPtr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class TemplateDegreeOfFreedomPtr
TemplateBodyNodePtr<BodyNodeT> mBodyNodePtr;

/// Local index of this DegreeOfFreedom within its Joint
std::size_t mIndex;
std::size_t mIndex = 0;
};

/// TemplateWeakDegreeOfFreedomPtr is a templated class that enables users to
Expand Down
2 changes: 1 addition & 1 deletion unittests/regression/test_Issue1231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST(Issue1231, NoContacts)
dart::simulation::WorldPtr world = dart::simulation::World::create();

double x = -0.25;
for (const std::string& name : {"1", "2"})
for (const auto& name : {"1", "2"})
{
const auto skeleton = dart::dynamics::Skeleton::create(name);
skeleton->setMobile(false);
Expand Down

0 comments on commit 9637b02

Please sign in to comment.