PlanningState.cpp
Go to the documentation of this file.
1 /*
2  * A footstep planner for humanoid robots
3  *
4  * Copyright 2010-2011 Johannes Garimort, Armin Hornung, University of Freiburg
5  * http://www.ros.org/wiki/footstep_planner
6  *
7  * D* Lite (Koenig et al. 2002) partly based on the implementation
8  * by J. Neufeld (http://code.google.com/p/dstarlite/)
9  *
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, version 3.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
25 
26 
27 namespace footstep_planner
28 {
29 PlanningState::PlanningState(double x, double y, double theta, Leg leg,
30  double cell_size, int num_angle_bins,
31  int max_hash_size)
32 : ivX(state_2_cell(x, cell_size)),
33  ivY(state_2_cell(y, cell_size)),
34  ivTheta(angle_state_2_cell(theta, num_angle_bins)),
35  ivLeg(leg),
36  ivId(-1),
37  ivHashTag(calc_hash_tag(ivX, ivY, ivTheta, ivLeg, max_hash_size))
38 {}
39 
40 
41 PlanningState::PlanningState(int x, int y, int theta, Leg leg,
42  int max_hash_size)
43 : ivX(x),
44  ivY(y),
45  ivTheta(theta),
46  ivLeg(leg),
47  ivId(-1),
48  ivHashTag(calc_hash_tag(ivX, ivY, ivTheta, ivLeg, max_hash_size))
49 {}
50 
51 
52 PlanningState::PlanningState(const State& s, double cell_size,
53  int num_angle_bins, int max_hash_size)
54 : ivX(state_2_cell(s.getX(), cell_size)),
55  ivY(state_2_cell(s.getY(), cell_size)),
56  ivTheta(angle_state_2_cell(s.getTheta(), num_angle_bins)),
57  ivLeg(s.getLeg()),
58  ivId(-1),
59  ivHashTag(calc_hash_tag(ivX, ivY, ivTheta, ivLeg, max_hash_size))
60 {}
61 
62 
64 : ivX(s.getX()),
65  ivY(s.getY()),
66  ivTheta(s.getTheta()),
67  ivLeg(s.getLeg()),
68  ivId(s.getId()),
70 {}
71 
72 
74 {}
75 
76 
77 bool
79 const
80 {
81  // First test the hash tag. If they differ, the states are definitely
82  // different.
83  if (ivHashTag != s2.getHashTag())
84  return false;
85 
86  return (ivX == s2.getX() && ivY == s2.getY() &&
87  ivTheta == s2.getTheta() && ivLeg == s2.getLeg());
88 }
89 
90 
91 bool
93 const
94 {
95  return ivHashTag != s2.getHashTag();
96 }
97 
98 
99 State
100 PlanningState::getState(double cell_size, int num_angle_bins)
101 const
102 {
103  return State(cell_2_state(ivX, cell_size),
104  cell_2_state(ivY, cell_size),
106  angle_cell_2_state(ivTheta, num_angle_bins)),
107  ivLeg);
108 }
109 } // end of namespace
double cell_2_state(int value, double cell_size)
Calculate the respective (continuous) state value for a cell. (Should be used to get a State from a d...
Definition: helper.h:122
State getState(double cell_size, int num_angle_bins) const
Computes the continuous State the PlanningState represents.
bool operator!=(const PlanningState &s2) const
Compare two states on inequality of x, y, theta, leg by comparing the hash tags of the states...
A class representing the robot&#39;s pose (i.e. position and orientation) in the (continuous) world view...
Definition: State.h:34
PlanningState(double x, double y, double theta, Leg leg, double cell_size, int num_angle_bins, int max_hash_size)
x, y and theta represent the global (continuous) position and orientation of the robot&#39;s support leg...
double angle_cell_2_state(int angle, int angle_bin_num)
Calculate the respective (continuous) angle for a bin.
Definition: helper.h:101
def normalize_angle(angle)
int ivX
Value of the grid cell the position&#39;s x value is fitted into.
Leg ivLeg
The supporting leg.
int ivTheta
Number of the bin the orientation is fitted into.
int ivY
Value of the grid cell the position&#39;s y value is fitted into.
int state_2_cell(float value, float cell_size)
Discretize a (continuous) state value into a cell. (Should be used to discretize a State to a Plannin...
Definition: helper.h:112
int angle_state_2_cell(double angle, int angle_bin_num)
Discretize a (continuous) angle into a bin.
Definition: helper.h:92
int ivId
The (unique) ID of the planning state.
unsigned int getHashTag() const
unsigned int calc_hash_tag(int x, int y, int theta, int leg, int max_hash_size)
Definition: helper.h:166
A class representing the robot&#39;s pose (i.e. position and orientation) in the underlying SBPL...
Definition: PlanningState.h:45
bool operator==(const PlanningState &s2) const
Compare two states on equality of x, y, theta, leg. Makes first use of the non-unique hash tag to rul...


footstep_planner
Author(s): Johannes Garimort, Armin Hornung
autogenerated on Mon Jun 10 2019 13:38:24