grid_state.h
Go to the documentation of this file.
1 #ifndef JSK_FOOTSTEP_PLANNER_GRID_STATE_H_
2 #define JSK_FOOTSTEP_PLANNER_GRID_STATE_H_
3 
4 namespace jsk_footstep_planner {
5  class GridState
6  {
7  public:
9  GridState(int x, int y) : index_x_(x), index_y_(y)
10  {
11  }
12  inline virtual int indexX() { return index_x_; }
13  inline virtual int indexY() { return index_y_; }
14 
15  inline virtual int getOccupancy() { return 0; }
16  inline virtual bool setOccupancy(int occ_) { return false; }
17  inline virtual float getCost() { return 0.0; }
18  inline virtual bool setCost(float c_) { return false; }
19  inline virtual bool isValid() { return true; }
20  // for boost unordered_map
21  bool operator==(const GridState& other) const
22  {
23  return ((index_x_ == other.index_x_) &&
24  (index_y_ == other.index_y_));
25  }
26  protected:
27  int index_x_;
28  int index_y_;
29  };
30 
32  {
33  public:
35 
36  OccupancyGridState(int x, int y) : GridState(x, y), occupancy_(0)
37  {
38  }
39 
40  inline virtual int getOccupancy() { return occupancy_; }
41  inline virtual bool setOccupancy(int occ_)
42  {
43  occupancy_ = occ_;
44  return true;
45  }
46  inline virtual bool isValid()
47  {
48  if(occupancy_ == 0) {
49  return true;
50  }
51  return false;
52  }
53  protected:
55  };
56 
58  {
59  public:
61 
62  CostedGridState(int x, int y) : OccupancyGridState(x, y), cost_(0.0)
63  {
64  }
65 
66  inline virtual float getCost()
67  {
68  return cost_;
69  }
70  inline virtual bool setCost(float c_)
71  {
72  cost_ = c_;
73  return true;
74  }
75  inline virtual bool isValid() {
76  // TODO update for using cost
77  if(occupancy_ == 0) {
78  return true;
79  }
80  return false;
81  }
82  protected:
83  float cost_;
84  };
85 
86  // for boost unordered_map
87  inline size_t hash_value(const GridState::Ptr& s)
88  {
89  return (std::abs(s->indexX() + 32000) << 16) + std::abs(s->indexY() + 32000);
90  }
91 }
92 #endif
virtual bool setCost(float c_)
Definition: grid_state.h:70
boost::shared_ptr< GridState > Ptr
Definition: grid_state.h:8
virtual bool setOccupancy(int occ_)
Definition: grid_state.h:16
bool operator==(const GridState &other) const
Definition: grid_state.h:21
virtual bool setOccupancy(int occ_)
Definition: grid_state.h:41
boost::shared_ptr< OccupancyGridState > Ptr
Definition: grid_state.h:34
boost::shared_ptr< CostedGridState > Ptr
Definition: grid_state.h:60
virtual bool setCost(float c_)
Definition: grid_state.h:18
size_t hash_value(const FootstepState::Ptr &s)


jsk_footstep_planner
Author(s): Ryohei Ueda
autogenerated on Sun May 28 2023 03:03:19