collision_check_grid_map_plugin.cpp
Go to the documentation of this file.
2 
3 
4 
6 {
9  , occ_thresh_(70)
10 {
11 }
12 
13 bool CollisionCheckGridMapPlugin::initialize(const vigir_generic_params::ParameterSet& params)
14 {
16  return false;
17 
18  std::string topic;
19  getParam("grid_map_topic", topic, std::string("/grid_map"));
20  occupancy_grid_map_sub_ = nh_.subscribe<nav_msgs::OccupancyGrid>(topic, 1, &CollisionCheckGridMapPlugin::mapCallback, this);
21 
22  getParam("occupancy_threshold", (int&) occ_thresh_, (int&) occ_thresh_, true);
23 
24  return true;
25 }
26 
28 {
30 
31  boost::unique_lock<boost::shared_mutex> lock(grid_map_shared_mutex_);
32  occupancy_grid_map_.reset();
33 }
34 
36 {
38 }
39 
41 {
42  boost::shared_lock<boost::shared_mutex> lock(grid_map_shared_mutex_);
43 
45  {
46  ROS_ERROR_THROTTLE(10, "[CollisionCheckGridMapPlugin] No grid map available yet.");
47  return true;
48  }
49 
50  double x = s.getX();
51  double y = s.getY();
52  int idx = 0;
53 
54  if (getGridMapIndex(*occupancy_grid_map_, x, y, idx))
55  return occupancy_grid_map_->data.at(idx) <= occ_thresh_;
56 
57  return false;
58 }
59 
60 bool CollisionCheckGridMapPlugin::isAccessible(const State& next, const State& /*current*/) const
61 {
62  return isAccessible(next);
63 }
64 
66 {
67  occ_thresh_ = static_cast<int8_t>(thresh);
68 }
69 
70 void CollisionCheckGridMapPlugin::mapCallback(const nav_msgs::OccupancyGridConstPtr& occupancy_grid_map)
71 {
72  boost::unique_lock<boost::shared_mutex> lock(grid_map_shared_mutex_);
73  this->occupancy_grid_map_ = occupancy_grid_map;
74 }
75 }
76 
77 #include <pluginlib/class_list_macros.h>
bool initialize(const vigir_generic_params::ParameterSet &params=vigir_generic_params::ParameterSet()) override
CollisionCheckGridMapPlugin(const std::string &name="collision_check_grid_map_plugin")
TFSIMD_FORCE_INLINE const tfScalar & y() const
#define ROS_ERROR_THROTTLE(rate,...)
bool getGridMapIndex(const nav_msgs::OccupancyGrid &map, double x, double y, int &idx)
TFSIMD_FORCE_INLINE const tfScalar & x() const
virtual void reset()
Resets the plugin to initial state.
bool initialize(const vigir_generic_params::ParameterSet &params=vigir_generic_params::ParameterSet()) override
virtual void mapCallback(const nav_msgs::OccupancyGridConstPtr &occupancy_grid_map)
void reset() override
Resets the plugin to initial state.


vigir_footstep_planning_plugins
Author(s): Alexander Stumpf
autogenerated on Mon Jun 10 2019 15:47:39