optimizer_goal.h
Go to the documentation of this file.
00001 
00018 #ifndef __INC_OPTIMIZER_GOAL
00019 #define __INC_OPTIMIZER_GOAL
00020 
00021 #include <vector>  
00022 #include <frame.h>
00023 #include <vecmath.h>
00024 #include <log.h>
00025 #include <utils.h>
00026 #include <datapairs.h>
00027 
00028 namespace robotLibPbD {
00029 
00030 class OptimizerGoal
00031 {
00032 protected:
00033   DataPairs information;
00034   std::string function;
00035 public:
00036   CFrame *first, *second;
00037   ~OptimizerGoal() {}
00038   void loadFromXml(CFrameContainer &frames, TiXmlElement* frameNode)
00039   {
00040     first = frames.getFrame(CConfiguration::getAttributeString(frameNode, "first", ""));
00041     second = frames.getFrame(CConfiguration::getAttributeString(frameNode, "second", ""));
00042     if (second == NULL)
00043       second = first;
00044 
00045     function = CConfiguration::getAttributeString(frameNode, "value", "");
00046   };
00047 
00048   virtual double getDistance() 
00049   {
00050     double angle;
00051     CVec axis;
00052     CMatrix pose;
00053     LOG_MSG(10, "First:\n%s", first->getRelativeToBase().toString().c_str());
00054     LOG_MSG(10, "Second:\n%s", second->getRelativeToBase().toString().c_str());
00055 
00056 
00057     pose = first->getRelativeToBase();
00058     pose.invert();
00059     pose.mul(pose, second->getRelativeToBase());
00060 
00061     //LOG_MSG(5, "Difference:\n%s", pose.toString().c_str());
00062 
00063     CMathLib::getRotationFromMatrix(pose, axis, angle);
00064     axis *= angle; 
00065 
00066     information.add("x", printToString("%f", pose.a[12]), true);
00067     information.add("y", printToString("%f", pose.a[13]), true);
00068     information.add("z", printToString("%f", pose.a[14]), true);
00069     information.add("rx", printToString("%f", axis.x), true);
00070     information.add("ry", printToString("%f", axis.y), true);
00071     information.add("rz", printToString("%f", axis.z), true);
00072 
00073     return atof(information.resolveString(function).c_str());
00074   };
00075 
00076   void getDistance(CVec &from, CVec &to)
00077   {
00078     from = first->getRelativeToBase()[3];
00079     to = second->getRelativeToBase()[3];
00080   };
00081 
00082   void getDistance(CVec &to)
00083   {
00084     CMatrix pose = first->getRelativeToBase();
00085     pose.invert();
00086     to = pose * second->getRelativeToBase()[3];
00087   };
00088 };
00089 };
00090 
00091 #endif


asr_kinematic_chain_optimizer
Author(s): Aumann Florian, Heller Florian, Jäkel Rainer, Wittenbeck Valerij
autogenerated on Sat Jun 8 2019 19:42:49