Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <kdl/chainfksolveracc_recursive.hpp>
00035
00036 namespace KDL {
00037
00038 ChainFkSolverAcc_recursive::ChainFkSolverAcc_recursive(const Chain &_chain): chain(_chain)
00039 {
00040
00041 }
00042
00043 ChainFkSolverAcc_recursive::~ChainFkSolverAcc_recursive()
00044 {
00045
00046 }
00047
00048 ChainFkSolverAcc::~ChainFkSolverAcc()
00049 {
00050 }
00051
00052
00053 int ChainFkSolverAcc_recursive::JntToCart(const JntArrayAcc &in, FrameAcc &out, int segmentNr)
00054 {
00055
00056 if(segmentNr<0)
00057 segmentNr=chain.getNrOfSegments();
00058
00059 out=FrameAcc::Identity();
00060
00061 if(!(in.q.rows()==chain.getNrOfJoints()&&in.qdot.rows()==chain.getNrOfJoints()))
00062 return -1;
00063 else if(segmentNr>chain.getNrOfSegments())
00064 return -1;
00065 else
00066 {
00067 int j=0;
00068 for (unsigned int i=0;i<segmentNr;i++)
00069 {
00070
00071 if(chain.getSegment(i).getJoint().getType()!=Joint::None){
00072 out=out*FrameAcc(chain.getSegment(i).pose(in.q(j)),
00073 chain.getSegment(i).twist(in.q(j),in.qdot(j)),
00074 SegmentGetTwistAcc(chain.getSegment(i), in.q(j), in.qdot(j), in.qdotdot(j)));
00075 j++;
00076 }else{
00077 out=out*FrameAcc(chain.getSegment(i).pose(0.0),
00078 chain.getSegment(i).twist(0.0,0.0),
00079 Twist::Zero());
00080 }
00081 }
00082 return 0;
00083 }
00084 }
00085
00086
00087 Twist ChainFkSolverAcc_recursive::SegmentGetTwistAcc(const Segment &s, const double &q,const double &qdot, const double &qdotdot) const
00088 {
00089 Twist out;
00090 Joint joint = s.getJoint();
00091 Frame f_tip = s.getFrameToTip();
00092 Twist t1 = (joint.twist(qdotdot).RefPoint(joint.pose(q).M * f_tip.p));
00093 Twist t2 = (joint.twist(qdot).RefPoint(joint.pose(q).M * f_tip.p));
00094 Twist t3 = (joint.twist(qdot).RefPoint(t2.vel));
00095
00096 out.rot = t1.rot;
00097 out.vel = t1.vel+t3.vel;
00098
00099 return out;
00100 }
00101
00102
00103 }