collision_robot_distance_field.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: E. Gil Jones */
36 
37 #ifndef MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_ROBOT_DISTANCE_FIELD_
38 #define MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_ROBOT_DISTANCE_FIELD_
39 
45 #include <boost/thread/mutex.hpp>
46 
47 namespace collision_detection
48 {
49 static const double DEFAULT_SIZE_X = 3.0;
50 static const double DEFAULT_SIZE_Y = 3.0;
51 static const double DEFAULT_SIZE_Z = 4.0;
52 static const bool DEFAULT_USE_SIGNED_DISTANCE_FIELD = false;
53 static const double DEFAULT_RESOLUTION = .02;
54 static const double DEFAULT_COLLISION_TOLERANCE = 0.0;
55 static const double DEFAULT_MAX_PROPOGATION_DISTANCE = .25;
56 
58 
60 {
62 
63 public:
65 
66  CollisionRobotDistanceField(const robot_model::RobotModelConstPtr& robot_model);
67 
68  CollisionRobotDistanceField(const CollisionRobot& col_robot, const Eigen::Vector3d& size,
69  const Eigen::Vector3d& origin, bool use_signed_distance_field, double resolution,
70  double collision_tolerance, double max_propogation_distance, double padding);
71 
72  CollisionRobotDistanceField(const robot_model::RobotModelConstPtr& robot_model,
73  const std::map<std::string, std::vector<CollisionSphere>>& link_body_decompositions,
74  double size_x = DEFAULT_SIZE_X, double size_y = DEFAULT_SIZE_Y,
75  double size_z = DEFAULT_SIZE_Z,
76  bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD,
77  double resolution = DEFAULT_RESOLUTION,
78  double collision_tolerance = DEFAULT_COLLISION_TOLERANCE,
79  double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE, double padding = 0.0,
80  double scale = 1.0);
81 
83 
84  void initialize(const std::map<std::string, std::vector<CollisionSphere>>& link_body_decompositions,
85  const Eigen::Vector3d& size, const Eigen::Vector3d& origin, bool use_signed_distance_field,
86  double resolution, double collision_tolerance, double max_propogation_distance);
87 
89  const moveit::core::RobotState& state) const override;
90 
92  const moveit::core::RobotState& state, GroupStateRepresentationPtr& gsr) const;
93 
95  const moveit::core::RobotState& state,
96  const collision_detection::AllowedCollisionMatrix& acm) const override;
97 
100  GroupStateRepresentationPtr& gsr) const;
101 
103  const moveit::core::RobotState& state1, const moveit::core::RobotState& state2) const override
104  {
105  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
106  };
107 
109  const moveit::core::RobotState& state1, const moveit::core::RobotState& state2,
110  const collision_detection::AllowedCollisionMatrix& acm) const override
111  {
112  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
113  };
114 
116  const moveit::core::RobotState& state, const CollisionRobot& other_robot,
117  const moveit::core::RobotState& other_state) const override
118  {
119  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
120  };
121 
123  const moveit::core::RobotState& state, const CollisionRobot& other_robot,
124  const moveit::core::RobotState& other_state,
125  const collision_detection::AllowedCollisionMatrix& acm) const override
126  {
127  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
128  };
129 
131  const moveit::core::RobotState& state1, const moveit::core::RobotState& state2,
132  const CollisionRobot& other_robot, const moveit::core::RobotState& other_state1,
133  const moveit::core::RobotState& other_state2) const override
134  {
135  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
136  };
137 
139  const moveit::core::RobotState& state1, const moveit::core::RobotState& state2,
140  const CollisionRobot& other_robot, const moveit::core::RobotState& other_state1,
141  const moveit::core::RobotState& other_state2,
142  const collision_detection::AllowedCollisionMatrix& acm) const override
143  {
144  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
145  };
146 
148  visualization_msgs::MarkerArray& model_markers) const;
149 
150  virtual double distanceSelf(const moveit::core::RobotState& state) const
151  {
152  return 0.0;
153  };
154  virtual double distanceSelf(const moveit::core::RobotState& state,
156  {
157  return 0.0;
158  };
159  virtual double distanceOther(const moveit::core::RobotState& state, const CollisionRobot& other_robot,
160  const moveit::core::RobotState& other_state) const
161  {
162  return 0.0;
163  };
164  virtual double distanceOther(const moveit::core::RobotState& state, const CollisionRobot& other_robot,
165  const moveit::core::RobotState& other_state,
167  {
168  return 0.0;
169  };
170 
172  const robot_state::RobotState& state) const override
173  {
174  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
175  }
176 
178  const CollisionRobot& other_robot, const robot_state::RobotState& other_state) const override
179  {
180  ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
181  }
182 
183  DistanceFieldCacheEntryConstPtr getLastDistanceFieldEntry() const
184  {
186  }
187 
188  // void getSelfCollisionsGradients(const collision_detection::CollisionRequest
189  // &req,
190  // collision_detection::CollisionResult &res,
191  // const moveit::core::RobotState &state,
192  // const
193  // collision_detection::AllowedCollisionMatrix
194  // &acm) const;
195 protected:
196  bool getSelfProximityGradients(GroupStateRepresentationPtr& gsr) const;
197 
198  bool getIntraGroupProximityGradients(GroupStateRepresentationPtr& gsr) const;
199 
201  GroupStateRepresentationPtr& gsr) const;
202 
204  collision_detection::CollisionResult& res, GroupStateRepresentationPtr& gsr) const;
205 
209  GroupStateRepresentationPtr& gsr) const;
210 
212  GroupStateRepresentationPtr& gsr) const;
213 
214  void generateCollisionCheckingStructures(const std::string& group_name, const moveit::core::RobotState& state,
216  GroupStateRepresentationPtr& gsr, bool generate_distance_field) const;
217 
218  DistanceFieldCacheEntryConstPtr
219  getDistanceFieldCacheEntry(const std::string& group_name, const moveit::core::RobotState& state,
221 
222  DistanceFieldCacheEntryPtr generateDistanceFieldCacheEntry(const std::string& group_name,
223  const moveit::core::RobotState& state,
225  bool generate_distance_field) const;
226 
228 
229  void addLinkBodyDecompositions(double resolution,
230  const std::map<std::string, std::vector<CollisionSphere>>& link_body_decompositions);
231 
232  PosedBodySphereDecompositionPtr getPosedLinkBodySphereDecomposition(const moveit::core::LinkModel* ls,
233  unsigned int ind) const;
234 
235  PosedBodyPointDecompositionPtr getPosedLinkBodyPointDecomposition(const moveit::core::LinkModel* ls) const;
236 
237  void getGroupStateRepresentation(const DistanceFieldCacheEntryConstPtr& dfce, const moveit::core::RobotState& state,
238  GroupStateRepresentationPtr& gsr) const;
239 
240  bool compareCacheEntryToState(const DistanceFieldCacheEntryConstPtr& dfce,
241  const moveit::core::RobotState& state) const;
242 
243  bool compareCacheEntryToAllowedCollisionMatrix(const DistanceFieldCacheEntryConstPtr& dfce,
245 
246  void updatedPaddingOrScaling(const std::vector<std::string>& links) override{};
247 
251  double resolution_;
254 
255  std::vector<BodyDecompositionConstPtr> link_body_decomposition_vector_;
256  std::map<std::string, unsigned int> link_body_decomposition_index_map_;
257 
258  mutable boost::mutex update_cache_lock_;
259  DistanceFieldCacheEntryPtr distance_field_cache_entry_;
260  std::map<std::string, std::map<std::string, bool>> in_group_update_map_;
261  std::map<std::string, GroupStateRepresentationPtr> pregenerated_group_state_representation_map_;
262 
263  planning_scene::PlanningScenePtr planning_scene_;
264 };
265 }
266 
267 #endif
void checkSelfCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state) const override
Check for self collision. Any collision between any pair of links is checked for, NO collisions are i...
void checkSelfCollisionHelper(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state, const collision_detection::AllowedCollisionMatrix *acm, GroupStateRepresentationPtr &gsr) const
Core components of MoveIt!
static const double DEFAULT_RESOLUTION
bool compareCacheEntryToState(const DistanceFieldCacheEntryConstPtr &dfce, const moveit::core::RobotState &state) const
Vec3fX< details::Vec3Data< double > > Vector3d
Definition: fcl_compat.h:90
void checkSelfCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state1, const moveit::core::RobotState &state2) const override
Check for self collision in a continuous manner. Any collision between any pair of links is checked f...
void checkOtherCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state, const CollisionRobot &other_robot, const moveit::core::RobotState &other_state, const collision_detection::AllowedCollisionMatrix &acm) const override
Check for collision with a different robot (possibly a different kinematic model as well)...
bool getSelfCollisions(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, GroupStateRepresentationPtr &gsr) const
void createCollisionModelMarker(const moveit::core::RobotState &state, visualization_msgs::MarkerArray &model_markers) const
void initialize(const std::map< std::string, std::vector< CollisionSphere >> &link_body_decompositions, const Eigen::Vector3d &size, const Eigen::Vector3d &origin, bool use_signed_distance_field, double resolution, double collision_tolerance, double max_propogation_distance)
MOVEIT_CLASS_FORWARD(AllowedCollisionMatrix)
std::map< std::string, unsigned int > link_body_decomposition_index_map_
void distanceOther(const DistanceRequest &req, DistanceResult &res, const robot_state::RobotState &state, const CollisionRobot &other_robot, const robot_state::RobotState &other_state) const override
The distance to self-collision given the robot is at state state.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW CollisionRobotDistanceField(const robot_model::RobotModelConstPtr &robot_model)
void checkOtherCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state1, const moveit::core::RobotState &state2, const CollisionRobot &other_robot, const moveit::core::RobotState &other_state1, const moveit::core::RobotState &other_state2) const override
Check for collision with a different robot (possibly a different kinematic model as well)...
PosedBodyPointDecompositionPtr getPosedLinkBodyPointDecomposition(const moveit::core::LinkModel *ls) const
DistanceFieldCacheEntryPtr generateDistanceFieldCacheEntry(const std::string &group_name, const moveit::core::RobotState &state, const collision_detection::AllowedCollisionMatrix *acm, bool generate_distance_field) const
static const double DEFAULT_MAX_PROPOGATION_DISTANCE
Generic interface to collision detection.
PosedBodySphereDecompositionPtr getPosedLinkBodySphereDecomposition(const moveit::core::LinkModel *ls, unsigned int ind) const
void updateGroupStateRepresentationState(const moveit::core::RobotState &state, GroupStateRepresentationPtr &gsr) const
static const double DEFAULT_COLLISION_TOLERANCE
static const double resolution
virtual double distanceOther(const moveit::core::RobotState &state, const CollisionRobot &other_robot, const moveit::core::RobotState &other_state, const collision_detection::AllowedCollisionMatrix &acm) const
virtual double distanceOther(const moveit::core::RobotState &state, const CollisionRobot &other_robot, const moveit::core::RobotState &other_state) const
bool getIntraGroupProximityGradients(GroupStateRepresentationPtr &gsr) const
std::map< std::string, std::map< std::string, bool > > in_group_update_map_
Definition of a structure for the allowed collision matrix. All elements in the collision world are r...
void checkOtherCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state1, const moveit::core::RobotState &state2, const CollisionRobot &other_robot, const moveit::core::RobotState &other_state1, const moveit::core::RobotState &other_state2, const collision_detection::AllowedCollisionMatrix &acm) const override
Check for collision with a different robot (possibly a different kinematic model as well)...
This class represents a collision model of the robot and can be used for self collision checks (to ch...
ROS/KDL based interface for the inverse kinematics of the PR2 arm.
void updatedPaddingOrScaling(const std::vector< std::string > &links) override
When the scale or padding is changed for a set of links by any of the functions in this class...
bool getIntraGroupCollisions(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, GroupStateRepresentationPtr &gsr) const
void distanceSelf(const DistanceRequest &req, DistanceResult &res, const robot_state::RobotState &state) const override
The distance to self-collision given the robot is at state state.
void checkOtherCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state, const CollisionRobot &other_robot, const moveit::core::RobotState &other_state) const override
Check for collision with a different robot (possibly a different kinematic model as well)...
virtual double distanceSelf(const moveit::core::RobotState &state) const
void checkSelfCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res, const moveit::core::RobotState &state1, const moveit::core::RobotState &state2, const collision_detection::AllowedCollisionMatrix &acm) const override
Check for self collision. Allowed collisions specified by the allowed collision matrix are taken into...
bool compareCacheEntryToAllowedCollisionMatrix(const DistanceFieldCacheEntryConstPtr &dfce, const collision_detection::AllowedCollisionMatrix &acm) const
bool getSelfProximityGradients(GroupStateRepresentationPtr &gsr) const
std::vector< BodyDecompositionConstPtr > link_body_decomposition_vector_
virtual double distanceSelf(const moveit::core::RobotState &state, const collision_detection::AllowedCollisionMatrix &acm) const
static const bool DEFAULT_USE_SIGNED_DISTANCE_FIELD
#define ROS_ERROR_NAMED(name,...)
Representation of a robot&#39;s state. This includes position, velocity, acceleration and effort...
Definition: robot_state.h:123
DistanceFieldCacheEntryConstPtr getLastDistanceFieldEntry() const
A link from the robot. Contains the constant transform applied to the link and its geometry...
Definition: link_model.h:72
std::map< std::string, GroupStateRepresentationPtr > pregenerated_group_state_representation_map_
void generateCollisionCheckingStructures(const std::string &group_name, const moveit::core::RobotState &state, const collision_detection::AllowedCollisionMatrix *acm, GroupStateRepresentationPtr &gsr, bool generate_distance_field) const
DistanceFieldCacheEntryConstPtr getDistanceFieldCacheEntry(const std::string &group_name, const moveit::core::RobotState &state, const collision_detection::AllowedCollisionMatrix *acm) const
void getGroupStateRepresentation(const DistanceFieldCacheEntryConstPtr &dfce, const moveit::core::RobotState &state, GroupStateRepresentationPtr &gsr) const


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Sun Apr 14 2019 02:52:24