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     class Algorithm;
00016 
00020     typedef Algorithm* (*AlgorithmNewFunc)(PathPlanner* planner);
00021 
00025     typedef void (*AlgorithmDeleteFunc)(Algorithm* algorithm);
00026 
00027     template <class _New>
00028     Algorithm* AlgorithmCreate(PathPlanner* planner) {
00029         return new _New(planner);
00030     }
00031 
00032     template <class _Delete>
00033     void AlgorithmDelete(Algorithm* algorithm) {
00034         delete algorithm;
00035     }
00036 
00044     class Algorithm {
00045     protected:
00051         Configuration start_;
00052 
00058         Configuration goal_;
00059 
00065         std::map<std::string, std::string> properties_;
00066 
00072         bool isRunning_;
00073 
00079         std::vector<Configuration> path_;
00080 
00087         PathPlanner* planner_;
00088 
00092         RoadmapPtr roadmap_;
00093 
00097         bool verbose_;
00098 
00102         bool ignoreCollisionAtStart_;
00103 
00107         bool ignoreCollisionAtGoal_;
00108 
00109     public:
00114         Algorithm(PathPlanner* planner);
00115 
00119         virtual ~Algorithm();
00120 
00121         void setProperty(const std::string& key, const std::string& value); 
00122 
00127         void setProperties(const std::map<std::string, std::string> &properties);
00128 
00134         void getProperties(std::vector<std::string> &names,
00135                            std::vector<std::string> &values);
00136 
00141         void setStartConfiguration(const Configuration &pos) {start_ = pos;}
00142 
00147         void setGoalConfiguration(const Configuration &pos) {goal_ = pos;}
00148 
00153         bool tryDirectConnection();
00154 
00163         virtual bool calcPath() = 0;
00164 
00168         void stopPlanning(){isRunning_ = false;}
00169 
00174         const std::vector<Configuration>& getPath() {return path_;}
00175 
00180         RoadmapPtr getRoadmap() { return roadmap_; } 
00181 
00186         bool preparePlanning();
00187 
00192         void verbose(bool b) { verbose_ = b; }
00193 
00197         void ignoreCollisionAtGoal(bool b) { ignoreCollisionAtGoal_ = b; }
00198 
00202         void ignoreCollisionAtStart(bool b) { ignoreCollisionAtStart_ = b; }
00203     };
00204 };
00205 
00206 #endif // __ALGORITHM_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:52