planning_scene.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2011, 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 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: Ioan Sucan, Acorn Pooley */
00036 
00037 #ifndef MOVEIT_PLANNING_SCENE_PLANNING_SCENE_
00038 #define MOVEIT_PLANNING_SCENE_PLANNING_SCENE_
00039 
00040 #include <moveit/robot_model/robot_model.h>
00041 #include <moveit/robot_state/robot_state.h>
00042 #include <moveit/transforms/transforms.h>
00043 #include <moveit/collision_detection/collision_detector_allocator.h>
00044 #include <moveit/collision_detection/world_diff.h>
00045 #include <moveit/kinematic_constraints/kinematic_constraint.h>
00046 #include <moveit/kinematics_base/kinematics_base.h>
00047 #include <moveit/robot_trajectory/robot_trajectory.h>
00048 #include <moveit/macros/deprecation.h>
00049 #include <moveit_msgs/PlanningScene.h>
00050 #include <moveit_msgs/RobotTrajectory.h>
00051 #include <moveit_msgs/Constraints.h>
00052 #include <moveit_msgs/PlanningSceneComponents.h>
00053 #include <boost/enable_shared_from_this.hpp>
00054 #include <boost/noncopyable.hpp>
00055 #include <boost/shared_ptr.hpp>
00056 #include <boost/function.hpp>
00057 #include <boost/concept_check.hpp>
00058 
00060 namespace planning_scene
00061 {
00062 
00063 class PlanningScene;
00064 typedef boost::shared_ptr<PlanningScene> PlanningScenePtr;
00065 typedef boost::shared_ptr<const PlanningScene> PlanningSceneConstPtr;
00066 
00069 typedef boost::function<bool(const robot_state::RobotState&, bool)> StateFeasibilityFn;
00070 
00074 typedef boost::function<bool(const robot_state::RobotState&, const robot_state::RobotState&, bool)> MotionFeasibilityFn;
00075 
00077 typedef std::map<std::string, std_msgs::ColorRGBA> ObjectColorMap;
00078 
00080 typedef std::map<std::string, object_recognition_msgs::ObjectType> ObjectTypeMap;
00081 
00085 class PlanningScene : private boost::noncopyable,
00086                       public boost::enable_shared_from_this<PlanningScene>
00087 {
00088 public:
00089 
00091   PlanningScene(const robot_model::RobotModelConstPtr &robot_model,
00092                 collision_detection::WorldPtr world = collision_detection::WorldPtr(new collision_detection::World()));
00093 
00096   PlanningScene(const boost::shared_ptr<const urdf::ModelInterface> &urdf_model,
00097                 const boost::shared_ptr<const srdf::Model> &srdf_model,
00098                 collision_detection::WorldPtr world = collision_detection::WorldPtr(new collision_detection::World()));
00099 
00100   static const std::string OCTOMAP_NS;
00101   static const std::string DEFAULT_SCENE_NAME;
00102 
00103   ~PlanningScene();
00104 
00106   const std::string& getName() const
00107   {
00108     return name_;
00109   }
00110 
00112   void setName(const std::string &name)
00113   {
00114     name_ = name;
00115   }
00116 
00129   PlanningScenePtr diff() const;
00130 
00133   PlanningScenePtr diff(const moveit_msgs::PlanningScene &msg) const;
00134 
00136   const PlanningSceneConstPtr& getParent() const
00137   {
00138     return parent_;
00139   }
00140 
00142   const robot_model::RobotModelConstPtr& getRobotModel() const
00143   {
00144     // the kinematic model does not change
00145     return kmodel_;
00146   }
00147 
00149   const robot_state::RobotState& getCurrentState() const
00150   {
00151     // if we have an updated state, return it; otherwise, return the parent one
00152     return kstate_ ? *kstate_ : parent_->getCurrentState();
00153   }
00155   robot_state::RobotState& getCurrentStateNonConst();
00156 
00158   robot_state::RobotStatePtr getCurrentStateUpdated(const moveit_msgs::RobotState &update) const;
00159 
00166   const std::string& getPlanningFrame() const
00167   {
00168     // if we have an updated set of transforms, return it; otherwise, return the parent one
00169     return ftf_ ? ftf_->getTargetFrame() : parent_->getPlanningFrame();
00170   }
00171 
00173   const robot_state::Transforms& getTransforms() const
00174   {
00175     // if we have updated transforms, return those
00176     return (ftf_ || !parent_) ? *ftf_ : parent_->getTransforms();
00177   }
00178 
00180   const robot_state::Transforms& getTransforms();
00181   
00183   robot_state::Transforms& getTransformsNonConst();
00184 
00187   const Eigen::Affine3d& getFrameTransform(const std::string &id) const;
00188 
00192   const Eigen::Affine3d& getFrameTransform(const std::string &id);
00193 
00197   const Eigen::Affine3d& getFrameTransform(robot_state::RobotState &state, const std::string &id) const
00198   {
00199     state.updateLinkTransforms();
00200     return getFrameTransform(const_cast<const robot_state::RobotState&>(state), id);
00201   }
00202   
00205   const Eigen::Affine3d& getFrameTransform(const robot_state::RobotState &state, const std::string &id) const;
00206   
00208   bool knowsFrameTransform(const std::string &id) const;
00209 
00211   bool knowsFrameTransform(const robot_state::RobotState &state, const std::string &id) const;
00212 
00237   void addCollisionDetector(const collision_detection::CollisionDetectorAllocatorPtr& allocator);
00238 
00248   void setActiveCollisionDetector(const collision_detection::CollisionDetectorAllocatorPtr& allocator,
00249                                   bool exclusive = false);
00250 
00257   bool setActiveCollisionDetector(const std::string& collision_detector_name);
00258 
00259   const std::string& getActiveCollisionDetectorName() const
00260   {
00261     return active_collision_->alloc_->getName();
00262   }
00263 
00266   void getCollisionDetectorNames(std::vector<std::string>& names) const;
00267 
00269   const collision_detection::WorldConstPtr& getWorld() const
00270   {
00271     // we always have a world representation
00272     return world_const_;
00273   }
00274 
00275   //brief Get the representation of the world
00276   const collision_detection::WorldPtr& getWorldNonConst()
00277   {
00278     // we always have a world representation
00279     return world_;
00280   }
00281 
00283   const collision_detection::CollisionWorldConstPtr& getCollisionWorld() const
00284   {
00285     // we always have a world representation after configure is called.
00286     return active_collision_->cworld_const_;
00287   }
00288 
00290   const collision_detection::CollisionRobotConstPtr& getCollisionRobot() const
00291   {
00292     return active_collision_->getCollisionRobot();
00293   }
00294 
00296   const collision_detection::CollisionRobotConstPtr& getCollisionRobotUnpadded() const
00297   {
00298     return active_collision_->getCollisionRobotUnpadded();
00299   }
00300 
00302   const collision_detection::CollisionWorldConstPtr& getCollisionWorld(const std::string& collision_detector_name) const;
00303 
00305   const collision_detection::CollisionRobotConstPtr& getCollisionRobot(const std::string& collision_detector_name) const;
00306 
00308   const collision_detection::CollisionRobotConstPtr& getCollisionRobotUnpadded(const std::string& collision_detector_name) const;
00309 
00314   const collision_detection::CollisionRobotPtr& getCollisionRobotNonConst();
00315 
00319   void propogateRobotPadding();
00320 
00322   const collision_detection::AllowedCollisionMatrix& getAllowedCollisionMatrix() const
00323   {
00324     return acm_ ? *acm_ : parent_->getAllowedCollisionMatrix();
00325   }
00327   collision_detection::AllowedCollisionMatrix& getAllowedCollisionMatrixNonConst();
00328 
00339   bool isStateColliding(const std::string &group = "", bool verbose = false);
00340 
00343   bool isStateColliding(const std::string &group = "", bool verbose = false) const
00344   {
00345     return isStateColliding(getCurrentState(), group, verbose);
00346   }
00347   
00350   bool isStateColliding(robot_state::RobotState &state, const std::string &group = "", bool verbose = false) const
00351   {
00352     state.updateCollisionBodyTransforms();
00353     return isStateColliding(const_cast<const robot_state::RobotState&>(state), group, verbose);
00354   }
00355 
00359   bool isStateColliding(const robot_state::RobotState &state, const std::string &group = "", bool verbose = false) const;
00360 
00363   bool isStateColliding(const moveit_msgs::RobotState &state, const std::string &group = "", bool verbose = false) const;
00364 
00366   void checkCollision(const collision_detection::CollisionRequest& req,
00367                       collision_detection::CollisionResult &res);
00368   
00370   void checkCollision(const collision_detection::CollisionRequest& req,
00371                       collision_detection::CollisionResult &res) const
00372   {
00373     checkCollision(req, res, getCurrentState());
00374   }
00375   
00378   void checkCollision(const collision_detection::CollisionRequest& req,
00379                       collision_detection::CollisionResult &res,
00380                       robot_state::RobotState &kstate) const
00381   {
00382     kstate.updateCollisionBodyTransforms();
00383     checkCollision(req, res, const_cast<const robot_state::RobotState&>(kstate));
00384   }
00385 
00387   void checkCollision(const collision_detection::CollisionRequest& req,
00388                       collision_detection::CollisionResult &res,
00389                       const robot_state::RobotState &kstate) const;
00390   
00394   void checkCollision(const collision_detection::CollisionRequest& req,
00395                       collision_detection::CollisionResult &res,
00396                       robot_state::RobotState &kstate,
00397                       const collision_detection::AllowedCollisionMatrix& acm) const
00398   {
00399     kstate.updateCollisionBodyTransforms();
00400     checkCollision(req, res, const_cast<const robot_state::RobotState&>(kstate), acm);
00401   }
00402 
00405   void checkCollision(const collision_detection::CollisionRequest& req,
00406                       collision_detection::CollisionResult &res,
00407                       const robot_state::RobotState &kstate,
00408                       const collision_detection::AllowedCollisionMatrix& acm) const;
00409 
00413   void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
00414                               collision_detection::CollisionResult &res);
00415   
00418   void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
00419                               collision_detection::CollisionResult &res) const
00420   {
00421     checkCollisionUnpadded(req, res, getCurrentState(), getAllowedCollisionMatrix());
00422   }
00423   
00426   void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
00427                               collision_detection::CollisionResult &res,
00428                               const robot_state::RobotState &kstate) const
00429   {
00430     checkCollisionUnpadded(req, res, kstate, getAllowedCollisionMatrix());
00431   }
00432 
00436   void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
00437                               collision_detection::CollisionResult &res,
00438                               robot_state::RobotState &kstate) const
00439   {
00440     kstate.updateCollisionBodyTransforms();
00441     checkCollisionUnpadded(req, res, const_cast<const robot_state::RobotState&>(kstate), getAllowedCollisionMatrix());
00442   }
00443   
00447   void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
00448                               collision_detection::CollisionResult &res,
00449                               robot_state::RobotState &kstate,
00450                               const collision_detection::AllowedCollisionMatrix& acm) const
00451   {
00452     kstate.updateCollisionBodyTransforms();
00453     checkCollisionUnpadded(req, res, const_cast<const robot_state::RobotState&>(kstate), acm);
00454   }
00455 
00458   void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
00459                               collision_detection::CollisionResult &res,
00460                               const robot_state::RobotState &kstate,
00461                               const collision_detection::AllowedCollisionMatrix& acm) const;
00462 
00464   void checkSelfCollision(const collision_detection::CollisionRequest& req,
00465                           collision_detection::CollisionResult &res);
00466   
00468   void checkSelfCollision(const collision_detection::CollisionRequest& req,
00469                           collision_detection::CollisionResult &res) const
00470   {
00471     checkSelfCollision(req, res, getCurrentState());
00472   }
00473 
00475   void checkSelfCollision(const collision_detection::CollisionRequest& req,
00476                           collision_detection::CollisionResult &res,
00477                           robot_state::RobotState &kstate) const
00478   { 
00479     kstate.updateCollisionBodyTransforms();
00480     checkSelfCollision(req, res, const_cast<const robot_state::RobotState&>(kstate), getAllowedCollisionMatrix());
00481   }
00482   
00484   void checkSelfCollision(const collision_detection::CollisionRequest& req,
00485                           collision_detection::CollisionResult &res,
00486                           const robot_state::RobotState &kstate) const
00487   {
00488     // do self-collision checking with the unpadded version of the robot
00489     getCollisionRobotUnpadded()->checkSelfCollision(req, res, kstate, getAllowedCollisionMatrix());
00490   }
00491 
00494   void checkSelfCollision(const collision_detection::CollisionRequest& req,
00495                           collision_detection::CollisionResult &res,
00496                           robot_state::RobotState &kstate,
00497                           const collision_detection::AllowedCollisionMatrix& acm) const
00498   {
00499     kstate.updateCollisionBodyTransforms();
00500     checkSelfCollision(req, res, const_cast<const robot_state::RobotState&>(kstate), acm);
00501   }
00502 
00505   void checkSelfCollision(const collision_detection::CollisionRequest& req,
00506                           collision_detection::CollisionResult &res,
00507                           const robot_state::RobotState &kstate,
00508                           const collision_detection::AllowedCollisionMatrix& acm) const
00509   {
00510     // do self-collision checking with the unpadded version of the robot
00511     getCollisionRobotUnpadded()->checkSelfCollision(req, res, kstate, acm);
00512   }
00513 
00515   void getCollidingLinks(std::vector<std::string> &links);
00516   
00518   void getCollidingLinks(std::vector<std::string> &links) const
00519   {
00520     getCollidingLinks(links, getCurrentState(), getAllowedCollisionMatrix());
00521   }
00522   
00525   void getCollidingLinks(std::vector<std::string> &links, robot_state::RobotState &kstate) const
00526   {
00527     kstate.updateCollisionBodyTransforms();
00528     getCollidingLinks(links, const_cast<const robot_state::RobotState&>(kstate), getAllowedCollisionMatrix());
00529   }
00530 
00532   void getCollidingLinks(std::vector<std::string> &links, const robot_state::RobotState &kstate) const
00533   {
00534     getCollidingLinks(links, kstate, getAllowedCollisionMatrix());
00535   }
00536 
00539   void getCollidingLinks(std::vector<std::string> &links,
00540                          robot_state::RobotState &kstate,
00541                          const collision_detection::AllowedCollisionMatrix& acm) const
00542   {   
00543     kstate.updateCollisionBodyTransforms();
00544     getCollidingLinks(links, const_cast<const robot_state::RobotState&>(kstate), acm);
00545   }
00546   
00549   void getCollidingLinks(std::vector<std::string> &links,
00550                          const robot_state::RobotState &kstate,
00551                          const collision_detection::AllowedCollisionMatrix& acm) const;
00552   
00555   void getCollidingPairs(collision_detection::CollisionResult::ContactMap &contacts);
00556   
00558   void getCollidingPairs(collision_detection::CollisionResult::ContactMap &contacts) const
00559   {
00560     getCollidingPairs(contacts, getCurrentState(), getAllowedCollisionMatrix());
00561   }
00562   
00564   void getCollidingPairs(collision_detection::CollisionResult::ContactMap &contacts,
00565                          const robot_state::RobotState &kstate) const
00566   {
00567     getCollidingPairs(contacts, kstate, getAllowedCollisionMatrix());
00568   }
00569 
00572   void getCollidingPairs(collision_detection::CollisionResult::ContactMap &contacts,
00573                          robot_state::RobotState &kstate) const
00574   { 
00575     kstate.updateCollisionBodyTransforms();
00576     getCollidingPairs(contacts, const_cast<const robot_state::RobotState&>(kstate), getAllowedCollisionMatrix());
00577   }
00578 
00581   void getCollidingPairs(collision_detection::CollisionResult::ContactMap &contacts,
00582                          robot_state::RobotState &kstate,
00583                          const collision_detection::AllowedCollisionMatrix& acm) const
00584   { 
00585     kstate.updateCollisionBodyTransforms();
00586     getCollidingPairs(contacts, const_cast<const robot_state::RobotState&>(kstate), acm);
00587   }
00588   
00591   void getCollidingPairs(collision_detection::CollisionResult::ContactMap &contacts,
00592                          const robot_state::RobotState &kstate,
00593                          const collision_detection::AllowedCollisionMatrix& acm) const;
00594 
00603   double distanceToCollision(robot_state::RobotState &kstate) const
00604   {
00605     kstate.updateCollisionBodyTransforms();
00606     return distanceToCollision(const_cast<const robot_state::RobotState&>(kstate));
00607   }  
00608   
00610   double distanceToCollision(const robot_state::RobotState &kstate) const
00611   {
00612     return getCollisionWorld()->distanceRobot(*getCollisionRobot(), kstate, getAllowedCollisionMatrix());
00613   }  
00614   
00616   double distanceToCollisionUnpadded(robot_state::RobotState &kstate) const
00617   {
00618     kstate.updateCollisionBodyTransforms();
00619     return distanceToCollisionUnpadded(const_cast<const robot_state::RobotState&>(kstate));
00620   }
00621   
00623   double distanceToCollisionUnpadded(const robot_state::RobotState &kstate) const
00624   {
00625     return getCollisionWorld()->distanceRobot(*getCollisionRobotUnpadded(), kstate, getAllowedCollisionMatrix());
00626   }
00627   
00629   double distanceToCollision(robot_state::RobotState &kstate, const collision_detection::AllowedCollisionMatrix& acm) const
00630   {
00631     kstate.updateCollisionBodyTransforms();
00632     return distanceToCollision(const_cast<const robot_state::RobotState&>(kstate), acm);
00633   }
00634 
00636   double distanceToCollision(const robot_state::RobotState &kstate, const collision_detection::AllowedCollisionMatrix& acm) const
00637   {
00638     return getCollisionWorld()->distanceRobot(*getCollisionRobot(), kstate, acm);
00639   }
00640   
00642   double distanceToCollisionUnpadded(robot_state::RobotState &kstate, const collision_detection::AllowedCollisionMatrix& acm) const
00643   {
00644     kstate.updateCollisionBodyTransforms();
00645     return distanceToCollisionUnpadded(const_cast<const robot_state::RobotState&>(kstate), acm);
00646   }
00647 
00649   double distanceToCollisionUnpadded(const robot_state::RobotState &kstate, const collision_detection::AllowedCollisionMatrix& acm) const
00650   {
00651     return getCollisionWorld()->distanceRobot(*getCollisionRobotUnpadded(), kstate, acm);
00652   }
00653   
00657   void saveGeometryToStream(std::ostream &out) const;
00658   
00660   void loadGeometryFromStream(std::istream &in);
00661   
00664   void getPlanningSceneDiffMsg(moveit_msgs::PlanningScene &scene) const;
00665 
00668   void getPlanningSceneMsg(moveit_msgs::PlanningScene &scene) const;
00669 
00672   void getPlanningSceneMsg(moveit_msgs::PlanningScene &scene, const moveit_msgs::PlanningSceneComponents &comp) const;
00673 
00677   void setPlanningSceneDiffMsg(const moveit_msgs::PlanningScene &scene);
00678 
00680   void setPlanningSceneMsg(const moveit_msgs::PlanningScene &scene);
00681 
00683   void usePlanningSceneMsg(const moveit_msgs::PlanningScene &scene);
00684 
00685   bool processCollisionObjectMsg(const moveit_msgs::CollisionObject &object);
00686   bool processAttachedCollisionObjectMsg(const moveit_msgs::AttachedCollisionObject &object);
00687 
00688   void processPlanningSceneWorldMsg(const moveit_msgs::PlanningSceneWorld &world);
00689 
00690   void processOctomapMsg(const octomap_msgs::OctomapWithPose &map);
00691   void processOctomapMsg(const octomap_msgs::Octomap &map);
00692   void processOctomapPtr(const boost::shared_ptr<const octomap::OcTree> &octree, const Eigen::Affine3d &t);
00693 
00697   void setCurrentState(const moveit_msgs::RobotState &state);
00698 
00700   void setCurrentState(const robot_state::RobotState &state);
00701 
00703   void setAttachedBodyUpdateCallback(const robot_state::AttachedBodyCallback &callback);
00704 
00706   void setCollisionObjectUpdateCallback(const collision_detection::World::ObserverCallbackFn &callback);
00707 
00708   bool hasObjectColor(const std::string &id) const;
00709 
00710   const std_msgs::ColorRGBA& getObjectColor(const std::string &id) const;
00711   void setObjectColor(const std::string &id, const std_msgs::ColorRGBA &color);
00712   void removeObjectColor(const std::string &id);
00713   void getKnownObjectColors(ObjectColorMap &kc) const;
00714 
00715   bool hasObjectType(const std::string &id) const;
00716 
00717   const object_recognition_msgs::ObjectType& getObjectType(const std::string &id) const;
00718   void setObjectType(const std::string &id, const object_recognition_msgs::ObjectType &type);
00719   void removeObjectType(const std::string &id);
00720   void getKnownObjectTypes(ObjectTypeMap &kc) const;
00721 
00723   void clearDiffs();
00724 
00727   void pushDiffs(const PlanningScenePtr &scene);
00728 
00732   void decoupleParent();
00733 
00736   void setStateFeasibilityPredicate(const StateFeasibilityFn &fn)
00737   {
00738     state_feasibility_ = fn;
00739   }
00740 
00742   const StateFeasibilityFn& getStateFeasibilityPredicate() const
00743   {
00744     return state_feasibility_;
00745   }
00746 
00748   void setMotionFeasibilityPredicate(const MotionFeasibilityFn &fn)
00749   {
00750     motion_feasibility_ = fn;
00751   }
00752 
00754   const MotionFeasibilityFn& getMotionFeasibilityPredicate() const
00755   {
00756     return motion_feasibility_;
00757   }
00758 
00760   bool isStateFeasible(const moveit_msgs::RobotState &state, bool verbose = false) const;
00761 
00763   bool isStateFeasible(const robot_state::RobotState &state, bool verbose = false) const;
00764 
00766   bool isStateConstrained(const moveit_msgs::RobotState &state, const moveit_msgs::Constraints &constr, bool verbose = false) const;
00767 
00769   bool isStateConstrained(const robot_state::RobotState &state, const moveit_msgs::Constraints &constr, bool verbose = false) const;
00770 
00772   bool isStateConstrained(const moveit_msgs::RobotState &state,  const kinematic_constraints::KinematicConstraintSet &constr, bool verbose = false) const;
00773 
00775   bool isStateConstrained(const robot_state::RobotState &state,  const kinematic_constraints::KinematicConstraintSet &constr, bool verbose = false) const;
00776 
00778   bool isStateValid(const moveit_msgs::RobotState &state, const std::string &group = "", bool verbose = false) const;
00779 
00781   bool isStateValid(const robot_state::RobotState &state, const std::string &group = "", bool verbose = false) const;
00782 
00784   bool isStateValid(const moveit_msgs::RobotState &state, const moveit_msgs::Constraints &constr, const std::string &group = "", bool verbose = false) const;
00785 
00787   bool isStateValid(const robot_state::RobotState &state, const moveit_msgs::Constraints &constr, const std::string &group = "", bool verbose = false) const;
00788 
00790   bool isStateValid(const robot_state::RobotState &state, const kinematic_constraints::KinematicConstraintSet &constr, const std::string &group = "", bool verbose = false) const;
00791 
00793   bool isPathValid(const moveit_msgs::RobotState &start_state,
00794                    const moveit_msgs::RobotTrajectory &trajectory,
00795                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00796 
00798   bool isPathValid(const moveit_msgs::RobotState &start_state,
00799                    const moveit_msgs::RobotTrajectory &trajectory,
00800                    const moveit_msgs::Constraints& path_constraints,
00801                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00802 
00804   bool isPathValid(const moveit_msgs::RobotState &start_state,
00805                    const moveit_msgs::RobotTrajectory &trajectory,
00806                    const moveit_msgs::Constraints& path_constraints,
00807                    const moveit_msgs::Constraints& goal_constraints,
00808                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00809 
00811   bool isPathValid(const moveit_msgs::RobotState &start_state,
00812                    const moveit_msgs::RobotTrajectory &trajectory,
00813                    const moveit_msgs::Constraints& path_constraints,
00814                    const std::vector<moveit_msgs::Constraints>& goal_constraints,
00815                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00816 
00818   bool isPathValid(const robot_trajectory::RobotTrajectory &trajectory,
00819                    const moveit_msgs::Constraints& path_constraints,
00820                    const std::vector<moveit_msgs::Constraints>& goal_constraints,
00821                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00822 
00824   bool isPathValid(const robot_trajectory::RobotTrajectory &trajectory,
00825                    const moveit_msgs::Constraints& path_constraints,
00826                    const moveit_msgs::Constraints& goal_constraints,
00827                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00828 
00830   bool isPathValid(const robot_trajectory::RobotTrajectory &trajectory,
00831                    const moveit_msgs::Constraints& path_constraints,
00832                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00833 
00835   bool isPathValid(const robot_trajectory::RobotTrajectory &trajectory,
00836                    const std::string &group = "", bool verbose = false, std::vector<std::size_t> *invalid_index = NULL) const;
00837 
00839   void getCostSources(const robot_trajectory::RobotTrajectory &trajectory, std::size_t max_costs,
00840                       std::set<collision_detection::CostSource> &costs, double overlap_fraction = 0.9) const;
00841 
00843   void getCostSources(const robot_trajectory::RobotTrajectory &trajectory, std::size_t max_costs,
00844                       const std::string &group_name, std::set<collision_detection::CostSource> &costs, double overlap_fraction = 0.9) const;
00845 
00847   void getCostSources(const robot_state::RobotState &state, std::size_t max_costs,
00848                       std::set<collision_detection::CostSource> &costs) const;
00849 
00851   void getCostSources(const robot_state::RobotState &state, std::size_t max_costs,
00852                       const std::string &group_name, std::set<collision_detection::CostSource> &costs) const;
00853 
00855   void printKnownObjects(std::ostream& out) const;
00856 
00858   static bool isEmpty(const moveit_msgs::PlanningScene &msg);
00859 
00861   static bool isEmpty(const moveit_msgs::PlanningSceneWorld &msg);
00862 
00864   static bool isEmpty(const moveit_msgs::RobotState &msg);
00865 
00867   static PlanningScenePtr clone(const PlanningSceneConstPtr &scene);
00868 
00869 private:
00870 
00871   /* Private constructor used by the diff() methods. */
00872   PlanningScene(const PlanningSceneConstPtr &parent);
00873 
00874   /* Initialize the scene.  This should only be called by the constructors.
00875    * Requires a valid robot_model_ */
00876   void initialize();
00877 
00878   /* helper function to create a RobotModel from a urdf/srdf. */
00879   static robot_model::RobotModelPtr createRobotModel(const boost::shared_ptr<const urdf::ModelInterface> &urdf_model,
00880                                                      const boost::shared_ptr<const srdf::Model> &srdf_model);
00881 
00882   void getPlanningSceneMsgCollisionObject(moveit_msgs::PlanningScene &scene, const std::string &ns) const;
00883   void getPlanningSceneMsgCollisionObjects(moveit_msgs::PlanningScene &scene) const;
00884   void getPlanningSceneMsgOctomap(moveit_msgs::PlanningScene &scene) const;
00885   void getPlanningSceneMsgObjectColors(moveit_msgs::PlanningScene &scene_msg) const;
00886 
00887   struct CollisionDetector;
00888   typedef boost::shared_ptr<CollisionDetector> CollisionDetectorPtr;
00889   typedef boost::shared_ptr<const CollisionDetector> CollisionDetectorConstPtr;
00890 
00891   /* \brief A set of compatible collision detectors */
00892   struct CollisionDetector
00893   {
00894     collision_detection::CollisionDetectorAllocatorPtr alloc_;
00895     collision_detection::CollisionRobotPtr             crobot_unpadded_;        // if NULL use parent's
00896     collision_detection::CollisionRobotConstPtr        crobot_unpadded_const_;
00897     collision_detection::CollisionRobotPtr             crobot_;                 // if NULL use parent's
00898     collision_detection::CollisionRobotConstPtr        crobot_const_;
00899 
00900     collision_detection::CollisionWorldPtr             cworld_;                 // never NULL
00901     collision_detection::CollisionWorldConstPtr        cworld_const_;
00902 
00903     CollisionDetectorConstPtr                          parent_;                 // may be NULL
00904 
00905     const collision_detection::CollisionRobotConstPtr& getCollisionRobot() const
00906     {
00907       return crobot_const_ ? crobot_const_ : parent_->getCollisionRobot();
00908     }
00909     const collision_detection::CollisionRobotConstPtr& getCollisionRobotUnpadded() const
00910     {
00911       return crobot_unpadded_const_ ? crobot_unpadded_const_ : parent_->getCollisionRobotUnpadded();
00912     }
00913     void findParent(const PlanningScene& scene);
00914     void copyPadding(const CollisionDetector& src);
00915   };
00916   friend struct CollisionDetector;
00917 
00918   typedef std::map<std::string, CollisionDetectorPtr>::iterator CollisionDetectorIterator;
00919   typedef std::map<std::string, CollisionDetectorPtr>::const_iterator CollisionDetectorConstIterator;
00920 
00921   void allocateCollisionDetectors();
00922   void allocateCollisionDetectors(CollisionDetector& detector);
00923 
00924 
00925 
00926   std::string                                    name_;         // may be empty
00927 
00928   PlanningSceneConstPtr                          parent_;       // Null unless this is a diff scene
00929 
00930   robot_model::RobotModelConstPtr                kmodel_;       // Never null (may point to same model as parent)
00931 
00932   robot_state::RobotStatePtr                     kstate_;       // if NULL use parent's
00933   robot_state::AttachedBodyCallback              current_state_attached_body_callback_; // called when changes are made to attached bodies
00934 
00935   robot_state::TransformsPtr                     ftf_;          // if NULL use parent's
00936 
00937   collision_detection::WorldPtr                  world_;        // never NULL, never shared with parent/child
00938   collision_detection::WorldConstPtr             world_const_;  // copy of world_
00939   collision_detection::WorldDiffPtr              world_diff_;   // NULL unless this is a diff scene
00940   collision_detection::World::ObserverCallbackFn current_world_object_update_callback_;
00941   collision_detection::World::ObserverHandle     current_world_object_update_observer_handle_;
00942 
00943   std::map<std::string, CollisionDetectorPtr>    collision_;          // never empty
00944   CollisionDetectorPtr                           active_collision_;   // copy of one of the entries in collision_.  Never NULL.
00945 
00946   collision_detection::AllowedCollisionMatrixPtr acm_;                // if NULL use parent's
00947 
00948   StateFeasibilityFn                             state_feasibility_;
00949   MotionFeasibilityFn                            motion_feasibility_;
00950 
00951   boost::scoped_ptr<ObjectColorMap>              object_colors_;
00952 
00953   // a map of object types
00954   boost::scoped_ptr<ObjectTypeMap>               object_types_;
00955 
00956 
00957 };
00958 
00959 }
00960 
00961 
00962 #endif


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Thu Aug 27 2015 13:58:53