00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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 #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