3 #include <vigir_footstep_planning_plugins/plugin_aggregators/state_generator.h> 10 : DiscreteSpaceInformation()
11 , foot_pose_transformer(foot_pose_transformer)
12 , feedback_cb(feedback_cb)
14 , ivNumExpandedStates(0)
16 , last_feedback_flush(
ros::Time::now())
39 ROS_INFO(
"Updating the heuristic values.");
64 ROS_DEBUG(
"Finished updating the heuristic values.");
89 msgs::PlanningFeedback feedback;
95 const PlanningState* state = &s;
97 step.header = feedback.header;
98 step.foot.header = feedback.header;
100 feedback.current_step_plan.header = feedback.header;
104 state->getState().getStep(step);
105 feedback.current_step_plan.steps.push_back(step);
109 if (!state->getPredState())
111 state = state->getPredState();
115 if (!state->getSuccState())
117 state = state->getSuccState();
138 s.getState().getStep(step);
141 step.foot.header = step.header;
148 assert(FromStateID >= 0 && (
unsigned int) FromStateID < state_space->ivStateId2State.size());
149 assert(ToStateID >= 0 && (
unsigned int) ToStateID < state_space->ivStateId2State.size());
162 return cvMmScale * params.
heuristic_scale * Heuristic::instance().getHeuristicValue(from.getState(), to.getState(), start.getState(), goal.getState());
167 const PlanningState* current =
state_space->ivStateId2State[stateID];
168 if (current->getLeg() == LEFT)
177 boost::this_thread::interruption_point();
182 assert(TargetStateID >= 0 && (
unsigned int) TargetStateID < state_space->ivStateId2State.size());
188 const PlanningState* current =
state_space->ivStateId2State[TargetStateID];
190 if (!current->getSuccState())
192 ROS_WARN(
"Step cost should be evaluated but current state has no successor!");
202 ROS_WARN(
"This should not happen! Reactivate setStateArea");
205 const PlanningState*
s;
207 std::vector<int>::const_iterator state_id_iter;
208 for(state_id_iter =
state_space->ivStateArea.begin(); state_id_iter !=
state_space->ivStateArea.end(); ++state_id_iter)
211 if (s->getLeg() == current->getLeg())
213 if (*(current->getSuccState()) == *s)
216 if (!
state_space->getStepCost(current->getState(), s->getState(), current->getSuccState()->getState(), cost))
219 PredIDV->push_back(s->getId());
220 CostV->push_back(cost);
233 if (*(current->getSuccState()) == *start)
236 if (WorldModel::instance().isAccessible(start->getState(), current->getState()))
239 if (
state_space->getStepCost(current->getState(), start->getState(), current->getSuccState()->getState(), cost))
241 PredIDV->push_back(start->getId());
242 CostV->push_back(cost);
250 std::list<PlanningState::Ptr> visited_states = StateGenerator::instance().generatePredecessors(*current);
252 PredIDV->reserve(visited_states.size());
253 CostV->reserve(visited_states.size());
255 for (
const PlanningState::Ptr& visited_state : visited_states)
257 const PlanningState* successor_hash =
state_space->createHashEntryIfNotExists(*visited_state);
259 PredIDV->push_back(successor_hash->getId());
260 CostV->push_back(static_cast<int>(cvMmScale * visited_state->getState().getCost() + 0.5));
267 const PlanningState* current =
state_space->ivStateId2State[stateID];
268 if (current->getLeg() == LEFT)
278 boost::this_thread::interruption_point();
283 assert(SourceStateID >= 0 &&
unsigned(SourceStateID) <
state_space->ivStateId2State.size());
289 const PlanningState* current =
state_space->ivStateId2State[SourceStateID];
291 if (!current->getPredState())
293 ROS_WARN(
"Step cost should be evaluated but current state has no predecessor!");
303 ROS_WARN(
"This should not happen! Reactivate setStateArea");
306 const PlanningState*
s;
308 std::vector<int>::const_iterator state_id_iter;
309 for(state_id_iter =
state_space->ivStateArea.begin(); state_id_iter !=
state_space->ivStateArea.end(); ++state_id_iter)
312 if (s->getLeg() == current->getLeg())
314 if (*(current->getPredState()) == *s)
317 if (!
state_space->getStepCost(current->getState(), current->getPredState()->getState(), s->getState(), cost))
320 SuccIDV->push_back(s->getId());
321 CostV->push_back(cost);
334 if (*(current->getPredState()) == *goal)
337 if (WorldModel::instance().isAccessible(goal->getState(), current->getState()))
340 if (
state_space->getStepCost(current->getState(), current->getPredState()->getState(), goal->getState(), cost))
342 SuccIDV->push_back(goal->getId());
343 CostV->push_back(cost);
351 std::list<PlanningState::Ptr> visited_states = StateGenerator::instance().generateSuccessors(*current);
353 SuccIDV->reserve(visited_states.size());
354 CostV->reserve(visited_states.size());
356 for (
const PlanningState::Ptr& visited_state : visited_states)
358 const PlanningState* successor_hash =
state_space->createHashEntryIfNotExists(*visited_state);
360 SuccIDV->push_back(successor_hash->getId());
361 CostV->push_back(static_cast<int>(cvMmScale * visited_state->getState().getCost() + 0.5));
368 boost::this_thread::interruption_point();
370 assert(SourceStateID >= 0 &&
unsigned(SourceStateID) <
state_space->ivStateId2State.size());
388 boost::this_thread::interruption_point();
390 assert(TargetStateID >= 0 &&
unsigned(TargetStateID) <
state_space->ivStateId2State.size());
408 assert(StateID1 >= 0 && StateID2 >= 0 &&
unsigned(StateID1) <
state_space->ivStateId2State.size() && unsigned(StateID2) <
state_space->ivStateId2State.size());
410 if (StateID1 == StateID2)
413 const PlanningState* s1 =
state_space->ivStateId2State[StateID1];
414 const PlanningState* s2 =
state_space->ivStateId2State[StateID2];
430 MDPCfg->startstateid =
state_space->ivIdPlanningStart;
431 MDPCfg->goalstateid =
state_space->ivIdPlanningGoal;
442 ROS_ERROR(
"FootstepPlanerEnvironment::PrintEnv_Config: Hit " 443 "unimplemented function. Check this!");
453 if(stateID ==
state_space->ivIdGoalFootLeft && bVerbose)
455 SBPL_FPRINTF(fOut,
"the state is a goal state\n");
458 const PlanningState*
s =
state_space->ivStateId2State[stateID];
462 SBPL_FPRINTF(fOut,
"X=%i Y=%i THETA=%i FOOT=%i\n",
463 s->getX(), s->getY(), s->getYaw(), s->getLeg());
467 SBPL_FPRINTF(fOut,
"%i %i %i %i\n",
468 s->getX(), s->getY(), s->getYaw(), s->getLeg());
480 ROS_ERROR(
"FootstepPlannerEnvironment::SetAllActionsandAllOutcomes: Hit" 481 " unimplemented function. Check this!");
492 ROS_ERROR(
"FootstepPlannerEnvironment::SetAllPreds: Hit unimplemented " 493 "function. Check this!");
503 if (a->getX() < b->getX())
505 else if (a->getY() < b->getY())
507 else if (a->getYaw() < b->getYaw())