00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <vigir_footstep_planning_lib/modeling/planning_state.h>
00028
00029
00030
00031 namespace vigir_footstep_planning
00032 {
00033 PlanningState::PlanningState(double x, double y, double z, double roll, double pitch, double yaw,
00034 Leg leg, double cell_size, double angle_bin_size, int max_hash_size, const PlanningState *pred_state, const PlanningState *succ_state)
00035 : ivState(State(x, y, z, roll, pitch, yaw, leg))
00036 , ivX(state_2_cell(x, cell_size))
00037 , ivY(state_2_cell(y, cell_size))
00038 , ivYaw(angle_state_2_cell(yaw, angle_bin_size))
00039 , ivpPredState(pred_state)
00040 , ivpSuccState(succ_state)
00041 , ivId(-1)
00042 {
00043 unsigned int hash_pred = pred_state ? pred_state->getHashTag() : 0u;
00044 unsigned int hash_succ = succ_state ? succ_state->getHashTag() : 0u;
00045 ivHashTag = calc_hash_tag(ivX, ivY, ivYaw, leg, hash_pred, hash_succ, max_hash_size);
00046 }
00047
00048
00049 PlanningState::PlanningState(int x, int y, double z, double roll, double pitch, int yaw,
00050 Leg leg, double cell_size, double angle_bin_size, int max_hash_size, const PlanningState *pred_state, const PlanningState *succ_state)
00051 : ivState(State(cell_2_state(x, cell_size), cell_2_state(y, cell_size), z, roll, pitch, angles::normalize_angle(angle_cell_2_state(yaw, angle_bin_size)), leg))
00052 , ivX(x)
00053 , ivY(y)
00054 , ivYaw(yaw)
00055 , ivpPredState(pred_state)
00056 , ivpSuccState(succ_state)
00057 , ivId(-1)
00058 {
00059 unsigned int hash_pred = pred_state ? pred_state->getHashTag() : 0u;
00060 unsigned int hash_succ = succ_state ? succ_state->getHashTag() : 0u;
00061 ivHashTag = calc_hash_tag(ivX, ivY, ivYaw, leg, hash_pred, hash_succ, max_hash_size);
00062 }
00063
00064 PlanningState::PlanningState(const geometry_msgs::Pose& pose,
00065 Leg leg, double cell_size, double angle_bin_size, int max_hash_size, const PlanningState *pred_state, const PlanningState *succ_state)
00066 : ivState(State(pose, leg))
00067 , ivX(state_2_cell(pose.position.x, cell_size))
00068 , ivY(state_2_cell(pose.position.y, cell_size))
00069 , ivpPredState(pred_state)
00070 , ivpSuccState(succ_state)
00071 , ivId(-1)
00072 {
00073 ivYaw = angle_state_2_cell(ivState.getYaw(), angle_bin_size);
00074
00075 unsigned int hash_pred = pred_state ? pred_state->getHashTag() : 0u;
00076 unsigned int hash_succ = succ_state ? succ_state->getHashTag() : 0u;
00077 ivHashTag = calc_hash_tag(ivX, ivY, ivYaw, leg, hash_pred, hash_succ, max_hash_size);
00078 }
00079
00080 PlanningState::PlanningState(const State& s, double cell_size, double angle_bin_size, int max_hash_size, const PlanningState *pred_state, const PlanningState *succ_state)
00081 : ivState(s)
00082 , ivX(state_2_cell(s.getX(), cell_size))
00083 , ivY(state_2_cell(s.getY(), cell_size))
00084 , ivYaw(angle_state_2_cell(s.getYaw(), angle_bin_size))
00085 , ivpPredState(pred_state)
00086 , ivpSuccState(succ_state)
00087 , ivId(-1)
00088 {
00089 unsigned int hash_pred = pred_state ? pred_state->getHashTag() : 0u;
00090 unsigned int hash_succ = succ_state ? succ_state->getHashTag() : 0u;
00091 ivHashTag = calc_hash_tag(ivX, ivY, ivYaw, s.getLeg(), hash_pred, hash_succ, max_hash_size);
00092 }
00093
00094 PlanningState::PlanningState(const PlanningState& s)
00095 : ivState(s.getState())
00096 , ivX(s.getX())
00097 , ivY(s.getY())
00098 , ivYaw(s.getYaw())
00099 , ivpPredState(s.getPredState())
00100 , ivpSuccState(s.getSuccState())
00101 , ivId(s.getId())
00102 , ivHashTag(s.getHashTag())
00103 {}
00104
00105 PlanningState::~PlanningState()
00106 {}
00107
00108 bool PlanningState::operator==(const PlanningState& s2) const
00109 {
00110
00111
00112 if (ivHashTag != s2.getHashTag())
00113 return false;
00114
00116 if (ivpPredState != s2.ivpPredState)
00117 return false;
00118
00119 if (ivpSuccState != s2.ivpSuccState)
00120 return false;
00121
00122
00123
00124 return (ivX == s2.getX() && ivY == s2.getY() && ivYaw == s2.getYaw() &&
00125 ivState.getLeg() == s2.ivState.getLeg());
00126 }
00127
00128 bool PlanningState::operator!=(const PlanningState& s2) const
00129 {
00130 return !operator==(s2);
00131 }
00132
00133 const State& PlanningState::getState() const
00134 {
00135 return ivState;
00136 }
00137
00138 State& PlanningState::getState()
00139 {
00140 return ivState;
00141 }
00142 }