Mod/Robot: fix some spaces and a couple of warnings
Warnings wsa: src/Mod/Robot/App/kdl_cp/chaindynparam.cpp|105 col 5| warning: control may reach end of non-void function [-Wreturn-type] src/Mod/Robot/App/kdl_cp/chainidsolver_recursive_newton_euler.cpp|82 col 5| warning: control may reach end of non-void function [-Wreturn-type]
This commit is contained in:
parent
efb08237ac
commit
cd0ae20ef5
|
@ -26,7 +26,7 @@
|
||||||
namespace KDL {
|
namespace KDL {
|
||||||
|
|
||||||
ChainDynParam::ChainDynParam(const Chain& _chain, Vector _grav):
|
ChainDynParam::ChainDynParam(const Chain& _chain, Vector _grav):
|
||||||
chain(_chain),
|
chain(_chain),
|
||||||
grav(_grav),
|
grav(_grav),
|
||||||
chainidsolver_coriolis( chain, Vector::Zero()),
|
chainidsolver_coriolis( chain, Vector::Zero()),
|
||||||
chainidsolver_gravity( chain, grav),
|
chainidsolver_gravity( chain, grav),
|
||||||
|
@ -44,64 +44,65 @@ namespace KDL {
|
||||||
//calculate inertia matrix H
|
//calculate inertia matrix H
|
||||||
int ChainDynParam::JntToMass(const JntArray &q, JntSpaceInertiaMatrix& H)
|
int ChainDynParam::JntToMass(const JntArray &q, JntSpaceInertiaMatrix& H)
|
||||||
{
|
{
|
||||||
//Check sizes when in debug mode
|
//Check sizes when in debug mode
|
||||||
if(q.rows()!=nj || H.rows()!=nj || H.columns()!=nj )
|
if(q.rows()!=nj || H.rows()!=nj || H.columns()!=nj )
|
||||||
return -1;
|
return -1;
|
||||||
unsigned int k=0;
|
unsigned int k=0;
|
||||||
double q_;
|
double q_;
|
||||||
|
|
||||||
//Sweep from root to leaf
|
//Sweep from root to leaf
|
||||||
for(unsigned int i=0;i<ns;i++)
|
for(unsigned int i=0;i<ns;i++)
|
||||||
{
|
{
|
||||||
//Collect RigidBodyInertia
|
//Collect RigidBodyInertia
|
||||||
Ic[i]=chain.getSegment(i).getInertia();
|
Ic[i]=chain.getSegment(i).getInertia();
|
||||||
if(chain.getSegment(i).getJoint().getType()!=Joint::None)
|
if(chain.getSegment(i).getJoint().getType()!=Joint::None)
|
||||||
{
|
{
|
||||||
q_=q(k);
|
q_=q(k);
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
q_=0.0;
|
q_=0.0;
|
||||||
}
|
}
|
||||||
X[i]=chain.getSegment(i).pose(q_);//Remark this is the inverse of the frame for transformations from the parent to the current coord frame
|
X[i]=chain.getSegment(i).pose(q_);//Remark this is the inverse of the frame for transformations from the parent to the current coord frame
|
||||||
S[i]=X[i].M.Inverse(chain.getSegment(i).twist(q_,1.0));
|
S[i]=X[i].M.Inverse(chain.getSegment(i).twist(q_,1.0));
|
||||||
}
|
}
|
||||||
//Sweep from leaf to root
|
//Sweep from leaf to root
|
||||||
int j,l;
|
int j,l;
|
||||||
k=nj-1; //reset k
|
k=nj-1; //reset k
|
||||||
for(int i=ns-1;i>=0;i--)
|
for(int i=ns-1;i>=0;i--)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(i!=0)
|
|
||||||
{
|
|
||||||
//assumption that previous segment is parent
|
|
||||||
Ic[i-1]=Ic[i-1]+X[i]*Ic[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
F=Ic[i]*S[i];
|
if(i!=0)
|
||||||
if(chain.getSegment(i).getJoint().getType()!=Joint::None)
|
{
|
||||||
{
|
//assumption that previous segment is parent
|
||||||
H(k,k)=dot(S[i],F);
|
Ic[i-1]=Ic[i-1]+X[i]*Ic[i];
|
||||||
j=k; //countervariable for the joints
|
}
|
||||||
l=i; //countervariable for the segments
|
|
||||||
while(l!=0) //go from leaf to root starting at i
|
|
||||||
{
|
|
||||||
//assumption that previous segment is parent
|
|
||||||
F=X[l]*F; //calculate the unit force (cfr S) for every segment: F[l-1]=X[l]*F[l]
|
|
||||||
l--; //go down a segment
|
|
||||||
|
|
||||||
if(chain.getSegment(l).getJoint().getType()!=Joint::None) //if the joint connected to segment is not a fixed joint
|
|
||||||
{
|
|
||||||
j--;
|
|
||||||
H(k,j)=dot(F,S[l]); //here you actually match a certain not fixed joint with a segment
|
|
||||||
H(j,k)=H(k,j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
k--; //this if-loop should be repeated nj times (k=nj-1 to k=0)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
F=Ic[i]*S[i];
|
||||||
|
if(chain.getSegment(i).getJoint().getType()!=Joint::None)
|
||||||
|
{
|
||||||
|
H(k,k)=dot(S[i],F);
|
||||||
|
j=k; //countervariable for the joints
|
||||||
|
l=i; //countervariable for the segments
|
||||||
|
while(l!=0) //go from leaf to root starting at i
|
||||||
|
{
|
||||||
|
//assumption that previous segment is parent
|
||||||
|
F=X[l]*F; //calculate the unit force (cfr S) for every segment: F[l-1]=X[l]*F[l]
|
||||||
|
l--; //go down a segment
|
||||||
|
|
||||||
|
if(chain.getSegment(l).getJoint().getType()!=Joint::None) //if the joint connected to segment is not a fixed joint
|
||||||
|
{
|
||||||
|
j--;
|
||||||
|
H(k,j)=dot(F,S[l]); //here you actually match a certain not fixed joint with a segment
|
||||||
|
H(j,k)=H(k,j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
k--; //this if-loop should be repeated nj times (k=nj-1 to k=0)
|
||||||
|
}
|
||||||
|
|
||||||
|
} // for
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//calculate coriolis matrix C
|
//calculate coriolis matrix C
|
||||||
|
@ -110,10 +111,10 @@ namespace KDL {
|
||||||
//make a null matrix with the size of q_dotdot and a null wrench
|
//make a null matrix with the size of q_dotdot and a null wrench
|
||||||
SetToZero(jntarraynull);
|
SetToZero(jntarraynull);
|
||||||
|
|
||||||
|
|
||||||
//the calculation of coriolis matrix C
|
//the calculation of coriolis matrix C
|
||||||
return chainidsolver_coriolis.CartToJnt(q, q_dot, jntarraynull, wrenchnull, coriolis);
|
return chainidsolver_coriolis.CartToJnt(q, q_dot, jntarraynull, wrenchnull, coriolis);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +123,7 @@ namespace KDL {
|
||||||
{
|
{
|
||||||
|
|
||||||
//make a null matrix with the size of q_dotdot and a null wrench
|
//make a null matrix with the size of q_dotdot and a null wrench
|
||||||
|
|
||||||
SetToZero(jntarraynull);
|
SetToZero(jntarraynull);
|
||||||
//the calculation of coriolis matrix C
|
//the calculation of coriolis matrix C
|
||||||
return chainidsolver_gravity.CartToJnt(q, jntarraynull, jntarraynull, wrenchnull, gravity);
|
return chainidsolver_gravity.CartToJnt(q, jntarraynull, jntarraynull, wrenchnull, gravity);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "frames_io.hpp"
|
#include "frames_io.hpp"
|
||||||
|
|
||||||
namespace KDL{
|
namespace KDL{
|
||||||
|
|
||||||
ChainIdSolver_RNE::ChainIdSolver_RNE(const Chain& chain_,Vector grav):
|
ChainIdSolver_RNE::ChainIdSolver_RNE(const Chain& chain_,Vector grav):
|
||||||
chain(chain_),nj(chain.getNrOfJoints()),ns(chain.getNrOfSegments()),
|
chain(chain_),nj(chain.getNrOfJoints()),ns(chain.getNrOfSegments()),
|
||||||
X(ns),S(ns),v(ns),a(ns),f(ns)
|
X(ns),S(ns),v(ns),a(ns),f(ns)
|
||||||
|
@ -48,10 +48,10 @@ namespace KDL{
|
||||||
j++;
|
j++;
|
||||||
}else
|
}else
|
||||||
q_=qdot_=qdotdot_=0.0;
|
q_=qdot_=qdotdot_=0.0;
|
||||||
|
|
||||||
//Calculate segment properties: X,S,vj,cj
|
//Calculate segment properties: X,S,vj,cj
|
||||||
X[i]=chain.getSegment(i).pose(q_);//Remark this is the inverse of the
|
X[i]=chain.getSegment(i).pose(q_);//Remark this is the inverse of the
|
||||||
//frame for transformations from
|
//frame for transformations from
|
||||||
//the parent to the current coord frame
|
//the parent to the current coord frame
|
||||||
//Transform velocity and unit velocity to segment frame
|
//Transform velocity and unit velocity to segment frame
|
||||||
Twist vj=X[i].M.Inverse(chain.getSegment(i).twist(q_,qdot_));
|
Twist vj=X[i].M.Inverse(chain.getSegment(i).twist(q_,qdot_));
|
||||||
|
@ -69,7 +69,7 @@ namespace KDL{
|
||||||
//Collect RigidBodyInertia and external forces
|
//Collect RigidBodyInertia and external forces
|
||||||
RigidBodyInertia Ii=chain.getSegment(i).getInertia();
|
RigidBodyInertia Ii=chain.getSegment(i).getInertia();
|
||||||
f[i]=Ii*a[i]+v[i]*(Ii*v[i])-f_ext[i];
|
f[i]=Ii*a[i]+v[i]*(Ii*v[i])-f_ext[i];
|
||||||
//std::cout << "a[i]=" << a[i] << "\n f[i]=" << f[i] << "\n S[i]" << S[i] << std::endl;
|
//std::cout << "a[i]=" << a[i] << "\n f[i]=" << f[i] << "\n S[i]" << S[i] << std::endl;
|
||||||
}
|
}
|
||||||
//Sweep from leaf to root
|
//Sweep from leaf to root
|
||||||
j=nj-1;
|
j=nj-1;
|
||||||
|
@ -79,5 +79,6 @@ namespace KDL{
|
||||||
if(i!=0)
|
if(i!=0)
|
||||||
f[i-1]=f[i-1]+X[i]*f[i];
|
f[i-1]=f[i-1]+X[i]*f[i];
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}//namespace
|
}//namespace
|
||||||
|
|
Loading…
Reference in New Issue
Block a user