boundary_step_cost_estimator.cpp
Go to the documentation of this file.
2 
3 #include <angles/angles.h>
4 
5 
6 
8 {
10  : StepCostEstimatorPlugin("boundary_step_cost_estimator")
11 {
12 }
13 
14 bool BoundaryStepCostEstimator::loadParams(const vigir_generic_params::ParameterSet& params)
15 {
16  if (!StepCostEstimatorPlugin::loadParams(params))
17  return false;
18 
19  params.getParam("boundary_step_cost_estimator/max_diff_z", max_diff_z);
20  params.getParam("boundary_step_cost_estimator/long_step_dist", long_step_dist);
21  params.getParam("boundary_step_cost_estimator/min_yaw_seperation_enlargement", min_yaw_seperation_enlargement);
22  params.getParam("boundary_step_cost_estimator/yaw_enlarged_min_seperation", yaw_enlarged_min_seperation);
23  params.getParam("boundary_step_cost_estimator/cost_roll_abs", cost_roll_abs);
24  params.getParam("boundary_step_cost_estimator/cost_pitch_abs", cost_pitch_abs);
25  params.getParam("boundary_step_cost_estimator/cost_yaw_rel", cost_yaw_rel);
26  params.getParam("boundary_step_cost_estimator/cost_height_diff_rel", cost_height_diff_rel);
27 
28  return true;
29 }
30 
31 bool BoundaryStepCostEstimator::getCost(const State& left_foot, const State& right_foot, const State& swing_foot, double& cost, double& cost_multiplier, double& risk, double& risk_multiplier) const
32 {
33  cost = 0.0;
34  cost_multiplier = 1.0;
35  risk = 0.0;
36  risk_multiplier = 1.0;
37 
38  if (swing_foot == left_foot || swing_foot == right_foot)
39  return true;
40 
41  const State& stand_foot = swing_foot.getLeg() == LEFT ? right_foot : left_foot;
42  const State& swing_foot_before = swing_foot.getLeg() == LEFT ? left_foot : right_foot;
43 
44  double diff_z = std::abs(swing_foot.getZ()-stand_foot.getZ());
45 
46  // add costs
47  if (diff_z >= max_diff_z)
48  return false;
49 
50  // determine additional costs
51  tf::Transform step = stand_foot.getPose().inverse() * swing_foot.getPose();
52 
53  // all long steps should be more expensive
54  if (step.getOrigin().x() > long_step_dist)
55  risk += step.getOrigin().x()-long_step_dist;
56 
57  // get yaw diffs
58  double stance_yaw_diff = angles::shortest_angular_distance(swing_foot_before.getYaw(), stand_foot.getYaw());
59  double swing_foot_yaw_diff = angles::shortest_angular_distance(stand_foot.getYaw(), swing_foot.getYaw());
60 
61  // if foot is turned step more outside
62  if (std::abs(swing_foot_yaw_diff) >= min_yaw_seperation_enlargement && std::abs(step.getOrigin().y()) <= yaw_enlarged_min_seperation)
63  return false;
64 
65  // determine costs changing yaw: increasing turn rate may be expensiv but decreasing is free
66  double turn_rate_diff = swing_foot_yaw_diff - stance_yaw_diff;
67 
68  if (turn_rate_diff * swing_foot_yaw_diff <= 0.0) // check for different sign
69  turn_rate_diff = 0.0; // decreasing turn rate towards zero is always free
70 
71  // determine risk
72  risk += cost_roll_abs * std::abs(swing_foot.getRoll());
73  risk += cost_pitch_abs * std::abs(swing_foot.getPitch());
74  risk += cost_yaw_rel * std::abs(turn_rate_diff);
75  risk += cost_height_diff_rel * diff_z;
76 
77  cost = risk*risk;
78 
79  return true;
80 }
81 }
82 
83 #include <pluginlib/class_list_macros.h>
84 PLUGINLIB_EXPORT_CLASS(vigir_footstep_planning::BoundaryStepCostEstimator, vigir_footstep_planning::StepCostEstimatorPlugin)
bool getCost(const State &left_foot, const State &right_foot, const State &swing_foot, double &cost, double &cost_multiplier, double &risk, double &risk_multiplier) const override
bool loadParams(const vigir_generic_params::ParameterSet &params=vigir_generic_params::ParameterSet()) override


vigir_footstep_planning_default_plugins
Author(s): Alexander Stumpf
autogenerated on Sun Nov 17 2019 03:30:01