KChainBodySchema.h

00001 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
00002 /* 
00003  * Copyright (C) 2008 Micha Hersch, EPFL
00004  * RobotCub Consortium, European Commission FP6 Project IST-004370
00005  * email:   micha.hersch@robotcub.org
00006  * website: www.robotcub.org
00007  * Permission is granted to copy, distribute, and/or modify this program
00008  * under the terms of the GNU General Public License, version 2 or any
00009  * later version published by the Free Software Foundation.
00010  *
00011  * A copy of the license can be found at
00012  * http://www.robotcub.org/icub/license/gpl.txt
00013  *
00014  * This program is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00017  * Public License for more details
00018  */
00019 #ifndef __K_CHAIN_BODY_SCHEMA_H__
00020 #define __K_CHAIN_BODY_SCHEMA_H__
00021 
00022 
00023 #define WITH_LAST_LINK
00024 
00025 #include "BodySchema.h"
00026 #include "KinematicChain.h"
00027 
00028 
00032 class KChainBodySchema : public BodySchema, public KinematicChain{
00033     
00034     int telescopic;
00035 
00036 public:
00037     KChainBodySchema():BodySchema(),KinematicChain(){telescopic=1;};
00038     KChainBodySchema(int teles):BodySchema(),KinematicChain(){telescopic=teles;};
00039     virtual ~KChainBodySchema(){};
00040     KChainBodySchema(char *filename):BodySchema(),KinematicChain(){BodySchema::Load(filename);};
00041     //  KChainBodySchema(const KinematicChain& chain);
00042     int GetNbJoints(){return nb_joints;}
00043     virtual void Angle2Cart(joint_vec_t& angles,cart_vec_t& pos)
00044     {SetForwardKinematics(angles.GetArray(),pos.GetArray());}
00045     void Angle2Cart(cart_vec_t& pos)
00046     {ForwardKinematics(pos.GetArray());}
00047     virtual int InverseKinematics(const cart_vec_t& pos,joint_vec_t& angles);
00048     virtual int InverseKinematics(const cart_vec_t& pos,joint_vec_t& start_angle,joint_vec_t& angles)
00049     {SetAngles(start_angle.GetArray()); return InverseKinematics(pos,angles);}
00050     virtual float TryInverseKinematics(const cart_vec_t& pos,joint_vec_t& angles);
00051     virtual void SetRandomAngle(joint_vec_t& angles)
00052     {GetRandomAngle(angles);SetAngles(angles.GetArray());}
00053     virtual void Jacobian(Matrix& jac);//jac is assumed to of the right dimension
00054     virtual void Jacobian(joint_vec_t& angles, Matrix& jac){SetAngles(angles.GetArray());Jacobian(jac);}
00055     virtual void Load(istream& in){in>>*((KinematicChain *)this);};
00056     virtual void Load(const char *filename);//{ifstream in(filename);Load(in);in.close();};  
00057     virtual void Print(ostream& out)const{out<<*((KinematicChain *)this);} 
00058     virtual void GetWeights(cart_vec_t& cart_weights, joint_vec_t& joint_weights);
00059     virtual void SetPosition(joint_vec_t& angles){SetAngles(angles.GetArray());};
00060     virtual void GetAngles(joint_vec_t& angles){KinematicChain::GetAngles(angles.GetArray());};
00061     virtual float *Serialize(float *data,int offset){return KinematicChain::Serialize(data,offset);};
00062     virtual int Deserialize(const float *data,int offset)
00063     {return KinematicChain::Deserialize(data,offset);};
00064     virtual int Deserialize(const float *data,int from,int to)
00065     {return KinematicChain::Deserialize(data,from,to);};
00066  
00067 };
00068 
00069 
00070 
00071 #endif
 All Data Structures Functions Variables

Generated on Wed Sep 22 16:51:25 2010 for Body_Schema_Learning by  doxygen 1.6.1