distance_field.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2009, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /* Author: Mrinal Kalakrishnan, Ken Anderson, E. Gil Jones */
00036 
00037 #ifndef MOVEIT_DISTANCE_FIELD_DISTANCE_FIELD_
00038 #define MOVEIT_DISTANCE_FIELD_DISTANCE_FIELD_
00039 
00040 #include <moveit/distance_field/voxel_grid.h>
00041 #include <vector>
00042 #include <list>
00043 #include <visualization_msgs/Marker.h>
00044 #include <visualization_msgs/MarkerArray.h>
00045 #include <Eigen/Core>
00046 #include <Eigen/Geometry>
00047 #include <moveit_msgs/CollisionMap.h>
00048 #include <eigen_stl_containers/eigen_stl_containers.h>
00049 #include <geometric_shapes/shapes.h>
00050 
00058 namespace distance_field
00059 {
00060 
00062 enum PlaneVisualizationType
00063 {
00064  XYPlane,
00065  XZPlane,
00066  YZPlane
00067 };
00068 
00084 class DistanceField
00085 {
00086 public:
00087 
00100   DistanceField(double size_x, double size_y, double size_z, double resolution,
00101                 double origin_x, double origin_y, double origin_z);
00102 
00103   virtual ~DistanceField();
00104 
00112   virtual void addPointsToField(const EigenSTL::vector_Vector3d &points)=0;
00113 
00127   virtual void removePointsFromField(const EigenSTL::vector_Vector3d &points)=0;
00128 
00152   virtual void updatePointsInField(const EigenSTL::vector_Vector3d& old_points,
00153                                    const EigenSTL::vector_Vector3d& new_points) = 0;
00154 
00173   void addShapeToField(const shapes::Shape* shape,
00174                        const geometry_msgs::Pose& pose);
00175 
00189   void addOcTreeToField(const octomap::OcTree* octree);
00190 
00209   void moveShapeInField(const shapes::Shape* shape,
00210                         const geometry_msgs::Pose& old_pose,
00211                         const geometry_msgs::Pose& new_pose);
00212 
00222   void removeShapeFromField(const shapes::Shape* shape,
00223                             const geometry_msgs::Pose& pose);
00224 
00229   virtual void reset()=0;
00230 
00250   virtual double getDistance(double x, double y, double z) const = 0;
00251 
00299   double getDistanceGradient(double x, double y, double z,
00300                              double& gradient_x, double& gradient_y, double& gradient_z,
00301                              bool& in_bounds) const;
00313   virtual double getDistance(int x, int y, int z) const = 0;
00314 
00325   virtual bool isCellValid(int x, int y, int z) const = 0;
00326 
00333   virtual int getXNumCells() const = 0;
00334 
00341   virtual int getYNumCells() const = 0;
00342 
00349   virtual int getZNumCells() const = 0;
00350 
00363   virtual bool gridToWorld(int x, int y, int z,
00364                            double& world_x, double& world_y, double& world_z) const = 0;
00365 
00382   virtual bool worldToGrid(double world_x, double world_y, double world_z,
00383                            int& x, int& y, int& z) const = 0;
00384 
00392   virtual bool writeToStream(std::ostream& stream) const = 0;
00393 
00403   virtual bool readFromStream(std::istream& stream) = 0;
00404 
00418   void getIsoSurfaceMarkers(double min_distance,
00419                             double max_distance,
00420                             const std::string &frame_id,
00421                             const ros::Time stamp,
00422                             visualization_msgs::Marker& marker ) const;
00423 
00424 
00425 
00439   void getGradientMarkers(double min_radius,
00440                           double max_radius,
00441                           const std::string& frame_id,
00442                           const ros::Time& stamp,
00443                           visualization_msgs::MarkerArray& marker_array) const;
00444 
00470   void getPlaneMarkers(PlaneVisualizationType type,
00471                        double length,
00472                        double width,
00473                        double height,
00474                        const Eigen::Vector3d& origin,
00475                        const std::string & frame_id,
00476                        const ros::Time stamp,
00477                        visualization_msgs::Marker& marker) const;
00494   void getProjectionPlanes(const std::string& frame_id,
00495                            const ros::Time& stamp,
00496                            double max_distance,
00497                            visualization_msgs::Marker& marker) const;
00498 
00505   double getSizeX() const
00506   {
00507     return size_x_;
00508   }
00509 
00516   double getSizeY() const
00517   {
00518     return size_y_;
00519   }
00520 
00527   double getSizeZ() const
00528   {
00529     return size_z_;
00530   }
00531 
00538   double getOriginX() const
00539   {
00540     return origin_x_;
00541   }
00542 
00549   double getOriginY() const
00550   {
00551     return origin_y_;
00552   }
00553 
00560   double getOriginZ() const
00561   {
00562     return origin_z_;
00563   }
00564 
00571   double getResolution() const {
00572     return resolution_;
00573   }
00574 
00581   virtual double getUninitializedDistance() const = 0;
00582 
00583 protected:
00598   void setPoint(int xCell, int yCell, int zCell,
00599                 double dist,
00600                 geometry_msgs::Point& point,
00601                 std_msgs::ColorRGBA& color,
00602                 double max_distance) const;
00603 
00604   double size_x_;               
00605   double size_y_;               
00606   double size_z_;               
00607   double origin_x_;             
00608   double origin_y_;             
00609   double origin_z_;             
00610   double resolution_;           
00611   int inv_twice_resolution_;    
00612 };
00613 
00614 }
00615 #endif


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Mon Oct 6 2014 02:24:46