KinematicChain.h
Go to the documentation of this file.
00001 /* 
00002  * Copyright (c) 2013 University of Jaume-I.
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the GNU Public License v3.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.gnu.org/licenses/gpl.html
00007  * 
00008  * Contributors:
00009  *     Mario Prats
00010  *     Javier Perez
00011  */
00012 
00013 #ifndef KINEMATICCHAIN_H_
00014 #define KINEMATICCHAIN_H_
00015 
00016 #include "SimulatorConfig.h"
00017 #include <osg/MatrixTransform>
00018 #include <ros/ros.h>
00019 
00020 #include <iostream>
00021 #include <string.h>
00022 #include "BulletPhysics.h"
00023 
00024 struct MimicArm
00025 {
00026   int joint;
00027   double offset, multiplier;
00028   int sliderCrank;
00029 };
00030 
00033 class KinematicChain
00034 {
00035 public:
00036   std::vector<osg::ref_ptr<osg::Node> > link; 
00037   std::vector<double> q; 
00038   std::vector<std::pair<double, double> > limits; 
00039   std::vector<std::string> names; //Names of the joints
00040 
00041   std::vector<MimicArm> mimic; //Mimic joints info
00042   std::vector<int> jointType; //type of joints 0 fixed, 1 rotation, 2 prismatic
00043   std::vector<osg::ref_ptr<osg::MatrixTransform> > joints; 
00044   std::vector<osg::ref_ptr<osg::MatrixTransform> > zerojoints; 
00045   osg::ref_ptr<osg::MatrixTransform> baseTransform; 
00046 
00047   //osg::MatrixTransform *tool_transform;       ///< Transform between the end-effector and the tool base frame
00048   //osg::ref_ptr<osg::Node> tool;               ///< Pointer to the tool osg node
00049 
00050   std::vector<double> qLastSafe; 
00051   BulletPhysics * physics; 
00052 
00053   ros::WallTime last;
00054   int started;
00055 
00056   KinematicChain(int nlinks, int njoints);
00057 
00058   void setJointPosition(double *q, int n);
00059   void setJointVelocity(double *qdot, int n);
00060   void setJointPosition(std::vector<double> &q, std::vector<std::string> names = std::vector<std::string>());
00061   void setJointVelocity(std::vector<double> &qdot, std::vector<std::string> names = std::vector<std::string>());
00062   std::vector<double> getJointPosition();
00063   std::vector<std::string> getJointName();
00064   std::map<std::string, double> getFullJointMap();  //Builds a map: name -> jointValue with all non-fixed joints (even mimic joints)
00065 
00067   int getNumberOfLinks()
00068   {
00069     return link.size();
00070   }
00072   int getNumberOfJoints()
00073   {
00074     return q.size();
00075   }
00076 
00077   ~KinematicChain();
00078 
00079 protected:
00080   virtual void updateJoints(std::vector<double> &q)=0; 
00081 };
00082 
00083 #endif /* KINEMATICCHAIN_H_ */


uwsim
Author(s): Mario Prats , Javier Perez
autogenerated on Fri Aug 28 2015 13:28:58