obstacle_layer.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2008, 2013, Willow Garage, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * Author: Eitan Marder-Eppstein
36  * David V. Lu!!
37  *********************************************************************/
40 #include <tf2_ros/message_filter.h>
41 
44 
46 
50 
53 
54 namespace costmap_2d
55 {
56 
58 {
59  ros::NodeHandle nh("~/" + name_), g_nh;
61 
62  bool track_unknown_space;
63  nh.param("track_unknown_space", track_unknown_space, layered_costmap_->isTrackingUnknown());
64  if (track_unknown_space)
66  else
68 
70  current_ = true;
71 
73  double transform_tolerance;
74  nh.param("transform_tolerance", transform_tolerance, 0.2);
75 
76  std::string topics_string;
77  // get the topics that we'll subscribe to from the parameter server
78  nh.param("observation_sources", topics_string, std::string(""));
79  ROS_INFO(" Subscribed to Topics: %s", topics_string.c_str());
80 
81  // now we need to split the topics based on whitespace which we can use a stringstream for
82  std::stringstream ss(topics_string);
83 
84  std::string source;
85  while (ss >> source)
86  {
87  ros::NodeHandle source_node(nh, source);
88 
89  // get the parameters for the specific topic
90  double observation_keep_time, expected_update_rate, min_obstacle_height, max_obstacle_height;
91  std::string topic, sensor_frame, data_type;
92  bool inf_is_valid, clearing, marking;
93 
94  source_node.param("topic", topic, source);
95  source_node.param("sensor_frame", sensor_frame, std::string(""));
96  source_node.param("observation_persistence", observation_keep_time, 0.0);
97  source_node.param("expected_update_rate", expected_update_rate, 0.0);
98  source_node.param("data_type", data_type, std::string("PointCloud"));
99  source_node.param("min_obstacle_height", min_obstacle_height, 0.0);
100  source_node.param("max_obstacle_height", max_obstacle_height, 2.0);
101  source_node.param("inf_is_valid", inf_is_valid, false);
102  source_node.param("clearing", clearing, false);
103  source_node.param("marking", marking, true);
104 
105  if (!(data_type == "PointCloud2" || data_type == "PointCloud" || data_type == "LaserScan"))
106  {
107  ROS_FATAL("Only topics that use point clouds or laser scans are currently supported");
108  throw std::runtime_error("Only topics that use point clouds or laser scans are currently supported");
109  }
110 
111  std::string raytrace_range_param_name, obstacle_range_param_name;
112 
113  // get the obstacle range for the sensor
114  double obstacle_range = 2.5;
115  if (source_node.searchParam("obstacle_range", obstacle_range_param_name))
116  {
117  source_node.getParam(obstacle_range_param_name, obstacle_range);
118  }
119 
120  // get the raytrace range for the sensor
121  double raytrace_range = 3.0;
122  if (source_node.searchParam("raytrace_range", raytrace_range_param_name))
123  {
124  source_node.getParam(raytrace_range_param_name, raytrace_range);
125  }
126 
127  ROS_DEBUG("Creating an observation buffer for source %s, topic %s, frame %s", source.c_str(), topic.c_str(),
128  sensor_frame.c_str());
129 
130  // create an observation buffer
131  observation_buffers_.push_back(
133  > (new ObservationBuffer(topic, observation_keep_time, expected_update_rate, min_obstacle_height,
134  max_obstacle_height, obstacle_range, raytrace_range, *tf_, global_frame_,
135  sensor_frame, transform_tolerance)));
136 
137  // check if we'll add this buffer to our marking observation buffers
138  if (marking)
139  marking_buffers_.push_back(observation_buffers_.back());
140 
141  // check if we'll also add this buffer to our clearing observation buffers
142  if (clearing)
143  clearing_buffers_.push_back(observation_buffers_.back());
144 
145  ROS_DEBUG(
146  "Created an observation buffer for source %s, topic %s, global frame: %s, "
147  "expected update rate: %.2f, observation persistence: %.2f",
148  source.c_str(), topic.c_str(), global_frame_.c_str(), expected_update_rate, observation_keep_time);
149 
150  // create a callback for the topic
151  if (data_type == "LaserScan")
152  {
154  > sub(new message_filters::Subscriber<sensor_msgs::LaserScan>(g_nh, topic, 50));
155 
158 
159  if (inf_is_valid)
160  {
161  filter->registerCallback([this,buffer=observation_buffers_.back()](auto& msg){ laserScanValidInfCallback(msg, buffer); });
162  }
163  else
164  {
165  filter->registerCallback([this,buffer=observation_buffers_.back()](auto& msg){ laserScanCallback(msg, buffer); });
166  }
167 
168  observation_subscribers_.push_back(sub);
169  observation_notifiers_.push_back(filter);
170 
171  observation_notifiers_.back()->setTolerance(ros::Duration(0.05));
172  }
173  else if (data_type == "PointCloud")
174  {
176  > sub(new message_filters::Subscriber<sensor_msgs::PointCloud>(g_nh, topic, 50));
177 
178  if (inf_is_valid)
179  {
180  ROS_WARN("obstacle_layer: inf_is_valid option is not applicable to PointCloud observations.");
181  }
182 
184  > filter(new tf2_ros::MessageFilter<sensor_msgs::PointCloud>(*sub, *tf_, global_frame_, 50, g_nh));
185  filter->registerCallback([this,buffer=observation_buffers_.back()](auto& msg){ pointCloudCallback(msg, buffer); });
186 
187  observation_subscribers_.push_back(sub);
188  observation_notifiers_.push_back(filter);
189  }
190  else
191  {
193  > sub(new message_filters::Subscriber<sensor_msgs::PointCloud2>(g_nh, topic, 50));
194 
195  if (inf_is_valid)
196  {
197  ROS_WARN("obstacle_layer: inf_is_valid option is not applicable to PointCloud observations.");
198  }
199 
201  > filter(new tf2_ros::MessageFilter<sensor_msgs::PointCloud2>(*sub, *tf_, global_frame_, 50, g_nh));
202  filter->registerCallback([this,buffer=observation_buffers_.back()](auto& msg){ pointCloud2Callback(msg, buffer); });
203 
204  observation_subscribers_.push_back(sub);
205  observation_notifiers_.push_back(filter);
206  }
207 
208  if (sensor_frame != "")
209  {
210  std::vector < std::string > target_frames;
211  target_frames.push_back(global_frame_);
212  target_frames.push_back(sensor_frame);
213  observation_notifiers_.back()->setTargetFrames(target_frames);
214  }
215  }
216 
217  dsrv_ = NULL;
219 }
220 
222 {
223  dsrv_ = new dynamic_reconfigure::Server<costmap_2d::ObstaclePluginConfig>(nh);
224  dynamic_reconfigure::Server<costmap_2d::ObstaclePluginConfig>::CallbackType cb =
225  [this](auto& config, auto level){ reconfigureCB(config, level); };
226  dsrv_->setCallback(cb);
227 }
228 
230 {
231  if (dsrv_)
232  delete dsrv_;
233 }
234 void ObstacleLayer::reconfigureCB(costmap_2d::ObstaclePluginConfig &config, uint32_t level)
235 {
236  enabled_ = config.enabled;
237  footprint_clearing_enabled_ = config.footprint_clearing_enabled;
238  max_obstacle_height_ = config.max_obstacle_height;
239  combination_method_ = config.combination_method;
240 }
241 
242 void ObstacleLayer::laserScanCallback(const sensor_msgs::LaserScanConstPtr& message,
244 {
245  // project the laser into a point cloud
246  sensor_msgs::PointCloud2 cloud;
247  cloud.header = message->header;
248 
249  // project the scan into a point cloud
250  try
251  {
252  projector_.transformLaserScanToPointCloud(message->header.frame_id, *message, cloud, *tf_);
253  }
254  catch (tf2::TransformException &ex)
255  {
256  ROS_WARN("High fidelity enabled, but TF returned a transform exception to frame %s: %s", global_frame_.c_str(),
257  ex.what());
258  projector_.projectLaser(*message, cloud);
259  }
260  catch (std::runtime_error &ex)
261  {
262  ROS_WARN("transformLaserScanToPointCloud error, it seems the message from laser sensor is malformed. Ignore this laser scan. what(): %s", ex.what());
263  return; //ignore this message
264  }
265 
266  // buffer the point cloud
267  buffer->lock();
268  buffer->bufferCloud(cloud);
269  buffer->unlock();
270 }
271 
272 void ObstacleLayer::laserScanValidInfCallback(const sensor_msgs::LaserScanConstPtr& raw_message,
274 {
275  // Filter positive infinities ("Inf"s) to max_range.
276  float epsilon = 0.0001; // a tenth of a millimeter
277  sensor_msgs::LaserScan message = *raw_message;
278  for (size_t i = 0; i < message.ranges.size(); i++)
279  {
280  float range = message.ranges[ i ];
281  if (!std::isfinite(range) && range > 0)
282  {
283  message.ranges[ i ] = message.range_max - epsilon;
284  }
285  }
286 
287  // project the laser into a point cloud
288  sensor_msgs::PointCloud2 cloud;
289  cloud.header = message.header;
290 
291  // project the scan into a point cloud
292  try
293  {
294  projector_.transformLaserScanToPointCloud(message.header.frame_id, message, cloud, *tf_);
295  }
296  catch (tf2::TransformException &ex)
297  {
298  ROS_WARN("High fidelity enabled, but TF returned a transform exception to frame %s: %s",
299  global_frame_.c_str(), ex.what());
300  projector_.projectLaser(message, cloud);
301  }
302  catch (std::runtime_error &ex)
303  {
304  ROS_WARN("transformLaserScanToPointCloud error, it seems the message from laser sensor is malformed. Ignore this laser scan. what(): %s", ex.what());
305  return; //ignore this message
306  }
307 
308  // buffer the point cloud
309  buffer->lock();
310  buffer->bufferCloud(cloud);
311  buffer->unlock();
312 }
313 
314 void ObstacleLayer::pointCloudCallback(const sensor_msgs::PointCloudConstPtr& message,
316 {
317  sensor_msgs::PointCloud2 cloud2;
318 
319  if (!sensor_msgs::convertPointCloudToPointCloud2(*message, cloud2))
320  {
321  ROS_ERROR("Failed to convert a PointCloud to a PointCloud2, dropping message");
322  return;
323  }
324 
325  // buffer the point cloud
326  buffer->lock();
327  buffer->bufferCloud(cloud2);
328  buffer->unlock();
329 }
330 
331 void ObstacleLayer::pointCloud2Callback(const sensor_msgs::PointCloud2ConstPtr& message,
333 {
334  // buffer the point cloud
335  buffer->lock();
336  buffer->bufferCloud(*message);
337  buffer->unlock();
338 }
339 
340 void ObstacleLayer::updateBounds(double robot_x, double robot_y, double robot_yaw, double* min_x,
341  double* min_y, double* max_x, double* max_y)
342 {
343  if (rolling_window_)
344  updateOrigin(robot_x - getSizeInMetersX() / 2, robot_y - getSizeInMetersY() / 2);
345  useExtraBounds(min_x, min_y, max_x, max_y);
346 
347  bool current = true;
348  std::vector<Observation> observations, clearing_observations;
349 
350  // get the marking observations
351  current = current && getMarkingObservations(observations);
352 
353  // get the clearing observations
354  current = current && getClearingObservations(clearing_observations);
355 
356  // update the global current status
357  current_ = current;
358 
359  // raytrace freespace
360  for (unsigned int i = 0; i < clearing_observations.size(); ++i)
361  {
362  raytraceFreespace(clearing_observations[i], min_x, min_y, max_x, max_y);
363  }
364 
365  // place the new obstacles into a priority queue... each with a priority of zero to begin with
366  for (std::vector<Observation>::const_iterator it = observations.begin(); it != observations.end(); ++it)
367  {
368  const Observation& obs = *it;
369 
370  const sensor_msgs::PointCloud2& cloud = *(obs.cloud_);
371 
372  double sq_obstacle_range = obs.obstacle_range_ * obs.obstacle_range_;
373 
377 
378  for (; iter_x !=iter_x.end(); ++iter_x, ++iter_y, ++iter_z)
379  {
380  double px = *iter_x, py = *iter_y, pz = *iter_z;
381 
382  // if the obstacle is too high or too far away from the robot we won't add it
383  if (pz > max_obstacle_height_)
384  {
385  ROS_DEBUG("The point is too high");
386  continue;
387  }
388 
389  // compute the squared distance from the hitpoint to the pointcloud's origin
390  double sq_dist = (px - obs.origin_.x) * (px - obs.origin_.x) + (py - obs.origin_.y) * (py - obs.origin_.y)
391  + (pz - obs.origin_.z) * (pz - obs.origin_.z);
392 
393  // if the point is far enough away... we won't consider it
394  if (sq_dist >= sq_obstacle_range)
395  {
396  ROS_DEBUG("The point is too far away");
397  continue;
398  }
399 
400  // now we need to compute the map coordinates for the observation
401  unsigned int mx, my;
402  if (!worldToMap(px, py, mx, my))
403  {
404  ROS_DEBUG("Computing map coords failed");
405  continue;
406  }
407 
408  unsigned int index = getIndex(mx, my);
409  costmap_[index] = LETHAL_OBSTACLE;
410  touch(px, py, min_x, min_y, max_x, max_y);
411  }
412  }
413 
414  updateFootprint(robot_x, robot_y, robot_yaw, min_x, min_y, max_x, max_y);
415 }
416 
417 void ObstacleLayer::updateFootprint(double robot_x, double robot_y, double robot_yaw, double* min_x, double* min_y,
418  double* max_x, double* max_y)
419 {
420  if (!footprint_clearing_enabled_) return;
421  transformFootprint(robot_x, robot_y, robot_yaw, getFootprint(), transformed_footprint_);
422 
423  for (unsigned int i = 0; i < transformed_footprint_.size(); i++)
424  {
425  touch(transformed_footprint_[i].x, transformed_footprint_[i].y, min_x, min_y, max_x, max_y);
426  }
427 }
428 
429 void ObstacleLayer::updateCosts(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j)
430 {
432  {
434  }
435 
436  switch (combination_method_)
437  {
438  case 0: // Overwrite
439  updateWithOverwrite(master_grid, min_i, min_j, max_i, max_j);
440  break;
441  case 1: // Maximum
442  updateWithMax(master_grid, min_i, min_j, max_i, max_j);
443  break;
444  default: // Nothing
445  break;
446  }
447 }
448 
449 void ObstacleLayer::addStaticObservation(costmap_2d::Observation& obs, bool marking, bool clearing)
450 {
451  if (marking)
452  static_marking_observations_.push_back(obs);
453  if (clearing)
454  static_clearing_observations_.push_back(obs);
455 }
456 
457 void ObstacleLayer::clearStaticObservations(bool marking, bool clearing)
458 {
459  if (marking)
461  if (clearing)
463 }
464 
465 bool ObstacleLayer::getMarkingObservations(std::vector<Observation>& marking_observations) const
466 {
467  bool current = true;
468  // get the marking observations
469  for (unsigned int i = 0; i < marking_buffers_.size(); ++i)
470  {
471  marking_buffers_[i]->lock();
472  marking_buffers_[i]->getObservations(marking_observations);
473  current = marking_buffers_[i]->isCurrent() && current;
474  marking_buffers_[i]->unlock();
475  }
476  marking_observations.insert(marking_observations.end(),
478  return current;
479 }
480 
481 bool ObstacleLayer::getClearingObservations(std::vector<Observation>& clearing_observations) const
482 {
483  bool current = true;
484  // get the clearing observations
485  for (unsigned int i = 0; i < clearing_buffers_.size(); ++i)
486  {
487  clearing_buffers_[i]->lock();
488  clearing_buffers_[i]->getObservations(clearing_observations);
489  current = clearing_buffers_[i]->isCurrent() && current;
490  clearing_buffers_[i]->unlock();
491  }
492  clearing_observations.insert(clearing_observations.end(),
494  return current;
495 }
496 
497 void ObstacleLayer::raytraceFreespace(const Observation& clearing_observation, double* min_x, double* min_y,
498  double* max_x, double* max_y)
499 {
500  double ox = clearing_observation.origin_.x;
501  double oy = clearing_observation.origin_.y;
502  const sensor_msgs::PointCloud2 &cloud = *(clearing_observation.cloud_);
503 
504  // get the map coordinates of the origin of the sensor
505  unsigned int x0, y0;
506  if (!worldToMap(ox, oy, x0, y0))
507  {
509  1.0, "The origin for the sensor at (%.2f, %.2f) is out of map bounds. So, the costmap cannot raytrace for it.",
510  ox, oy);
511  return;
512  }
513 
514  // we can pre-compute the enpoints of the map outside of the inner loop... we'll need these later
515  double origin_x = origin_x_, origin_y = origin_y_;
516  double map_end_x = origin_x + size_x_ * resolution_;
517  double map_end_y = origin_y + size_y_ * resolution_;
518 
519 
520  touch(ox, oy, min_x, min_y, max_x, max_y);
521 
522  // for each point in the cloud, we want to trace a line from the origin and clear obstacles along it
525 
526  for (; iter_x != iter_x.end(); ++iter_x, ++iter_y)
527  {
528  double wx = *iter_x;
529  double wy = *iter_y;
530 
531  // now we also need to make sure that the enpoint we're raytracing
532  // to isn't off the costmap and scale if necessary
533  double a = wx - ox;
534  double b = wy - oy;
535 
536  // the minimum value to raytrace from is the origin
537  if (wx < origin_x)
538  {
539  double t = (origin_x - ox) / a;
540  wx = origin_x;
541  wy = oy + b * t;
542  }
543  if (wy < origin_y)
544  {
545  double t = (origin_y - oy) / b;
546  wx = ox + a * t;
547  wy = origin_y;
548  }
549 
550  // the maximum value to raytrace to is the end of the map
551  if (wx > map_end_x)
552  {
553  double t = (map_end_x - ox) / a;
554  wx = map_end_x - .001;
555  wy = oy + b * t;
556  }
557  if (wy > map_end_y)
558  {
559  double t = (map_end_y - oy) / b;
560  wx = ox + a * t;
561  wy = map_end_y - .001;
562  }
563 
564  // now that the vector is scaled correctly... we'll get the map coordinates of its endpoint
565  unsigned int x1, y1;
566 
567  // check for legality just in case
568  if (!worldToMap(wx, wy, x1, y1))
569  continue;
570 
571  unsigned int cell_raytrace_range = cellDistance(clearing_observation.raytrace_range_);
572  MarkCell marker(costmap_, FREE_SPACE);
573  // and finally... we can execute our trace to clear obstacles along that line
574  raytraceLine(marker, x0, y0, x1, y1, cell_raytrace_range);
575 
576  updateRaytraceBounds(ox, oy, wx, wy, clearing_observation.raytrace_range_, min_x, min_y, max_x, max_y);
577  }
578 }
579 
581 {
582  // if we're stopped we need to re-subscribe to topics
583  for (unsigned int i = 0; i < observation_subscribers_.size(); ++i)
584  {
585  if (observation_subscribers_[i] != NULL)
586  observation_subscribers_[i]->subscribe();
587  }
588 
589  for (unsigned int i = 0; i < observation_buffers_.size(); ++i)
590  {
591  if (observation_buffers_[i])
592  observation_buffers_[i]->resetLastUpdated();
593  }
594 }
596 {
597  for (unsigned int i = 0; i < observation_subscribers_.size(); ++i)
598  {
599  if (observation_subscribers_[i] != NULL)
600  observation_subscribers_[i]->unsubscribe();
601  }
602 }
603 
604 void ObstacleLayer::updateRaytraceBounds(double ox, double oy, double wx, double wy, double range,
605  double* min_x, double* min_y, double* max_x, double* max_y)
606 {
607  double dx = wx-ox, dy = wy-oy;
608  double full_distance = hypot(dx, dy);
609  double scale = std::min(1.0, range / full_distance);
610  double ex = ox + dx * scale, ey = oy + dy * scale;
611  touch(ex, ey, min_x, min_y, max_x, max_y);
612 }
613 
615 {
616  deactivate();
617  resetMaps();
618  current_ = true;
619  activate();
620 }
621 
622 } // namespace costmap_2d
costmap_2d::Costmap2D::getSizeInMetersX
double getSizeInMetersX() const
Accessor for the x size of the costmap in meters.
Definition: costmap_2d.cpp:440
costmap_2d::ObstacleLayer::deactivate
virtual void deactivate()
Stop publishers.
Definition: obstacle_layer.cpp:595
costmap_2d::ObstacleLayer::getMarkingObservations
bool getMarkingObservations(std::vector< costmap_2d::Observation > &marking_observations) const
Get the observations used to mark space.
Definition: obstacle_layer.cpp:465
point_cloud2_iterator.h
costmap_2d::ObstacleLayer::raytraceFreespace
virtual void raytraceFreespace(const costmap_2d::Observation &clearing_observation, double *min_x, double *min_y, double *max_x, double *max_y)
Clear freespace based on one observation.
Definition: obstacle_layer.cpp:497
costmap_2d::ObstacleLayer::global_frame_
std::string global_frame_
The global frame for the costmap.
Definition: obstacle_layer.h:224
obstacle_layer.h
costmap_2d::CostmapLayer::updateWithMax
void updateWithMax(costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j)
Definition: costmap_layer.cpp:63
costmap_2d::Layer::tf_
tf2_ros::Buffer * tf_
Definition: layer.h:178
tf2_ros::MessageFilter
epsilon
double epsilon
costmap_2d::Observation::raytrace_range_
double raytrace_range_
Definition: observation.h:98
costmap_2d::ObstacleLayer::updateRaytraceBounds
void updateRaytraceBounds(double ox, double oy, double wx, double wy, double range, double *min_x, double *min_y, double *max_x, double *max_y)
Definition: obstacle_layer.cpp:604
boost::shared_ptr
costmap_2d::ObstacleLayer::static_clearing_observations_
std::vector< costmap_2d::Observation > static_clearing_observations_
Definition: obstacle_layer.h:236
costmap_2d::Layer::enabled_
bool enabled_
Definition: layer.h:176
PointCloud2IteratorBase< T, const T, const unsigned char, const sensor_msgs::PointCloud2, PointCloud2ConstIterator >::end
PointCloud2ConstIterator< T > end() const
costmap_2d::ObstacleLayer::updateCosts
virtual void updateCosts(costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j)
Actually update the underlying costmap, only within the bounds calculated during UpdateBounds().
Definition: obstacle_layer.cpp:429
costmap_2d::LayeredCostmap::isRolling
bool isRolling()
Definition: layered_costmap.h:133
costmap_2d::Costmap2D::worldToMap
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
Convert from world coordinates to map coordinates.
Definition: costmap_2d.cpp:208
costmap_2d::Costmap2D::MarkCell
Definition: costmap_2d.h:465
costmap_2d::Costmap2D::default_value_
unsigned char default_value_
Definition: costmap_2d.h:463
costmap_2d::Costmap2D::getSizeInMetersY
double getSizeInMetersY() const
Accessor for the y size of the costmap in meters.
Definition: costmap_2d.cpp:445
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
ROS_WARN_THROTTLE
#define ROS_WARN_THROTTLE(period,...)
costmap_2d::ObstacleLayer::updateBounds
virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double *min_x, double *min_y, double *max_x, double *max_y)
This is called by the LayeredCostmap to poll this plugin as to how much of the costmap it needs to up...
Definition: obstacle_layer.cpp:340
costmap_2d::NO_INFORMATION
static const unsigned char NO_INFORMATION
Definition: cost_values.h:77
costmap_2d::Costmap2D::origin_x_
double origin_x_
Definition: costmap_2d.h:460
costmap_2d::transformFootprint
void transformFootprint(double x, double y, double theta, const std::vector< geometry_msgs::Point > &footprint_spec, std::vector< geometry_msgs::Point > &oriented_footprint)
Given a pose and base footprint, build the oriented footprint of the robot (list of Points)
Definition: footprint.cpp:106
laser_geometry::LaserProjection::transformLaserScanToPointCloud
void transformLaserScanToPointCloud(const std::string &target_frame, const sensor_msgs::LaserScan &scan_in, sensor_msgs::PointCloud &cloud_out, tf::Transformer &tf, double range_cutoff, int channel_options=channel_option::Default)
costmap_2d::ObstacleLayer::static_marking_observations_
std::vector< costmap_2d::Observation > static_marking_observations_
Definition: obstacle_layer.h:236
costmap_2d::ObstacleLayer::reconfigureCB
void reconfigureCB(costmap_2d::ObstaclePluginConfig &config, uint32_t level)
Definition: obstacle_layer.cpp:234
costmap_2d::CostmapLayer::matchSize
virtual void matchSize()
Implement this to make this layer match the size of the parent costmap.
Definition: costmap_layer.cpp:14
costmap_2d::ObstacleLayer::observation_notifiers_
std::vector< boost::shared_ptr< tf2_ros::MessageFilterBase > > observation_notifiers_
Used to make sure that transforms are available for each sensor.
Definition: obstacle_layer.h:230
costmap_2d::Costmap2D
A 2D costmap provides a mapping between points in the world and their associated "costs".
Definition: costmap_2d.h:96
costmap_2d::ObstacleLayer::projector_
laser_geometry::LaserProjection projector_
Used to project laser scans into point clouds.
Definition: obstacle_layer.h:227
costmap_2d::CostmapLayer::updateWithOverwrite
void updateWithOverwrite(costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j)
Definition: costmap_layer.cpp:108
costmap_2d::ObstacleLayer::setupDynamicReconfigure
virtual void setupDynamicReconfigure(ros::NodeHandle &nh)
Definition: obstacle_layer.cpp:221
costmap_2d::Layer::name_
std::string name_
Definition: layer.h:177
costmap_2d::ObstacleLayer::addStaticObservation
void addStaticObservation(costmap_2d::Observation &obs, bool marking, bool clearing)
Definition: obstacle_layer.cpp:449
costmap_2d::Layer::current_
bool current_
Definition: layer.h:175
costmap_2d::LayeredCostmap::isTrackingUnknown
bool isTrackingUnknown()
Definition: layered_costmap.h:138
costmap_2d::Layer::layered_costmap_
LayeredCostmap * layered_costmap_
Definition: layer.h:174
sensor_msgs::PointCloud2ConstIterator
costmap_2d::ObstacleLayer::onInitialize
virtual void onInitialize()
This is called at the end of initialize(). Override to implement subclass-specific initialization.
Definition: obstacle_layer.cpp:57
costmap_2d::Observation::cloud_
sensor_msgs::PointCloud2 * cloud_
Definition: observation.h:97
message_filters::Subscriber
costmap_2d::ObstacleLayer::max_obstacle_height_
double max_obstacle_height_
Max Obstacle Height.
Definition: obstacle_layer.h:225
laser_geometry::LaserProjection::projectLaser
void projectLaser(const sensor_msgs::LaserScan &scan_in, sensor_msgs::PointCloud &cloud_out, double range_cutoff=-1.0, int channel_options=channel_option::Default)
costmap_2d::ObstacleLayer::marking_buffers_
std::vector< boost::shared_ptr< costmap_2d::ObservationBuffer > > marking_buffers_
Used to store observation buffers used for marking obstacles.
Definition: obstacle_layer.h:232
costmap_2d::ObstacleLayer::observation_subscribers_
std::vector< boost::shared_ptr< message_filters::SubscriberBase > > observation_subscribers_
Used for the observation message filters.
Definition: obstacle_layer.h:229
PLUGINLIB_EXPORT_CLASS
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
costmap_2d::ObstacleLayer::clearing_buffers_
std::vector< boost::shared_ptr< costmap_2d::ObservationBuffer > > clearing_buffers_
Used to store observation buffers used for clearing obstacles.
Definition: obstacle_layer.h:233
message_filter.h
ROS_DEBUG
#define ROS_DEBUG(...)
costmap_2d::ObstacleLayer::activate
virtual void activate()
Restart publishers if they've been stopped.
Definition: obstacle_layer.cpp:580
ros::NodeHandle::searchParam
bool searchParam(const std::string &key, std::string &result) const
costmap_2d::ObstacleLayer::combination_method_
int combination_method_
Definition: obstacle_layer.h:241
costmap_2d::ObstacleLayer::transformed_footprint_
std::vector< geometry_msgs::Point > transformed_footprint_
Definition: obstacle_layer.h:219
costmap_2d::Costmap2D::size_y_
unsigned int size_y_
Definition: costmap_2d.h:458
costmap_2d::ObstacleLayer
Definition: obstacle_layer.h:98
ROS_WARN
#define ROS_WARN(...)
costmap_2d::LETHAL_OBSTACLE
static const unsigned char LETHAL_OBSTACLE
Definition: cost_values.h:78
costmap_2d::Observation::obstacle_range_
double obstacle_range_
Definition: observation.h:98
costmap_2d::ObstacleLayer::~ObstacleLayer
virtual ~ObstacleLayer()
Definition: obstacle_layer.cpp:229
costmap_math.h
costmap_2d::Layer::getFootprint
const std::vector< geometry_msgs::Point > & getFootprint() const
Convenience function for layered_costmap_->getFootprint().
Definition: layer.cpp:51
ROS_FATAL
#define ROS_FATAL(...)
costmap_2d::ObstacleLayer::updateFootprint
void updateFootprint(double robot_x, double robot_y, double robot_yaw, double *min_x, double *min_y, double *max_x, double *max_y)
Definition: obstacle_layer.cpp:417
costmap_2d::CostmapLayer::useExtraBounds
void useExtraBounds(double *min_x, double *min_y, double *max_x, double *max_y)
Definition: costmap_layer.cpp:47
costmap_2d::Costmap2D::size_x_
unsigned int size_x_
Definition: costmap_2d.h:457
costmap_2d::CostmapLayer::touch
void touch(double x, double y, double *min_x, double *min_y, double *max_x, double *max_y)
Definition: costmap_layer.cpp:6
costmap_2d::Costmap2D::cellDistance
unsigned int cellDistance(double world_dist)
Given distance in the world... convert it to cells.
Definition: costmap_2d.cpp:181
costmap_2d::Costmap2D::resolution_
double resolution_
Definition: costmap_2d.h:459
costmap_2d::Observation
Stores an observation in terms of a point cloud and the origin of the source.
Definition: observation.h:46
costmap_2d::ObstacleLayer::laserScanValidInfCallback
void laserScanValidInfCallback(const sensor_msgs::LaserScanConstPtr &message, const boost::shared_ptr< ObservationBuffer > &buffer)
A callback to handle buffering LaserScan messages which need filtering to turn Inf values into range_...
Definition: obstacle_layer.cpp:272
costmap_2d::Costmap2D::resetMaps
virtual void resetMaps()
Resets the costmap and static_map to be unknown space.
Definition: costmap_2d.cpp:87
costmap_2d::ObstacleLayer::reset
virtual void reset()
Definition: obstacle_layer.cpp:614
ROS_ERROR
#define ROS_ERROR(...)
costmap_2d::Costmap2D::raytraceLine
void raytraceLine(ActionType at, unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int max_length=UINT_MAX)
Raytrace a line and apply some action at each step.
Definition: costmap_2d.h:396
class_list_macros.hpp
costmap_2d::ObstacleLayer::pointCloud2Callback
void pointCloud2Callback(const sensor_msgs::PointCloud2ConstPtr &message, const boost::shared_ptr< costmap_2d::ObservationBuffer > &buffer)
A callback to handle buffering PointCloud2 messages.
Definition: obstacle_layer.cpp:331
costmap_2d::ObstacleLayer::dsrv_
dynamic_reconfigure::Server< costmap_2d::ObstaclePluginConfig > * dsrv_
Definition: obstacle_layer.h:239
ros::NodeHandle::param
T param(const std::string &param_name, const T &default_val) const
costmap_2d::Costmap2D::origin_y_
double origin_y_
Definition: costmap_2d.h:461
costmap_2d::Layer
Definition: layer.h:84
costmap_2d::Observation::origin_
geometry_msgs::Point origin_
Definition: observation.h:96
costmap_2d::Costmap2D::updateOrigin
virtual void updateOrigin(double new_origin_x, double new_origin_y)
Move the origin of the costmap to a new location.... keeping data when it can.
Definition: costmap_2d.cpp:260
costmap_2d::Costmap2D::setConvexPolygonCost
bool setConvexPolygonCost(const std::vector< geometry_msgs::Point > &polygon, unsigned char cost_value)
Sets the cost of a convex polygon to a desired value.
Definition: costmap_2d.cpp:315
costmap_2d::Costmap2D::getIndex
unsigned int getIndex(unsigned int mx, unsigned int my) const
Given two map coordinates... compute the associated index.
Definition: costmap_2d.h:207
costmap_2d::Costmap2D::costmap_
unsigned char * costmap_
Definition: costmap_2d.h:462
costmap_2d::ObstacleLayer::pointCloudCallback
void pointCloudCallback(const sensor_msgs::PointCloudConstPtr &message, const boost::shared_ptr< costmap_2d::ObservationBuffer > &buffer)
A callback to handle buffering PointCloud messages.
Definition: obstacle_layer.cpp:314
costmap_2d::FREE_SPACE
static const unsigned char FREE_SPACE
Definition: cost_values.h:80
costmap_2d::LayeredCostmap::getGlobalFrameID
const std::string & getGlobalFrameID() const noexcept
Definition: layered_costmap.h:110
costmap_2d::ObstacleLayer::clearStaticObservations
void clearStaticObservations(bool marking, bool clearing)
Definition: obstacle_layer.cpp:457
tf2::TransformException
ROS_INFO
#define ROS_INFO(...)
costmap_2d::ObstacleLayer::footprint_clearing_enabled_
bool footprint_clearing_enabled_
Definition: obstacle_layer.h:220
costmap_2d
Definition: array_parser.h:37
ros::Duration
costmap_2d::ObstacleLayer::laserScanCallback
void laserScanCallback(const sensor_msgs::LaserScanConstPtr &message, const boost::shared_ptr< costmap_2d::ObservationBuffer > &buffer)
A callback to handle buffering LaserScan messages.
Definition: obstacle_layer.cpp:242
costmap_2d::ObservationBuffer
Takes in point clouds from sensors, transforms them to the desired frame, and stores them.
Definition: observation_buffer.h:93
t
geometry_msgs::TransformStamped t
costmap_2d::ObstacleLayer::observation_buffers_
std::vector< boost::shared_ptr< costmap_2d::ObservationBuffer > > observation_buffers_
Used to store observations from various sensors.
Definition: obstacle_layer.h:231
costmap_2d::ObstacleLayer::rolling_window_
bool rolling_window_
Definition: obstacle_layer.h:238
ros::NodeHandle
costmap_2d::ObstacleLayer::getClearingObservations
bool getClearingObservations(std::vector< costmap_2d::Observation > &clearing_observations) const
Get the observations used to clear space.
Definition: obstacle_layer.cpp:481
sensor_msgs::convertPointCloudToPointCloud2
static bool convertPointCloudToPointCloud2(const sensor_msgs::PointCloud &input, sensor_msgs::PointCloud2 &output)


costmap_2d
Author(s): Eitan Marder-Eppstein, David V. Lu!!, Dave Hershberger, contradict@gmail.com
autogenerated on Mon Mar 6 2023 03:50:17