28 : DiscreteSpaceInformation(),
30 ivIdStartFootLeft(-1),
31 ivIdStartFootRight(-1),
33 ivIdGoalFootRight(-1),
36 ivFootstepSet(params.footstep_set),
37 ivHeuristicConstPtr(params.heuristic),
38 ivFootsizeX(params.footsize_x),
39 ivFootsizeY(params.footsize_y),
40 ivOriginFootShiftX(params.foot_origin_shift_x),
41 ivOriginFootShiftY(params.foot_origin_shift_y),
42 ivMaxFootstepX(
disc_val(params.max_footstep_x, params.cell_size)),
43 ivMaxFootstepY(
disc_val(params.max_footstep_y, params.cell_size)),
46 ivMaxInvFootstepX(
disc_val(params.max_inverse_footstep_x, params.cell_size)),
47 ivMaxInvFootstepY(
disc_val(params.max_inverse_footstep_y, params.cell_size)),
48 ivMaxInvFootstepTheta(
50 params.num_angle_bins)),
51 ivStepCost(cvMmScale * params.step_cost),
52 ivCollisionCheckAccuracy(params.collision_check_accuracy),
53 ivHashTableSize(params.hash_table_size),
54 ivCellSize(params.cell_size),
55 ivNumAngleBins(params.num_angle_bins),
56 ivForwardSearch(params.forward_search),
57 ivMaxStepWidth(double(
disc_val(params.max_step_width, params.cell_size))),
58 ivNumRandomNodes(params.num_random_nodes),
59 ivRandomNodeDist(params.random_node_distance / ivCellSize),
60 ivHeuristicScale(params.heuristic_scale),
61 ivHeuristicExpired(true),
62 ivNumExpandedStates(0)
104 const State& foot_right)
112 if (p_foot_left == NULL)
115 if (p_foot_right == NULL)
142 const State& foot_right)
150 if (p_foot_left == NULL)
153 if (p_foot_right == NULL)
193 assert(state_id < (
size_t)std::numeric_limits<int>::max());
196 new_state->
setId(state_id);
202 int* entry =
new int[NUMOFINDICES_STATEID2IND];
203 StateID2IndexMapping.push_back(entry);
204 for(
int i = 0; i < NUMOFINDICES_STATEID2IND; ++i)
206 StateID2IndexMapping[state_id][i] = -1;
209 assert(StateID2IndexMapping.size() - 1 == state_id);
227 std::vector<const PlanningState*>::const_iterator state_iter;
232 if (*(*state_iter) == s)
244 if (hash_entry == NULL)
285 double theta_cos = cos(theta);
286 double theta_sin = sin(theta);
346 ROS_INFO(
"Updating the heuristic values.");
361 success = h->calculateDistances(*start, *goal);
363 success = h->calculateDistances(*goal, *start);
366 ROS_ERROR(
"Failed to calculate path cost heuristic.");
371 ROS_DEBUG(
"Finished updating the heuristic values.");
394 StateID2IndexMapping.clear();
470 if (footstep_theta >= num_angle_bins_half)
472 else if (footstep_theta < -num_angle_bins_half)
478 footstep_y = -footstep_y;
479 footstep_theta = -footstep_theta;
537 const std::vector<State>& changed_states,
538 std::vector<int>* pred_ids)
542 std::vector<State>::const_iterator state_iter;
543 for (state_iter = changed_states.begin();
544 state_iter != changed_states.end();
550 std::vector<Footstep>::const_iterator footstep_set_iter;
555 PlanningState pred = footstep_set_iter->reverseMeOnThisState(s);
558 if (pred_hash_entry == NULL)
560 pred_ids->push_back(pred_hash_entry->
getId());
568 const std::vector<State>& changed_states,
569 std::vector<int>* succ_ids)
573 std::vector<State>::const_iterator state_iter;
574 for (state_iter = changed_states.begin();
575 state_iter != changed_states.end();
581 std::vector<Footstep>::const_iterator footstep_set_iter;
586 PlanningState succ = footstep_set_iter->performMeOnThisState(s);
589 if (succ_hash_entry == NULL)
591 succ_ids->push_back(succ_hash_entry->
getId());
601 assert(FromStateID >= 0 && (
unsigned int) FromStateID <
ivStateId2State.size());
602 assert(ToStateID >= 0 && (
unsigned int) ToStateID <
ivStateId2State.size());
636 std::vector<int> *PredIDV,
637 std::vector<int> *CostV)
642 assert(TargetStateID >= 0 &&
653 CostV->push_back(0.0);
668 std::vector<int>::const_iterator state_id_iter;
675 PredIDV->push_back(s->
getId());
676 CostV->push_back(cost);
702 std::vector<Footstep>::const_iterator footstep_set_iter;
708 footstep_set_iter->reverseMeOnThisState(*current);
715 int cost =
stepCost(*current, *predecessor_hash);
716 PredIDV->push_back(predecessor_hash->
getId());
717 CostV->push_back(cost);
731 std::vector<int> *SuccIDV,
732 std::vector<int> *CostV)
737 assert(SourceStateID >= 0 &&
750 CostV->push_back(0.0);
766 std::vector<int>::const_iterator state_id_iter;
773 SuccIDV->push_back(s->
getId());
774 CostV->push_back(cost);
793 SuccIDV->push_back(goal_id);
794 CostV->push_back(
stepCost(*current, *goal));
801 std::vector<Footstep>::const_iterator footstep_set_iter;
807 footstep_set_iter->performMeOnThisState(*current);
814 int cost =
stepCost(*current, *successor_hash_entry);
815 SuccIDV->push_back(successor_hash_entry->
getId());
816 CostV->push_back(cost);
822 std::vector<int> *SuccIDV,
823 std::vector<int> *CostV)
830 assert(SourceStateID >= 0 &&
862 int cost =
stepCost(*current, *goal);
863 SuccIDV->push_back(goal_id);
864 CostV->push_back(cost);
870 assert(goalStateId >= 0 &&
unsigned(goalStateId) <
ivStateId2State.size());
872 if (randomGoal->getLeg() != current->
getLeg() &&
reachable(*current, *randomGoal)){
873 int cost =
stepCost(*current, *randomGoal);
874 SuccIDV->push_back(goalStateId);
875 CostV->push_back(cost);
884 std::vector<Footstep>::const_iterator footstep_set_iter;
890 footstep_set_iter->performMeOnThisState(*current);
896 int cost =
stepCost(*current, *successor_hash);
897 SuccIDV->push_back(successor_hash->
getId());
898 CostV->push_back(cost);
905 std::vector<int>* SuccIDV, std::vector<int>* CLowV)
908 assert(SourceStateID >= 0 &&
unsigned(SourceStateID) <
ivStateId2State.size());
927 std::vector<int>* PredIDV, std::vector<int>* CLowV)
930 assert(TargetStateID >= 0 &&
962 int X = currentState->
getX();
963 int Y = currentState->
getY();
978 int nDist_sq = nDist_c*nDist_c;
990 NeighIDV->push_back(goal_left->
getId());
991 CLowV->push_back(clow);
1005 NeighIDV->push_back(goal_right->
getId());
1006 CLowV->push_back(clow);
1012 for (
int i = 0; i < nNumofNeighs && nAttempts < 5*nNumofNeighs; ++i, ++nAttempts)
1016 float fDir = (float)(
TWO_PI*(((
double)rand())/RAND_MAX));
1018 int dX = (int)(nDist_c*cos(fDir));
1019 int dY = (int)(nDist_c*sin(fDir));
1037 Leg newLeg =
Leg(rand() % 2);
1052 if (random_hash_entry == NULL){
1065 NeighIDV->push_back(random_hash_entry->
getId());
1066 CLowV->push_back(clow);
1097 if (NeighIDV->size() == 0){
1098 ROS_WARN(
"Could not create any random neighbor nodes (%d attempts) from id %d (%d %d)",
1099 nAttempts, currentState->
getId(), X, Y);
1102 ROS_DEBUG(
"Created %zu random neighbors (%d attempts) from id %d " 1103 "(%d %d)", NeighIDV->size(), nAttempts, currentState->
getId(),
1110 assert(StateID1 >= 0 && StateID2 >= 0
1114 if (StateID1 == StateID2)
1121 return (std::abs(s1->
getX() - s2->
getX()) < 1
1122 && std::abs(s1->
getY() - s2->
getY()) < 1
1162 ROS_ERROR(
"FootstepPlanerEnvironment::PrintEnv_Config: Hit " 1163 "unimplemented function. Check this!");
1178 SBPL_FPRINTF(fOut,
"the state is a goal state\n");
1185 SBPL_FPRINTF(fOut,
"X=%i Y=%i THETA=%i FOOT=%i\n",
1190 SBPL_FPRINTF(fOut,
"%i %i %i %i\n",
1205 ROS_ERROR(
"FootstepPlannerEnvironment::SetAllActionsandAllOutcomes: Hit" 1206 " unimplemented function. Check this!");
1219 ROS_ERROR(
"FootstepPlannerEnvironment::SetAllPreds: Hit unimplemented " 1220 "function. Check this!");
1240 double cont_step_x, cont_step_y, cont_step_theta;
1252 Footstep step(cont_step_x, cont_step_y, cont_step_theta,
TFSIMD_FORCE_INLINE const tfScalar & x() const
static Quaternion createQuaternionFromYaw(double yaw)
TFSIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
TFSIMD_FORCE_INLINE const tfScalar & y() const
def normalize_angle(angle)