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

Calculation of the mass of a portion of the kinematic chain #142

Merged
merged 31 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3096b94
Slide joint
rafaelxero Apr 4, 2016
f62ba87
to merge
rafaelxero Apr 4, 2016
25cb87d
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Apr 11, 2016
1bcec8f
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Apr 24, 2016
103d0eb
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero May 10, 2016
02c64e1
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero May 11, 2016
d1239c3
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero May 22, 2016
4fc0109
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero May 30, 2016
9dddc93
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Jun 21, 2016
8b90a08
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Jun 23, 2016
ab9c7ca
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Jul 6, 2016
cee4100
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Jul 7, 2016
86fc3f9
Calculation of the spatial velocity
rafaelxero Sep 15, 2016
a796c2b
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Sep 16, 2016
44d8e90
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Dec 5, 2016
8f75c0b
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Feb 17, 2017
95900f4
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Feb 20, 2017
d799599
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Mar 13, 2017
14162da
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Apr 5, 2017
6ace562
Add calcTotalMass to LinkTraverse
rafaelxero Sep 28, 2017
c80fab8
Merge branch 'master' of https://github.com/rafaelxero/openhrp3
rafaelxero Dec 5, 2017
052f8f7
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Dec 24, 2017
1d21479
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Mar 30, 2018
e6b30da
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Apr 4, 2018
204b397
Added calcJacobianDot to JointPath
rafaelxero Apr 11, 2018
1df954a
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero May 15, 2018
a583b1e
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Jul 10, 2018
a92ca41
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Jul 26, 2018
222963d
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Sep 10, 2018
7072332
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Sep 14, 2018
9e938ed
Merge branch 'master' of https://github.com/fkanehiro/openhrp3
rafaelxero Apr 11, 2019
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
16 changes: 10 additions & 6 deletions hrplib/hrpModel/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ void Body::calcInverseDynamics(Link* ptr, Vector3& out_f, Vector3& out_tau)
sw.setZero();
sv.setZero();
}

ptr->vo = parent->vo + sv * ptr->dq; // Added by Rafa
ptr->w = parent->w + sw * ptr->dq; // Added by Rafa

dsv = parent->w.cross(sv) + parent->vo.cross(sw);
dsw = parent->w.cross(sw);

Expand All @@ -458,9 +462,9 @@ void Body::calcInverseDynamics(Link* ptr, Vector3& out_f, Vector3& out_tau)
ptr->sw = sw;
ptr->sv = sv;
}
Vector3 c,P,L;
Matrix33 I,c_hat;

Vector3 c, P, L;
Matrix33 I, c_hat;

c = ptr->R * ptr->c + ptr->p;
I.noalias() = ptr->R * ptr->I * ptr->R.transpose();
Expand Down Expand Up @@ -925,9 +929,9 @@ void Body::calcCMJacobian(Link *base, dmatrix &J)
}
case Link::SLIDE_JOINT:
{
Vector3 dp((j->subm/totalMass_)*sgn[j->jointId]*j->R*j->d);
J.col(j->jointId) = dp;
break;
Vector3 dp((j->subm/totalMass_)*sgn[j->jointId]*j->R*j->d);
J.col(j->jointId) = dp;
break;
}
default:
std::cerr << "calcCMJacobian() : unsupported jointType("
Expand Down
54 changes: 53 additions & 1 deletion hrplib/hrpModel/JointPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
\file
\brief Implementations of the LinkPath class
\author Shin'ichiro Nakaoka
\author Shin'ichiro Nakaoka, Rafael Cisneros
*/

#include "JointPath.h"
Expand Down Expand Up @@ -170,6 +170,58 @@ void JointPath::calcJacobian(dmatrix& out_J, const Vector3& local_p) const
}


void JointPath::calcJacobianDot(dmatrix& out_dJ, const Vector3& local_p) const
{
const int n = joints.size();
out_dJ.resize(6, n);

if (n > 0) {

Link* targetLink = linkPath.endLink();

for (int i=0; i < n; ++i) {

Link* link = joints[i];

switch (link->jointType) {

case Link::ROTATIONAL_JOINT:
{
Vector3 omega(link->R * link->a);
Vector3 arm(targetLink->p + targetLink->R * local_p - link->p);

Vector3 omegaDot(hat(link->w) * link->R * link->a);
Vector3 armDot(targetLink->v + hat(targetLink->w) * targetLink->R * local_p - link->v);

if (!isJointDownward(i)) {
omega *= -1.0;
omegaDot *= -1.0;
}

Vector3 ddp(omegaDot.cross(arm) + omega.cross(armDot));

out_dJ.col(i) << ddp, omegaDot;
}
break;

case Link::SLIDE_JOINT:
{
Vector3 ddp(hat(link->w) * link->R * link->d);
if (!isJointDownward(i)) {
ddp *= -1.0;
}
out_dJ.col(i) << ddp, Vector3::Zero();
}
break;

default:
out_dJ.col(i).setZero();
}
}
}
}


void JointPath::setMaxIKError(double e)
{
maxIKErrorSqr = e * e;
Expand Down
4 changes: 3 additions & 1 deletion hrplib/hrpModel/JointPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/** \file
\brief The header file of the LinkPath and JointPath classes
\author Shin'ichiro Nakaoka
\author Shin'ichiro Nakaoka, Rafael Cisneros
*/

#ifndef HRPMODEL_JOINT_PATH_H_INCLUDED
Expand Down Expand Up @@ -71,6 +71,8 @@ namespace hrp {
return J;
}

void calcJacobianDot(dmatrix& out_dJ, const Vector3& local_p = Vector3::Zero()) const;

// InverseKinematics Interface
virtual void setMaxIKError(double e);
virtual void setBestEffortIKMode(bool on);
Expand Down
14 changes: 13 additions & 1 deletion hrplib/hrpModel/LinkTraverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
\file
\brief Implementations of the LinkTraverse class
\author Shin'ichiro Nakaoka
\author Shin'ichiro Nakaoka, Rafael Cisneros
*/


Expand Down Expand Up @@ -203,6 +203,18 @@ void LinkTraverse::calcForwardKinematics(bool calcVelocity, bool calcAcceleratio
}


double LinkTraverse::calcTotalMass()
{
totalMass_ = 0.0;

for(int i = 0; i < numLinks(); ++i) {
totalMass_ += links[i]->m;
}

return totalMass_;
}


std::ostream& operator<<(std::ostream& os, LinkTraverse& traverse)
{
int n = traverse.numLinks();
Expand Down
9 changes: 8 additions & 1 deletion hrplib/hrpModel/LinkTraverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
\file
\brief The header file of the LinkTraverse class
\author Shin'ichiro Nakaoka
\author Shin'ichiro Nakaoka, Rafael Cisneros
*/

#ifndef HRPMODEL_LINK_TRAVERSE_H_INCLUDED
Expand Down Expand Up @@ -80,10 +80,17 @@ namespace hrp {

void calcForwardKinematics(bool calcVelocity = false, bool calcAcceleration = false) const;

double calcTotalMass();

inline double totalMass() const {
return totalMass_;
}

protected:

std::vector<Link*> links;
int numUpwardConnections;
double totalMass_;

private:

Expand Down