hot_map_heuristic.cpp
Go to the documentation of this file.
2 
3 
4 
6 {
8 : HeuristicPlugin("hot_map_heuristic")
9 {
10 }
11 
12 bool HotMapHeuristic::loadParams(const vigir_generic_params::ParameterSet& params)
13 {
14  if (!HeuristicPlugin::loadParams(params))
15  return false;
16 
17  params.getParam("collision_check/cell_size", cell_size_);
18  int num_angle_bins;
19  params.getParam("collision_check/num_angle_bins", num_angle_bins);
20  angle_bin_size_ = 2.0*M_PI / static_cast<double>(num_angle_bins);
21  return true;
22 }
23 
24 bool HotMapHeuristic::initialize(const vigir_generic_params::ParameterSet& params)
25 {
26  if (!HeuristicPlugin::initialize(params))
27  return false;
28 
29  // publish topics
30  hot_map_pub_ = nh_.advertise<nav_msgs::OccupancyGrid>("hot_map", 1);
31  publish_timer_ = nh_.createTimer(ros::Duration(1.0), &HotMapHeuristic::publishHotMap, this);
32 
33  return true;
34 }
35 
37 {
38  boost::unique_lock<boost::shared_mutex> lock(hot_map_shared_mutex_);
39  hot_map_.clear();
41 }
42 
43 double HotMapHeuristic::getHeuristicValue(const State& from, const State& to, const State& /*start*/, const State& /*goal*/) const
44 {
45  if (from == to)
46  return 0.0;
47 
48  unsigned int hit = 0;
49  {
50  boost::unique_lock<boost::shared_mutex> lock(hot_map_shared_mutex_);
53  }
54 
55  return 1000.0 * static_cast<double>(hit)/static_cast<double>(total_hit_counter_);
56 }
57 
58 void HotMapHeuristic::publishHotMap(const ros::TimerEvent& /*publish_timer*/) const
59 {
61  {
62  boost::shared_lock<boost::shared_mutex> lock(hot_map_shared_mutex_);
63 
64  nav_msgs::OccupancyGrid grid_map;
65 
66  grid_map.header.stamp = ros::Time::now();
67  grid_map.header.frame_id = "/world";
68 
70 
71  hot_map_pub_.publish(grid_map);
72  }
73 }
74 }
75 
76 #include <pluginlib/class_list_macros.h>
77 PLUGINLIB_EXPORT_CLASS(vigir_footstep_planning::HotMapHeuristic, vigir_footstep_planning::HeuristicPlugin)
void publish(const boost::shared_ptr< M > &message) const
bool initialize(const vigir_generic_params::ParameterSet &params=vigir_generic_params::ParameterSet()) override
void publishHotMap(const ros::TimerEvent &publish_timer) const
double getHeuristicValue(const State &from, const State &to, const State &start, const State &goal) const override
bool loadParams(const vigir_generic_params::ParameterSet &params=vigir_generic_params::ParameterSet()) override
uint32_t getNumSubscribers() const
static Time now()


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