Skip to content

Commit

Permalink
Adding ERP and CFM override for 6 DOF joints. Adding a flag to indica…
Browse files Browse the repository at this point in the history
…te override
  • Loading branch information
adnanmunawar committed Jul 8, 2024
1 parent fd5520b commit 32a7b38
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions adf_loader/version_1_0/adf_loader_1_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1927,10 +1927,12 @@ bool ADFLoader_1_0::loadJointAttribs(YAML::Node *a_node, afJointAttributes *attr
}

if(erpNode.IsDefined()){
attribs->m_override_erp = true;
attribs->m_erp = erpNode.as<double>();
}

if(cfmNode.IsDefined()){
attribs->m_override_cfm = true;
attribs->m_cfm = cfmNode.as<double>();
}

Expand Down
4 changes: 4 additions & 0 deletions ambf_framework/afAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ struct afJointAttributes: public afBaseObjectAttributes
m_equilibriumPoint = 0.0;
m_ignoreInterCollision = true;
m_erp = 0.1;
m_override_erp = false;
m_cfm = 0.1;
m_override_cfm = false;
}

struct afConeTwistLimits{
Expand Down Expand Up @@ -709,7 +711,9 @@ struct afJointAttributes: public afBaseObjectAttributes
afSixDofLimits m_sixDofLimits;
afSixDofSpringAttribs m_sixDofSpringAttribs;
double m_erp;
bool m_override_erp;
double m_cfm;
bool m_override_cfm;
// Rotational offset of joint along the free joint axis
double m_jointOffset;
// Rotation offset of child along the free joint axis
Expand Down
5 changes: 5 additions & 0 deletions ambf_framework/afFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3484,6 +3484,9 @@ bool afJoint::createFromAttribs(afJointAttributes *a_attribs)
// The rotational limits are inverted in Bullet
m_sixDof->setLimit(id, -a_attribs->m_sixDofLimits.m_upperLimit[id], -a_attribs->m_sixDofLimits.m_lowerLimit[id]);
}
for (int id = 0 ; id < 6 ; id++){
if (a_attribs->m_override_cfm) m_sixDof->setParam(BT_CONSTRAINT_CFM, a_attribs->m_cfm, id);
}

m_btConstraint = m_sixDof;

Expand All @@ -3504,6 +3507,8 @@ bool afJoint::createFromAttribs(afJointAttributes *a_attribs)
m_sixDofSpring->setDamping(id, a_attribs->m_sixDofSpringAttribs.m_damping[id]);
m_sixDofSpring->setStiffness(id, a_attribs->m_sixDofSpringAttribs.m_stiffness[id]);
m_sixDofSpring->enableSpring(id, true);
if (a_attribs->m_override_erp) m_sixDofSpring->setParam(BT_CONSTRAINT_ERP, a_attribs->m_erp, id);
if (a_attribs->m_override_cfm) m_sixDofSpring->setParam(BT_CONSTRAINT_CFM, a_attribs->m_cfm, id);
}

m_btConstraint = m_sixDofSpring;
Expand Down

0 comments on commit 32a7b38

Please sign in to comment.