Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetJointTransmittedWrench feature #283

Merged
merged 3 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions dartsim/src/JointFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,33 @@ Identity JointFeatures::AttachPrismaticJoint(
return this->GenerateIdentity(jointID, this->joints.at(jointID));
}

/////////////////////////////////////////////////
Wrench3d JointFeatures::GetJointTransmittedWrenchInJointFrame(
const Identity &_id) const
{
auto &joint = this->ReferenceInterface<JointInfo>(_id)->joint;
auto *childBn = joint->getChildBodyNode();
if (nullptr == childBn)
{
ignerr
<< "Joint [" << joint->getName()
<< "] does not have a child link. Unable to get transmitted wrench.\n";
return {};
}

const Eigen::Vector6d transmittedWrenchInBody = childBn->getBodyForce();
// C - Child body frame
// J - Joint frame
// X_CJ - Pose of joint in child body frame
const Eigen::Isometry3d X_CJ = joint->getTransformFromChildBodyNode();

const Eigen::Vector6d transmittedWrenchInJoint =
dart::math::dAdT(X_CJ, transmittedWrenchInBody);
Wrench3d wrenchOut;
wrenchOut.torque = transmittedWrenchInJoint.head<3>();
wrenchOut.force = transmittedWrenchInJoint.tail<3>();
return wrenchOut;
}
}
}
}
7 changes: 6 additions & 1 deletion dartsim/src/JointFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ struct JointFeatureList : FeatureList<
SetJointVelocityCommandFeature,
SetJointPositionLimitsFeature,
SetJointVelocityLimitsFeature,
SetJointEffortLimitsFeature
SetJointEffortLimitsFeature,
GetJointTransmittedWrench
> { };

class JointFeatures :
Expand Down Expand Up @@ -198,6 +199,10 @@ class JointFeatures :
public: void SetJointMaxEffort(
const Identity &_id, const std::size_t _dof,
const double _value) override;

// ----- Transmitted wrench -----
public: Wrench3d GetJointTransmittedWrenchInJointFrame(
const Identity &_id) const override;
};

}
Expand Down
Loading