3 #include <vigir_footstep_planning_lib/math.h> 5 #include <vigir_footstep_planning_plugins/plugin_aggregators/robot_model.h> 6 #include <vigir_footstep_planning_plugins/plugin_aggregators/post_processor.h> 7 #include <vigir_footstep_planning_plugins/plugin_aggregators/step_cost_estimator.h> 8 #include <vigir_footstep_planning_plugins/plugin_aggregators/heuristic.h> 17 , ivIdPlanningStart(-1)
18 , ivIdPlanningGoal(-1)
19 , ivIdStartFootLeft(-1)
20 , ivIdStartFootRight(-1)
21 , ivIdGoalFootLeft(-1)
22 , ivIdGoalFootRight(-1)
23 , state_ID2_index_mapping(state_ID2_index_mapping)
24 , ivpStateHash2State(new
std::vector<PlanningState*>[params.hash_table_size])
25 , ivHeuristicExpired(false)
26 , ivRandomNodeDist(params.random_node_distance / params.cell_size)
146 if (start_foot_selection == msgs::StepPlanRequest::AUTO)
156 start_foot_selection = msgs::StepPlanRequest::RIGHT;
158 start_foot_selection = msgs::StepPlanRequest::LEFT;
161 if (start_foot_selection == msgs::StepPlanRequest::LEFT)
171 else if (start_foot_selection == msgs::StepPlanRequest::RIGHT)
182 ROS_ERROR(
"[setPlannerStartAndGoal] Unknown selection mode: %u", start_foot_selection);
213 robot.setX(0.5*(left.getX()+right.getX()));
214 robot.setY(0.5*(left.getY()+right.getY()));
215 robot.setZ(0.5*(left.getZ()+right.getZ()));
216 robot.setYaw(0.5*(left.getYaw()+right.getYaw()));
239 robot.setX(0.5*(left.getX()+right.getX()));
240 robot.setY(0.5*(left.getY()+right.getY()));
241 robot.setZ(0.5*(left.getZ()+right.getZ()));
242 robot.setYaw(0.5*(left.getYaw()+right.getYaw()));
254 unsigned int state_hash = s.getHashTag();
255 PlanningState* new_state =
new PlanningState(s);
260 assert(state_id < (
size_t)std::numeric_limits<int>::max());
263 new_state->setId(state_id);
269 int* entry =
new int[NUMOFINDICES_STATEID2IND];
272 for(
int i = 0; i < NUMOFINDICES_STATEID2IND; ++i)
288 unsigned int state_hash = s.getHashTag();
289 std::vector<PlanningState*>::const_iterator state_iter;
293 if (*(*state_iter) == s)
303 if (hash_entry == NULL)
314 assert(from.getSuccState() !=
nullptr);
317 State left_foot = (from.getLeg() == LEFT) ? from.getState() : from.getSuccState()->getState();
318 State right_foot = (from.getLeg() == RIGHT) ? from.getState() : from.getSuccState()->getState();
321 PostProcessor::instance().postProcessBackward(left_foot, right_foot, start_foot);
322 if (!RobotModel::instance().isReachable(left_foot, right_foot, start_foot))
326 if (start_foot.getLeg() == LEFT)
328 left_foot = start_foot;
333 right_foot = start_foot;
337 PostProcessor::instance().postProcessBackward(left_foot, right_foot, start_foot);
338 start_foot.setBodyVelocity(geometry_msgs::Vector3());
339 if (!RobotModel::instance().isReachable(left_foot, right_foot, start_foot))
350 assert(from.getPredState() !=
nullptr);
353 State left_foot = (from.getLeg() == LEFT) ? from.getState() : from.getPredState()->getState();
354 State right_foot = (from.getLeg() == RIGHT) ? from.getState() : from.getPredState()->getState();
357 PostProcessor::instance().postProcessForward(left_foot, right_foot, goal_foot);
358 if (!RobotModel::instance().isReachable(left_foot, right_foot, goal_foot))
362 if (goal_foot.getLeg() == LEFT)
364 left_foot = goal_foot;
369 right_foot = goal_foot;
373 PostProcessor::instance().postProcessForward(left_foot, right_foot, goal_foot);
374 goal_foot.setBodyVelocity(geometry_msgs::Vector3());
375 if (!RobotModel::instance().isReachable(left_foot, right_foot, goal_foot))
381 bool StateSpace::getStepCost(
const State& stand_foot,
const State& swing_foot_before,
const State& swing_foot_after,
double& cost,
double& risk)
const 386 if (stand_foot.getLeg() == swing_foot_before.getLeg())
388 ROS_ERROR(
"Can't compute step cost: No standing foot is same leg as swing foot!");
392 if (swing_foot_before.getLeg() != swing_foot_after.getLeg())
394 ROS_ERROR(
"Can't compute step cost: Swing foot states have not same leg!");
398 const State& left_foot = stand_foot.getLeg() == LEFT ? stand_foot : swing_foot_before;
399 const State& right_foot = stand_foot.getLeg() == RIGHT ? stand_foot : swing_foot_before;
401 if (!StepCostEstimator::instance().getCost(left_foot, right_foot, swing_foot_after, cost, risk))
410 bool StateSpace::getStepCost(
const State& stand_foot,
const State& swing_foot_before,
const State& swing_foot_after,
int& cost,
int& risk)
const 412 double cost_d, risk_d;
413 if (!
getStepCost(stand_foot, swing_foot_before, swing_foot_after, cost_d, risk_d))
416 cost =
static_cast<int>(cvMmScale * cost_d + 0.5);
417 risk =
static_cast<int>(cvMmScale * risk_d + 0.5);
422 bool StateSpace::getStepCost(
const State& stand_foot,
const State& swing_foot_before,
const State& swing_foot_after,
int& cost)
const 425 return getStepCost(stand_foot, swing_foot_before, swing_foot_after, cost, risk);
TFSIMD_FORCE_INLINE const tfScalar & getY() const