“ 作者在读源代码时,遇到了下述的代码raytraceFreespace,不是很好理解,有很多疑惑,于是打算对此部分进行详解,并记下笔记。”void ObstacleLayer::raytraceFreespace(const Observation& clearing_observation, double* min_x, double* min_y, double* max_x, double* max_y){ clearing_observation的origin_是传感器坐标,传入 double ox = clearing_observation.origin_.x; double oy = clearing_observation.origin_.y; pcl::PointCloud cloud = *(clearing_observation.cloud_); //得到传感器原点在地图上的坐标 // get the map coordinates of the origin of the sensor unsigned int x0, y0; if (!worldToMap(ox, oy, x0, y0)) { ROS_WARN_THROTTLE( 1.0, "The origin for the sensor at (%.2f, %.2f) is out of map bounds. So, the costmap cannot raytrace for it.", ox, oy); return; } // we can pre-compute the enpoints of the map outside of the inner loop... we'll need these later
………………………………