8 : StepCostEstimatorPlugin(
"map_step_cost_estimator")
14 if (!StepCostEstimatorPlugin::loadParams(params))
18 params.getParam(
"map_step_cost_estimator/file", filename);
25 bool MapStepCostEstimator::getCost(
const State& left_foot,
const State& right_foot,
const State& swing_foot,
double& cost,
double& cost_multiplier,
double& risk,
double& risk_multiplier)
const 28 cost_multiplier = 1.0;
30 risk_multiplier = 1.0;
32 const State& stand_foot = swing_foot.getLeg() == LEFT ? right_foot : left_foot;
33 double foot_dist = euclidean_distance(stand_foot.getX(), stand_foot.getY(), swing_foot.getX(), swing_foot.getY());
35 const State& swing_foot_before = swing_foot.getLeg() == LEFT ? left_foot : right_foot;
36 double dist = 0.5*euclidean_distance(swing_foot_before.getX(), swing_foot_before.getY(), swing_foot.getX(), swing_foot.getY());
38 if (dist > 0.3 || foot_dist > 0.45)
45 boost::unordered_map<StepCostKey, std::pair<double, double> >::const_iterator iter =
cost_map.find(key);
53 risk = iter->second.second <= 0.25 ? abs(iter->second.first) : 1.0;
65 cost = dist + 2*risk*risk;
78 file.open(filename.c_str(), std::ios::in | std::ios::binary);
82 ROS_ERROR(
"Could not read from file %s", filename.c_str());
89 read<float>(file,
min_x);
90 read<float>(file,
max_x);
91 read<float>(file,
min_y);
92 read<float>(file,
max_y);
98 read<float>(file, temp);
104 uint32_t dim_size, num_elements;
105 read<uint32_t>(file, num_elements);
106 read<uint32_t>(file, dim_size);
110 std::vector<double> key;
111 key.resize(dim_size);
112 std::pair<double, double> entry;
115 for (
unsigned int i = 0; i < num_elements; i++)
118 for (
unsigned int d = 0;
d < dim_size;
d++)
121 read<float>(file, k);
127 read<float>(file, c);
128 read<float>(file, s);
138 ROS_INFO(
"Loaded step cost map: %u dimensions and %lu entries", dim_size,
cost_map.size());
145 #include <pluginlib/class_list_macros.h>