00001
00002
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef OCTOMAP_ROS_H_
00041 #define OCTOMAP_ROS_H_
00042
00043
00044 #include <sensor_msgs/PointCloud2.h>
00045 #include <pcl/point_cloud.h>
00046 #include <pcl/point_types.h>
00047 #include <pcl/ros/conversions.h>
00048 #include <tf/transform_datatypes.h>
00049
00050 #include <geometry_msgs/Point.h>
00051 #include <geometry_msgs/Vector3.h>
00052 #include <octomap/octomap.h>
00053 #include <octomap_ros/conversions.h>
00054
00055 #pragma message("DEPRECATION WARNING: OctomapROS.h is deprecated and will disappear soon. Use the OctoMap library and octomap_ros/conversions.h directly instead.")
00056
00057 namespace octomap {
00058
00059
00066 template <class OctreeT>
00067 class OctomapROS {
00068 public:
00069 OctomapROS(double resolution) __attribute__ ((deprecated));
00070 OctomapROS(OctreeT tree) __attribute__ ((deprecated));
00071 virtual ~OctomapROS() {}
00072
00083 template <class PointT>
00084 void insertScan(const sensor_msgs::PointCloud2& scan, const PointT& origin,
00085 double maxrange=-1., bool pruning=true, bool dirty=false);
00086
00096 template <class PCLPointT, class PointT>
00097 void insertScan(const pcl::PointCloud<PCLPointT>& scan, const PointT& origin,
00098 double maxrange=-1., bool pruning=true, bool dirty=false);
00099
00111 template <class PCLPointT, class PCLQuaternionT>
00112 void insertScan(const pcl::PointCloud<PCLPointT>& scan, const PCLPointT& sensor_origin,
00113 const PCLPointT& frame_origin_trans, const PCLQuaternionT& frame_origin_rot,
00114 double maxrange=-1., bool pruning=true, bool dirty=false);
00115
00116
00117
00118
00133 template <class PointT>
00134 bool castRay(const PointT& origin, const PointT& direction, PointT& end,
00135 bool ignoreUnknownCells = false, double maxRange = -1.0) const;
00136
00147 template <class PointT>
00148 bool insertRay(const PointT& origin, const PointT& end, double maxRange = -1.0);
00149
00150
00158 template <class PointT>
00159 typename OctreeT::NodeType* search(const PointT& point) const;
00160
00161 typename OctreeT::NodeType* search(const tf::Point& point) const;
00162
00163 OctreeT octree;
00164
00165 typedef OctreeT OcTreeType;
00166 typedef typename OctreeT::NodeType NodeType;
00167 };
00168
00175 typedef OctomapROS<OcTree> OcTreeROS;
00176
00177
00178
00179
00180
00181
00182
00183 template <class OctreeT>
00184 OctomapROS<OctreeT>::OctomapROS(double resolution)
00185 : octree(resolution)
00186 {
00187
00188 }
00189
00190
00191
00192 template <class OctreeT>
00193 template <class PCLPointT, class PointT>
00194 void OctomapROS<OctreeT>::insertScan(const pcl::PointCloud<PCLPointT>& scan, const PointT& origin,
00195 double maxrange, bool pruning, bool dirty){
00196
00197 Pointcloud pc;
00198 pointcloudPCLToOctomap(scan, pc);
00199
00200 octree.insertScan(pc, point3d(origin.x, origin.y, origin.z), maxrange, pruning, dirty);
00201
00202 }
00203
00204
00205 template <class OctreeT>
00206 template <class PCLPointT, class PCLQuaternionT>
00207 void OctomapROS<OctreeT>::insertScan(const pcl::PointCloud<PCLPointT>& scan, const PCLPointT& sensor_origin,
00208 const PCLPointT& frame_origin_trans, const PCLQuaternionT& frame_origin_rot, double maxrange, bool pruning, bool dirty)
00209 {
00210
00211 Pointcloud pc;
00212 pointcloudPCLToOctomap(scan, pc);
00213
00214 pose6d frame_origin;
00215 frame_origin.trans() = point3d(frame_origin_trans.x, frame_origin_trans.y, frame_origin_trans.z);
00216 frame_origin.rot() = octomath::Quaternion(frame_origin_rot.w(),
00217 frame_origin_rot.x(), frame_origin_rot.y(), frame_origin_rot.z());
00218 octree.insertScan(pc, point3d(sensor_origin.x, sensor_origin.y, sensor_origin.z), frame_origin,
00219 maxrange, pruning, dirty);
00220
00221 }
00222
00223
00224 template <class OctreeT>
00225 template <class PointT>
00226 void OctomapROS<OctreeT>::insertScan(const sensor_msgs::PointCloud2& scan, const PointT& origin,
00227 double maxrange, bool pruning, bool dirty){
00228
00229
00230 pcl::PointCloud<pcl::PointXYZ> pc;
00231 pcl::fromROSMsg(scan, pc);
00232 insertScan(pc, origin, maxrange, pruning, dirty);
00233
00234 }
00235
00236 template <class OctreeT>
00237 template <class PointT>
00238 bool OctomapROS<OctreeT>::insertRay(const PointT& origin, const PointT& end, double maxRange){
00239
00240 return octree.insertRay(point3d(origin.x, origin.y, origin.z),
00241 point3d(end.x, end.y, end.z),maxRange);
00242
00243 }
00244
00245 template <class OctreeT>
00246 template <class PointT>
00247 bool OctomapROS<OctreeT>::castRay(const PointT& origin, const PointT& direction,
00248 PointT& end, bool ignoreUnknownCells, double maxRange) const{
00249
00250 point3d ptEnd;
00251 bool result = octree.castRay(point3d(origin.x, origin.y, origin.z), point3d(direction.x, direction.y, direction.z),
00252 ptEnd, ignoreUnknownCells, maxRange);
00253
00254 end.x = ptEnd.x();
00255 end.y = ptEnd.y();
00256 end.z = ptEnd.z();
00257
00258 return result;
00259 }
00260
00261
00262 template <class OctreeT>
00263 template <class PointT>
00264 typename OctreeT::NodeType* OctomapROS<OctreeT>::search(const PointT& point) const{
00265 return octree.search(point.x, point.y, point.z);
00266 }
00267
00268 template <class OctreeT>
00269 typename OctreeT::NodeType* OctomapROS<OctreeT>::search(const tf::Point& point) const{
00270 return octree.search(point.x(), point.y(), point.z());
00271 }
00272
00273 }
00274
00275 #endif