Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef ROBOT_H_
00009 #define ROBOT_H_
00010
00011
00012
00013 #include <cstdio>
00014 #include <iostream>
00015 #include <kdl/tree.hpp>
00016 #include <kdl/chain.hpp>
00017
00018 #include <kdl/chainfksolverpos_recursive.hpp>
00019 #include <kdl/chainjnttojacsolver.hpp>
00020
00021 #include <Eigen/Core>
00022
00023 #include "nasa_common_logging/Logger.h"
00024 #include <stdexcept>
00025
00026 class Robot
00027 {
00028 public:
00029 struct JointData
00030 {
00031 double curPosition;
00032 double curVelocity;
00033 double curTorque;
00034 };
00035
00036
00037 struct JointTraits
00038 {
00039 std::string name;
00040 std::string type;
00041 double maxPosition;
00042 double minPosition;
00043 double maxVelocity;
00044 double maxTorque;
00045 double springConstant;
00046 };
00047
00048 typedef std::vector<JointTraits> JointTraitsVector;
00049 typedef std::map<std::string, JointData*> JointDataMap;
00050 typedef std::map<std::string, JointTraits*> JointTraitsMap;
00051 typedef std::map<std::string, KDL::Frame> FrameMap;
00052
00053 Robot();
00054 virtual ~Robot();
00055
00056 KDL::Chain getChain(const std::string& fromSegment, const std::string& toSegment, KDL::Chain& chain);
00057 KDL::Chain getChainToRoot(const std::string& fromSegment, KDL::Chain& chain);
00058 KDL::Chain getChainFromRoot(const std::string& toSegment, KDL::Chain& chain);
00059 static KDL::Chain getChainInReverse(const KDL::Chain& inChain, KDL::Chain& retChain);
00060
00061 double getMass();
00062 KDL::Vector getCenterOfMass();
00063
00064 JointTraits* addJoint(const std::string& jointName);
00065 JointTraits* getJointTraits(const std::string& segmentName);
00066 JointTraitsVector getJointTraits();
00067
00068 JointData* getJointData(const std::string& segmentName);
00069
00070 void zeroJoints();
00071 void setJointLimits(const std::string& segmentName, double min, double max);
00072
00073 void setJointPosition(const std::string& segmentName, double position);
00074 double getJointPosition(const std::string& segmentName);
00075
00076 void setJointVelocity(const std::string& segmentName, double velocity);
00077 double getJointVelocity(const std::string& segmentName);
00078
00079 void setJointTorque(const std::string& segmentName, double velocity);
00080 double getJointTorque(const std::string& segmentName);
00081
00082 KDL::JntArray getChainJointPositions(const KDL::Chain& chain);
00083 KDL::JntArray getChainJointVelocities(const KDL::Chain& chain);
00084
00085 KDL::Frame getChainTransformBaseToTip(const std::string& segmentName);
00086 KDL::Frame getChainTransformTipToBase(const std::string& segmentName);
00087 KDL::Frame getStaticTransform(const std::string& transformName);
00088 void setStaticTransform(const std::string& transformName, const KDL::Frame& transform);
00089
00090
00091
00092 KDL::Frame getChainTransform(const KDL::Chain& chain);
00093
00094 static KDL::Frame getChainTransform(const KDL::Chain& chain, const KDL::JntArray& pos);
00095
00096 static void getChainJacobian(const KDL::Chain& chain, const KDL::JntArray& positions, KDL::Jacobian& jacobian);
00097
00098 static void printChain(const KDL::Chain& chain);
00099 static std::string segmentToString(const KDL::Segment& segment);
00100 static std::string vectorToString(const KDL::Vector& vector);
00101 static std::string rotationToString(const KDL::Rotation& rotation);
00102 static std::string rotationToRpyString(const KDL::Rotation& rotation);
00103 static std::string frameToString(const KDL::Frame& frame);
00104 static std::string rigidBodyInertiaToString(const KDL::RigidBodyInertia& rbi);
00105 static std::string jacobianToString(KDL::Jacobian& jacobian);
00106
00107 KDL::Tree robotTree;
00108
00109 protected:
00110 JointDataMap jointDataMap;
00111 JointTraitsMap jointTraitsMap;
00112
00113 FrameMap staticTransforms;
00114 };
00115
00116 #endif