Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <footstep_planner/Heuristic.h>
00025
00026 namespace footstep_planner
00027 {
00028 Heuristic::Heuristic(double cell_size, int num_angle_bins,
00029 HeuristicType type)
00030 : ivCellSize(cell_size),
00031 ivNumAngleBins(num_angle_bins),
00032 ivHeuristicType(type)
00033 {}
00034
00035
00036 Heuristic::~Heuristic()
00037 {}
00038
00039
00040 EuclideanHeuristic::EuclideanHeuristic(double cell_size, int num_angle_bins)
00041 : Heuristic(cell_size, num_angle_bins, EUCLIDEAN)
00042 {}
00043
00044
00045 EuclideanHeuristic::~EuclideanHeuristic()
00046 {}
00047
00048
00049 double
00050 EuclideanHeuristic::getHValue(const PlanningState& from,
00051 const PlanningState& to)
00052 const
00053 {
00054 if (from == to)
00055 return 0.0;
00056
00057
00058 double dist = euclidean_distance(from.getX(), from.getY(),
00059 to.getX(), to.getY());
00060
00061 return cont_val(dist, ivCellSize);
00062 }
00063
00064
00065 EuclStepCostHeuristic::EuclStepCostHeuristic(double cell_size,
00066 int num_angle_bins,
00067 double step_cost,
00068 double diff_angle_cost,
00069 double max_step_width)
00070 : Heuristic(cell_size, num_angle_bins, EUCLIDEAN_STEPCOST),
00071 ivStepCost(step_cost),
00072 ivDiffAngleCost(diff_angle_cost),
00073 ivMaxStepWidth(max_step_width)
00074 {}
00075
00076
00077 EuclStepCostHeuristic::~EuclStepCostHeuristic()
00078 {}
00079
00080
00081 double
00082 EuclStepCostHeuristic::getHValue(const PlanningState& from,
00083 const PlanningState& to)
00084 const
00085 {
00086 if (from == to)
00087 return 0.0;
00088
00089
00090 double dist = cont_val(euclidean_distance(
00091 from.getX(), from.getY(), to.getX(), to.getY()), ivCellSize);
00092 double expected_steps = dist / ivMaxStepWidth;
00093 double diff_angle = 0.0;
00094 if (ivDiffAngleCost > 0.0)
00095 {
00096
00097 int diff_angle_disc = (
00098 ((to.getTheta() - from.getTheta()) % ivNumAngleBins) +
00099 ivNumAngleBins) % ivNumAngleBins;
00100
00101 diff_angle = std::abs(angles::normalize_angle(
00102 angle_cell_2_state(diff_angle_disc, ivNumAngleBins)));
00103 }
00104
00105 return (dist + expected_steps * ivStepCost +
00106 diff_angle * ivDiffAngleCost);
00107 }
00108 }