Algorithm.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef __ALGORITHM_H__
00004 #define __ALGORITHM_H__
00005 
00006 #include <map>
00007 #include <vector>
00008 #include <iostream>
00009 
00010 #include "Configuration.h"
00011 #include "Roadmap.h"
00012 
00013 namespace PathEngine {
00014     class PathPlanner;
00015 
00023     class Algorithm {
00024     protected:
00030         Configuration start_;
00031 
00037         Configuration goal_;
00038 
00044         std::map<std::string, std::string> properties_;
00045 
00051         bool isRunning_;
00052 
00058         std::vector<Configuration> path_;
00059 
00066         PathPlanner* planner_;
00067 
00071         RoadmapPtr roadmap_;
00072 
00076         bool verbose_;
00077 
00081         bool ignoreCollisionAtStart_;
00082 
00086         bool ignoreCollisionAtGoal_;
00087 
00088     public:
00093         Algorithm(PathPlanner* planner);
00094 
00098         virtual ~Algorithm();
00099 
00100         void setProperty(const std::string& key, const std::string& value); 
00101 
00106         void setProperties(const std::map<std::string, std::string> &properties);
00107 
00113         void getProperties(std::vector<std::string> &names,
00114                            std::vector<std::string> &values);
00115 
00120         void setStartConfiguration(const Configuration &pos) {start_ = pos;}
00121 
00126         void setGoalConfiguration(const Configuration &pos) {goal_ = pos;}
00127 
00132         bool tryDirectConnection();
00133 
00142         virtual bool calcPath() = 0;
00143 
00147         void stopPlanning(){isRunning_ = false;}
00148 
00153         const std::vector<Configuration>& getPath() {return path_;}
00154 
00159         RoadmapPtr getRoadmap() { return roadmap_; } 
00160 
00165         bool preparePlanning();
00166 
00171         void verbose(bool b) { verbose_ = b; }
00172 
00176         void ignoreCollisionAtGoal(bool b) { ignoreCollisionAtGoal_ = b; }
00177 
00181         void ignoreCollisionAtStart(bool b) { ignoreCollisionAtStart_ = b; }
00182     };
00183 
00187     typedef Algorithm* (*AlgorithmNewFunc)(PathPlanner* planner);
00188 
00192     typedef void (*AlgorithmDeleteFunc)(Algorithm* algorithm);
00193 
00194     template <class _New>
00195     Algorithm* AlgorithmCreate(PathPlanner* planner) {
00196         return new _New(planner);
00197     }
00198 
00199     template <class _Delete>
00200     void AlgorithmDelete(Algorithm* algorithm) {
00201         delete algorithm;
00202     }
00203 };
00204 
00205 #endif // __ALGORITHM_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:15