Go to the documentation of this file.00001 #include <vigir_footstep_planning_default_plugins/step_cost_estimators/boundary_step_cost_estimator.h>
00002
00003 #include <angles/angles.h>
00004
00005
00006
00007 namespace vigir_footstep_planning
00008 {
00009 BoundaryStepCostEstimator::BoundaryStepCostEstimator()
00010 : StepCostEstimatorPlugin("boundary_step_cost_estimator")
00011 {
00012 }
00013
00014 bool BoundaryStepCostEstimator::loadParams(const vigir_generic_params::ParameterSet& params)
00015 {
00016 if (!StepCostEstimatorPlugin::loadParams(params))
00017 return false;
00018
00019 params.getParam("boundary_step_cost_estimator/max_diff_z", max_diff_z);
00020 params.getParam("boundary_step_cost_estimator/long_step_dist", long_step_dist);
00021 params.getParam("boundary_step_cost_estimator/min_yaw_seperation_enlargement", min_yaw_seperation_enlargement);
00022 params.getParam("boundary_step_cost_estimator/yaw_enlarged_min_seperation", yaw_enlarged_min_seperation);
00023 params.getParam("boundary_step_cost_estimator/cost_roll_abs", cost_roll_abs);
00024 params.getParam("boundary_step_cost_estimator/cost_pitch_abs", cost_pitch_abs);
00025 params.getParam("boundary_step_cost_estimator/cost_yaw_rel", cost_yaw_rel);
00026 params.getParam("boundary_step_cost_estimator/cost_height_diff_rel", cost_height_diff_rel);
00027
00028 return true;
00029 }
00030
00031 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
00032 {
00033 cost = 0.0;
00034 cost_multiplier = 1.0;
00035 risk = 0.0;
00036 risk_multiplier = 1.0;
00037
00038 if (swing_foot == left_foot || swing_foot == right_foot)
00039 return true;
00040
00041 const State& stand_foot = swing_foot.getLeg() == LEFT ? right_foot : left_foot;
00042 const State& swing_foot_before = swing_foot.getLeg() == LEFT ? left_foot : right_foot;
00043
00044 double diff_z = std::abs(swing_foot.getZ()-stand_foot.getZ());
00045
00046
00047 if (diff_z >= max_diff_z)
00048 return false;
00049
00050
00051 tf::Transform step = stand_foot.getPose().inverse() * swing_foot.getPose();
00052
00053
00054 if (step.getOrigin().x() > long_step_dist)
00055 risk += step.getOrigin().x()-long_step_dist;
00056
00057
00058 double stance_yaw_diff = angles::shortest_angular_distance(swing_foot_before.getYaw(), stand_foot.getYaw());
00059 double swing_foot_yaw_diff = angles::shortest_angular_distance(stand_foot.getYaw(), swing_foot.getYaw());
00060
00061
00062 if (std::abs(swing_foot_yaw_diff) >= min_yaw_seperation_enlargement && std::abs(step.getOrigin().y()) <= yaw_enlarged_min_seperation)
00063 return false;
00064
00065
00066 double turn_rate_diff = swing_foot_yaw_diff - stance_yaw_diff;
00067
00068 if (turn_rate_diff * swing_foot_yaw_diff <= 0.0)
00069 turn_rate_diff = 0.0;
00070
00071
00072 risk += cost_roll_abs * std::abs(swing_foot.getRoll());
00073 risk += cost_pitch_abs * std::abs(swing_foot.getPitch());
00074 risk += cost_yaw_rel * std::abs(turn_rate_diff);
00075 risk += cost_height_diff_rel * diff_z;
00076
00077 cost = risk*risk;
00078
00079 return true;
00080 }
00081 }
00082
00083 #include <pluginlib/class_list_macros.h>
00084 PLUGINLIB_EXPORT_CLASS(vigir_footstep_planning::BoundaryStepCostEstimator, vigir_footstep_planning::StepCostEstimatorPlugin)