pnf/Flow.hpp

Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2004
00003  * Swiss Federal Institute of Technology, Lausanne. All rights reserved.
00004  * 
00005  * Author: Roland Philippsen <roland dot philippsen at gmx net>
00006  *         Autonomous Systems Lab <http://asl.epfl.ch/>
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  * 
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021  * USA
00022  */
00023 
00024 
00025 #ifndef PNF_FLOW_HPP
00026 #define PNF_FLOW_HPP
00027 
00028 
00029 #include <estar/util.hpp>
00030 #include <boost/shared_ptr.hpp>
00031 #include <boost/scoped_ptr.hpp>
00032 #include <map>
00033 #include <vector>
00034 
00035 
00036 namespace estar {
00037   class Facade;
00038   class RiskMap;
00039   class Sprite;
00040   class Region;
00041   class Grid;
00042 }
00043 
00044 
00045 namespace local {
00046   class Object;
00047   class Robot;
00048 }
00049 
00050 
00051 namespace pnf {
00052   
00053   
00054   class BufferZone;
00055   
00056 
00060   class Flow
00061   {
00062   private:
00063     Flow(ssize_t xsize, ssize_t ysize, double resolution,
00064          bool perform_convolution, bool alternate_worst_case);
00065     
00066     
00067   public:
00068     typedef std::pair<const estar::array<double> *, double> array_info_t;
00069     
00070     const ssize_t xsize, ysize;
00071     const double resolution;
00072     const double half_diagonal;
00073     const bool perform_convolution;
00074     const bool alternate_worst_case; // just for (hacked) trials...
00075     
00076     static Flow * Create(ssize_t xsize, ssize_t ysize, double resolution,
00077                          bool perform_convolution, bool alternate_worst_case);
00078     ~Flow();
00079     
00080     bool HaveEnvdist() const;
00081     void PropagateEnvdist(bool step);
00082     
00083     void MapEnvdist();
00084     
00085     bool HaveObjdist(size_t id) const;
00086     void PropagateObjdist(size_t id);
00087     bool HaveAllObjdist() const;
00088     void PropagateAllObjdist();
00089     bool HaveRobdist() const;
00090     void PropagateRobdist();
00091     
00100     void ComputeAllCooc(double static_buffer_factor,
00101                         double static_buffer_degree);
00102     void ComputeRisk(const estar::RiskMap & risk_map);
00103     
00104     bool HavePNF() const;
00105     void PropagatePNF();
00106     
00107     void AddStaticObject(ssize_t ix, ssize_t iy);
00108     void RemoveStaticObject(ssize_t ix, ssize_t iy);
00109     void RemoveDynamicObject(size_t id);
00110     
00111     bool AddStaticObject(double x, double y);
00112     bool RemoveStaticObject(double x, double y);
00113     bool SetDynamicObject(size_t id, double x, double y, double r, double v);
00114     bool SetRobot(double x, double y,double r,  double v);
00115     bool SetGoal(double x, double y, double r);
00116     
00117     void DumpEnvdist(FILE * stream) const;
00118     void DumpRobdist(FILE * stream) const;
00119     void DumpObjdist(size_t id, FILE * stream) const;
00120     void DumpObjCooc(size_t id, FILE * stream) const;
00121     void DumpRisk(FILE * stream) const;
00122     void DumpPNF(FILE * stream) const;
00123     
00125     const estar::Facade * GetObjdist(size_t id) const
00126     { return GetObjdist(id, 0); }
00127     
00129     const estar::Region * GetRegion(size_t id) const;
00130     
00132     const estar::Region * GetGoal() const { return m_goal.get(); }
00133     
00135     const estar::Region * GetRobot() const;
00136     
00138     const estar::Facade * GetRobdist() const;
00139     
00141     estar::Facade & GetEnvdist() { return * m_envdist; }
00142       
00144     boost::shared_ptr<estar::Grid const> GetEnvdistGrid() const;
00145       
00146     const estar::Facade & GetPNF()     const { return * m_pnf; }
00147     
00150     array_info_t GetRobotLambda() const;
00151     
00155     array_info_t GetObjectLambda(size_t id) const;
00156     
00160     array_info_t GetEnvCooc() const;
00161     
00165     array_info_t GetObjCooc(size_t id) const;
00166     
00169     array_info_t GetDynamicCooc() const;
00170     
00174     array_info_t GetRisk() const;
00175     
00176     
00177   private:
00178     typedef std::map<size_t, boost::shared_ptr<local::Object> > objectmap_t;
00179     
00180     boost::scoped_ptr<estar::Facade>  m_envdist;
00181     boost::scoped_ptr<local::Robot>   m_robot;
00182     objectmap_t                       m_object;
00183     boost::scoped_ptr<estar::Facade>  m_pnf;
00184     boost::scoped_ptr<estar::Region>  m_goal;
00185     
00186     boost::scoped_ptr<estar::array<double> > m_env_cooc;
00187     double m_max_env_cooc;
00188     boost::scoped_ptr<estar::array<double> > m_dynamic_cooc;
00189     double m_max_dynamic_cooc;
00190     boost::scoped_ptr<estar::array<double> > m_risk;
00191     double m_max_risk;
00192     
00193     bool CompIndices(double x, double y, ssize_t & ix, ssize_t & iy) const;
00194     estar::Facade * GetObjdist(size_t id, FILE * verbose_stream) const;
00195 
00196     bool DoSetRobot(double x, double y, ssize_t ix, ssize_t iy,
00197                     double r, double v);
00198     void DoComputeLambda(local::Robot & obj);
00199     void DoComputeCooc(local::Object & obj);
00200   };
00201   
00202 }
00203 
00204 #endif // PNF_FLOW_HPP

doxygen SourceForge.net Logo
E* Interpolated Graph Replanner Wed Dec 12 18:55:40 2007