-
Notifications
You must be signed in to change notification settings - Fork 287
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
Fix incorrect rotational motion of BallJoint and FreeJoint #518
Changes from 3 commits
f28d6e5
273376d
fbc4478
4ff70fb
c3cd476
95992d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -508,49 +508,30 @@ void FreeJoint::setAngularAcceleration( | |
|
||
//============================================================================== | ||
Eigen::Matrix6d FreeJoint::getLocalJacobianStatic( | ||
const Eigen::Vector6d& _positions) const | ||
const Eigen::Vector6d& /*positions*/) const | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wait, I take that back. Does this function imply that the Jacobian is now completely agnostic to the current position values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Previously a Jacobian of FreeJoint was dependent on joint positions like other joints but now it's only dependent on the transform from child BodyNode to the joint. Since this function is a virtual function declared in Joint so it still has positions argument. |
||
{ | ||
// Jacobian expressed in the Joint frame | ||
Eigen::Matrix6d J = Eigen::Matrix6d::Identity(); | ||
J.topLeftCorner<3,3>() = math::expMapJac(-_positions.head<3>()); | ||
|
||
// Transform the reference frame to the child BodyNode frame | ||
J.leftCols<3>() = math::AdTJacFixed(mJointP.mT_ChildBodyToJoint, | ||
J.leftCols<3>()); | ||
J.bottomRightCorner<3,3>() | ||
= mJointP.mT_ChildBodyToJoint.linear() | ||
* math::expMapRot(-_positions.head<3>()); | ||
|
||
// Note that the top right 3x3 block of J is always zero | ||
assert((J.topRightCorner<3,3>()) == Eigen::Matrix3d::Zero()); | ||
|
||
assert(!math::isNan(J)); | ||
|
||
return J; | ||
return mJacobian; | ||
} | ||
|
||
//============================================================================== | ||
Eigen::Vector6d FreeJoint::getPositionDifferencesStatic( | ||
const Eigen::Vector6d& _q2, | ||
const Eigen::Vector6d& _q1) const | ||
{ | ||
Eigen::Vector6d dq; | ||
const Eigen::Isometry3d T1 = convertToTransform(_q1); | ||
const Eigen::Isometry3d T2 = convertToTransform(_q2); | ||
|
||
const Eigen::Matrix3d Jw = getLocalJacobianStatic(_q1).topLeftCorner<3,3>(); | ||
const Eigen::Matrix3d R1T = math::expMapRot(-_q1.head<3>()); | ||
const Eigen::Matrix3d R2 = math::expMapRot( _q2.head<3>()); | ||
|
||
dq.head<3>() = Jw.inverse() * math::logMap(R1T * R2); | ||
dq.tail<3>() = _q2.tail<3>() - _q1.tail<3>(); | ||
|
||
return dq; | ||
return convertToPositions(T1.inverse() * T2); | ||
} | ||
|
||
//============================================================================== | ||
FreeJoint::FreeJoint(const Properties& _properties) | ||
: MultiDofJoint<6>(_properties), | ||
mQ(Eigen::Isometry3d::Identity()) | ||
{ | ||
mJacobian = math::getAdTMatrix(mJointP.mT_ChildBodyToJoint); | ||
mJacobianDeriv = Eigen::Matrix6d::Zero(); | ||
|
||
setProperties(_properties); | ||
updateDegreeOfFreedomNames(); | ||
} | ||
|
@@ -574,6 +555,16 @@ const std::string& FreeJoint::getStaticType() | |
return name; | ||
} | ||
|
||
//============================================================================== | ||
void FreeJoint::setTransformFromChildBodyNode(const Eigen::Isometry3d& T) | ||
{ | ||
Joint::setTransformFromChildBodyNode(T); | ||
|
||
// We update Jacobian here since the Jacobian of FreeJoint is a function of | ||
// "T" but not of joint positions. | ||
mJacobian = math::getAdTMatrix(T); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should move this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Then, I think we don't need this overriding function since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, don't we need _mandatory flag for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The motivation of the My impression with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct. I scanned all the |
||
} | ||
|
||
//============================================================================== | ||
bool FreeJoint::isCyclic(size_t _index) const | ||
{ | ||
|
@@ -584,15 +575,8 @@ bool FreeJoint::isCyclic(size_t _index) const | |
//============================================================================== | ||
void FreeJoint::integratePositions(double _dt) | ||
{ | ||
const Eigen::Vector6d& velocities = getVelocitiesStatic(); | ||
|
||
const Eigen::Isometry3d& Q = getQ(); | ||
Eigen::Isometry3d Qnext(Eigen::Isometry3d::Identity()); | ||
|
||
Qnext.linear() = Q.linear() | ||
* math::expMapRot(getLocalJacobianStatic().topLeftCorner<3,3>() | ||
* velocities.head<3>() * _dt); | ||
Qnext.translation() = Q.translation() + velocities.tail<3>() * _dt; | ||
const Eigen::Isometry3d Qnext | ||
= getQ() * convertToTransform(getVelocitiesStatic() * _dt); | ||
|
||
setPositionsStatic(convertToPositions(Qnext)); | ||
} | ||
|
@@ -628,38 +612,14 @@ void FreeJoint::updateLocalTransform() const | |
//============================================================================== | ||
void FreeJoint::updateLocalJacobian(bool) const | ||
{ | ||
mJacobian = getLocalJacobian(getPositionsStatic()); | ||
// Do nothing. Jacobian will be updated by | ||
// FreeJoint::setTransformFromChildBodyNode() instead. | ||
} | ||
|
||
//============================================================================== | ||
void FreeJoint::updateLocalJacobianTimeDeriv() const | ||
{ | ||
Eigen::Matrix<double, 6, 3> J; | ||
J.topRows<3>() = Eigen::Matrix3d::Zero(); | ||
J.bottomRows<3>() = Eigen::Matrix3d::Identity(); | ||
|
||
const Eigen::Vector6d& positions = getPositionsStatic(); | ||
const Eigen::Vector6d& velocities = getVelocitiesStatic(); | ||
Eigen::Matrix<double, 6, 3> dJ; | ||
dJ.topRows<3>() = math::expMapJacDot(positions.head<3>(), | ||
velocities.head<3>()).transpose(); | ||
dJ.bottomRows<3>() = Eigen::Matrix3d::Zero(); | ||
|
||
const Eigen::Isometry3d T = mJointP.mT_ChildBodyToJoint | ||
* math::expAngular(-positions.head<3>()); | ||
|
||
mJacobianDeriv.leftCols<3>() = | ||
math::AdTJacFixed(mJointP.mT_ChildBodyToJoint, dJ); | ||
const Eigen::Matrix<double, 6, 6>& Jacobian = getLocalJacobianStatic(); | ||
mJacobianDeriv.col(3) | ||
= -math::ad(Jacobian.leftCols<3>() * velocities.head<3>(), | ||
math::AdT(T, J.col(0))); | ||
mJacobianDeriv.col(4) | ||
= -math::ad(Jacobian.leftCols<3>() * velocities.head<3>(), | ||
math::AdT(T, J.col(1))); | ||
mJacobianDeriv.col(5) | ||
= -math::ad(Jacobian.leftCols<3>() * velocities.head<3>(), | ||
math::AdT(T, J.col(2))); | ||
assert(Eigen::Matrix6d::Zero() == mJacobianDeriv); | ||
} | ||
|
||
//============================================================================== | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here: I think this should be moved to the
updateLocalJacobian()
function and wrapped in the_mandatory
flag.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍