grid_state.h
Go to the documentation of this file.
00001 #ifndef JSK_FOOTSTEP_PLANNER_GRID_STATE_H_
00002 #define JSK_FOOTSTEP_PLANNER_GRID_STATE_H_
00003 
00004 namespace jsk_footstep_planner {
00005   class GridState
00006   {
00007   public:
00008     typedef boost::shared_ptr<GridState> Ptr;
00009     GridState(int x, int y) : index_x_(x), index_y_(y)
00010     {
00011     }
00012     inline virtual int indexX() { return index_x_; }
00013     inline virtual int indexY() { return index_y_; }
00014 
00015     inline virtual int getOccupancy() { return 0; }
00016     inline virtual bool setOccupancy(int occ_) { return false; }
00017     inline virtual float getCost() { return 0.0; }
00018     inline virtual bool setCost(float c_) { return false; }
00019     inline virtual bool isValid() { return true; }
00020     // for boost unordered_map
00021     bool operator==(const GridState& other) const
00022     {
00023       return ((index_x_ == other.index_x_) &&
00024               (index_y_ == other.index_y_));
00025     }
00026   protected:
00027     int index_x_;
00028     int index_y_;
00029   };
00030 
00031   class OccupancyGridState : public GridState
00032   {
00033   public:
00034     typedef boost::shared_ptr<OccupancyGridState> Ptr;
00035 
00036     OccupancyGridState(int x, int y) : GridState(x, y), occupancy_(0)
00037     {
00038     }
00039 
00040     inline virtual int getOccupancy() { return occupancy_; }
00041     inline virtual bool setOccupancy(int occ_)
00042     {
00043       occupancy_ = occ_;
00044       return true;
00045     }
00046     inline virtual bool isValid()
00047     {
00048       if(occupancy_ == 0) {
00049         return true;
00050       }
00051       return false;
00052     }
00053   protected:
00054     int occupancy_;
00055   };
00056 
00057   class CostedGridState : public OccupancyGridState
00058   {
00059   public:
00060     typedef boost::shared_ptr<CostedGridState> Ptr;
00061 
00062     CostedGridState(int x, int y) : OccupancyGridState(x, y), cost_(0.0)
00063     {
00064     }
00065 
00066     inline virtual float getCost()
00067     {
00068       return cost_;
00069     }
00070     inline virtual bool setCost(float c_)
00071     {
00072       cost_ = c_;
00073       return true;
00074     }
00075     inline virtual bool isValid() {
00076       // TODO update for using cost
00077       if(occupancy_ == 0) {
00078         return true;
00079       }
00080       return false;
00081     }
00082   protected:
00083     float cost_;
00084   };
00085 
00086   // for boost unordered_map
00087   inline size_t hash_value(const GridState::Ptr& s)
00088   {
00089     return (std::abs(s->indexX() + 32000) << 16) + std::abs(s->indexY() + 32000);
00090   }
00091 }
00092 #endif


jsk_footstep_planner
Author(s): Ryohei Ueda
autogenerated on Wed Jul 19 2017 02:54:29