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 #include "LocateAlgorithm.h"
00024 #include "XMLTag.h"
00025
00026 #include <pluginlib/class_loader.h>
00027
00028
00029
00030
00031 #include <time.h>
00032 #define TRACKING_POSSIBLE_MS 2
00033
00034 using namespace cop;
00035
00036
00037
00038 pluginlib::ClassLoader<LocateAlgorithm> s_localg_loader("cognitive_perception", "LocateAlgorithm");
00039
00040 LocateAlgorithm* LocateAlgorithm::LocAlgFactory(XMLTag* tag)
00041 {
00042 std::string name = tag->GetName();
00043 LocateAlgorithm* alg = NULL;
00044 try
00045 {
00046 alg = s_localg_loader.createClassInstance(name);
00047 if(alg != NULL)
00048 alg->SetData(tag);
00049 }
00050 catch(pluginlib::PluginlibException& ex)
00051 {
00052
00053 ROS_WARN("LocateAlgorithm: The plugin failed to load for some reason. Error: %s\n", ex.what());
00054 ROS_WARN("LocateAlgorithm: Tag failed: %s\n", tag->GetName().c_str());
00055 }
00056 return alg;
00057 }
00058
00059
00060 bool LocateAlgorithm::TrackingPossible(const Reading& img, const Signature& sig, RelPose* pose)
00061 {
00062 unsigned long l = (unsigned long)time(NULL);
00063 l -= sig.date();
00064 #ifdef _DEBUG
00065 printf("TrackingPossible? Last Match diff: %ld\n", l);
00066 #endif
00067 const RelPose* old_pose = sig.GetObjectPose();
00068 if(old_pose != NULL)
00069 {
00070 RelPose* copy = RelPoseFactory::FRelPose(old_pose->m_uniqueID);
00071 if(l > 0 && l < TRACKING_POSSIBLE_MS && pose != NULL && copy != NULL)
00072 {
00073 Matrix m = copy->GetCovarianceMatrix(0);
00074
00075 #ifdef _DEBUG
00076 printf("Check 3 Cov Values of %ld: %f < 0.1; %f < 0.1;%f < 0.1;\n", old_pose->m_uniqueID, m.data()[0],m.data()[7], m.data()[14]);
00077 #endif
00078 return m.data()[0] < 0.1 && m.data()[7] < 0.1 && m.data()[14] < 0.1;
00079 }
00080 RelPoseFactory::FreeRelPose(©);
00081 }
00082 return false;
00083
00084 }
00085
00086
00087
00088
00089
00090