joint_model_group.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2012, 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, Inc. 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 */
00036 
00037 #ifndef MOVEIT_ROBOT_MODEL_JOINT_MODEL_GROUP_
00038 #define MOVEIT_ROBOT_MODEL_JOINT_MODEL_GROUP_
00039 
00040 #include <moveit/robot_model/joint_model.h>
00041 #include <moveit/robot_model/link_model.h>
00042 #include <moveit/kinematics_base/kinematics_base.h>
00043 #include <boost/function.hpp>
00044 #include <set>
00045 
00046 namespace robot_model
00047 {
00048 
00049 class RobotModel;
00050 class JointModelGroup;
00051 
00053 typedef boost::function<kinematics::KinematicsBasePtr(const JointModelGroup*)> SolverAllocatorFn;
00054 
00056 typedef std::map<const JointModelGroup*, SolverAllocatorFn> SolverAllocatorMapFn;
00057 
00058 class JointModelGroup
00059 {
00060   friend class RobotModel;
00061 
00062 public:
00063 
00064   JointModelGroup(const std::string& name, const std::vector<const JointModel*>& joint_vector, const RobotModel *parent_model);
00065 
00066   ~JointModelGroup();
00067 
00069   const RobotModel* getParentModel() const
00070   {
00071     return parent_model_;
00072   }
00073 
00075   const std::string& getName() const
00076   {
00077     return name_;
00078   }
00079 
00081   bool hasJointModel(const std::string &joint) const;
00082 
00084   bool hasLinkModel(const std::string &link) const;
00085 
00087   const JointModel* getJointModel(const std::string &joint) const;
00088 
00090   const LinkModel* getLinkModel(const std::string &joint) const;
00091 
00094   const std::vector<const JointModel*>& getJointModels() const
00095   {
00096     return joint_model_vector_;
00097   }
00098 
00100   const std::vector<std::string>& getJointModelNames() const
00101   {
00102     return joint_model_name_vector_;
00103   }
00104 
00106   const std::vector<const JointModel*>& getFixedJointModels() const
00107   {
00108     return fixed_joints_;
00109   }
00110 
00112   const std::vector<const JointModel*>& getMimicJointModels() const
00113   {
00114     return mimic_joints_;
00115   }
00116 
00118   const std::vector<const JointModel*>& getContinuousJointModels() const
00119   {
00120     return continuous_joint_model_vector_const_;
00121   }
00122 
00126   const std::vector<std::string>& getVariableNames() const
00127   {
00128     return active_variable_names_;
00129   }
00130 
00138   const std::vector<const JointModel*>& getJointRoots() const
00139   {
00140     return joint_roots_;
00141   }
00142 
00144   const std::vector<const LinkModel*>& getLinkModels() const
00145   {
00146     return link_model_vector_;
00147   }
00148 
00150   const std::vector<std::string>& getLinkModelNames() const
00151   {
00152     return link_model_name_vector_;
00153   }
00154 
00156   const std::vector<std::string>& getLinkModelNamesWithCollisionGeometry() const
00157   {
00158     return link_model_with_geometry_name_vector_;
00159   }
00160 
00164   const std::vector<const LinkModel*>& getUpdatedLinkModels() const
00165   {
00166     return updated_link_model_vector_;
00167   }
00168 
00170   const std::vector<std::string>& getUpdatedLinkModelNames() const
00171   {
00172     return updated_link_model_name_vector_;
00173   }
00174 
00178   const std::vector<const LinkModel*>& getUpdatedLinkModelsWithGeometry() const
00179   {
00180     return updated_link_model_with_geometry_vector_;
00181   }
00182 
00184   const std::set<const LinkModel*>& getUpdatedLinkModelsWithGeometrySet() const
00185   {
00186     return updated_link_model_with_geometry_set_;
00187   }
00188 
00190   const std::vector<std::string>& getUpdatedLinkModelsWithGeometryNames() const
00191   {
00192     return updated_link_model_with_geometry_name_vector_;
00193   }
00194 
00196   const std::set<std::string>& getUpdatedLinkModelsWithGeometryNamesSet() const
00197   {
00198     return updated_link_model_with_geometry_name_set_;
00199   }
00200 
00204   bool isLinkUpdated(const std::string &name) const
00205   {
00206     return updated_link_model_name_set_.find(name) != updated_link_model_name_set_.end();
00207   }
00208 
00211   bool isActiveDOF(const std::string &name) const
00212   {
00213     return active_variable_names_set_.find(name) != active_variable_names_set_.end();
00214   }
00215 
00219   const std::map<std::string, unsigned int>& getJointVariablesIndexMap() const
00220   {
00221     return joint_variables_index_map_;
00222   }
00223 
00225   void getKnownDefaultStates(std::vector<std::string> &default_states) const;
00226 
00228   bool getVariableDefaultValues(const std::string &name, std::map<std::string, double> &values) const;
00229 
00231   void getVariableDefaultValues(std::vector<double> &values) const;
00232 
00234   void getVariableDefaultValues(std::map<std::string, double> &values) const;
00235 
00237   void getVariableRandomValues(random_numbers::RandomNumberGenerator &rng, std::vector<double> &values) const;
00238 
00240   void getVariableRandomValuesNearBy(random_numbers::RandomNumberGenerator &rng, std::vector<double> &values, const std::vector<double> &near, const std::map<robot_model::JointModel::JointType, double> &distance_map) const;
00241 
00243   void getVariableRandomValuesNearBy(random_numbers::RandomNumberGenerator &rng, std::vector<double> &values, const std::vector<double> &near, const std::vector<double> &distances) const;
00244 
00246   unsigned int getVariableCount() const
00247   {
00248     return variable_count_;
00249   }
00250 
00252   const std::vector<std::string>& getSubgroupNames() const
00253   {
00254     return subgroup_names_;
00255   }
00256 
00258   bool isSubgroup(const std::string& group) const;
00259 
00261   bool isChain() const
00262   {
00263     return is_chain_;
00264   }
00265 
00267   bool isEndEffector() const
00268   {
00269     return is_end_effector_;
00270   }
00271 
00273   const std::string& getEndEffectorName() const
00274   {
00275     return end_effector_name_;
00276   }
00277 
00279   const std::pair<std::string, std::string>& getEndEffectorParentGroup() const
00280   {
00281     return end_effector_parent_;
00282   }
00283 
00285   const std::vector<std::string>& getAttachedEndEffectorNames() const
00286   {
00287     return attached_end_effector_names_;
00288   }
00289 
00291   double getMaximumExtent(void) const;
00292 
00294   std::vector<moveit_msgs::JointLimits> getVariableDefaultLimits() const;
00295 
00297   std::vector<moveit_msgs::JointLimits> getVariableLimits() const;
00298 
00300   void setVariableLimits(const std::vector<moveit_msgs::JointLimits>& jlim);
00301 
00302   const std::pair<SolverAllocatorFn, SolverAllocatorMapFn>& getSolverAllocators() const
00303   {
00304     return solver_allocators_;
00305   }
00306 
00307   void setSolverAllocators(const SolverAllocatorFn &solver, const SolverAllocatorMapFn &solver_map = SolverAllocatorMapFn())
00308   {
00309     setSolverAllocators(std::make_pair(solver, solver_map));
00310   }
00311 
00312   void setSolverAllocators(const std::pair<SolverAllocatorFn, SolverAllocatorMapFn> &solvers);
00313 
00314   const kinematics::KinematicsBaseConstPtr& getSolverInstance() const
00315   {
00316     return solver_instance_const_;
00317   }
00318 
00319   const kinematics::KinematicsBasePtr& getSolverInstance()
00320   {
00321     return solver_instance_;
00322   }
00323 
00324   bool canSetStateFromIK(const std::string &tip) const;
00325 
00326   bool setRedundantJoints(const std::vector<unsigned int> &joints)
00327   {
00328     if(solver_instance_)
00329       return (solver_instance_->setRedundantJoints(joints));
00330     return false;
00331   }
00332 
00334   double getDefaultIKTimeout() const
00335   {
00336     return default_ik_timeout_;
00337   }
00338 
00340   void setDefaultIKTimeout(double ik_timeout);
00341 
00343   unsigned int getDefaultIKAttempts() const
00344   {
00345     return default_ik_attempts_;
00346   }
00347 
00349   void setDefaultIKAttempts(unsigned int ik_attempts)
00350   {
00351     default_ik_attempts_ = ik_attempts;
00352   }
00353 
00355   const std::vector<unsigned int>& getKinematicsSolverJointBijection() const
00356   {
00357     return ik_joint_bijection_;
00358   }
00359 
00361   void printGroupInfo(std::ostream &out = std::cout) const;
00362 
00363 protected:
00364 
00366   const RobotModel                                 *parent_model_;
00367 
00369   std::string                                           name_;
00370 
00372   std::vector<std::string>                              joint_model_name_vector_;
00373 
00375   std::vector<const JointModel*>                        joint_model_vector_;
00376 
00378   std::map<std::string, const JointModel*>              joint_model_map_;
00379 
00381   std::vector<const JointModel*>                        joint_roots_;
00382 
00386   std::map<std::string, unsigned int>                   joint_variables_index_map_;
00387 
00389   std::vector<const JointModel*>                        fixed_joints_;
00390 
00392   std::vector<const JointModel*>                        mimic_joints_;
00393 
00395   std::vector<const JointModel*>                        continuous_joint_model_vector_const_;
00396 
00398   std::vector<std::string>                              active_variable_names_;
00399 
00401   std::set<std::string>                                 active_variable_names_set_;
00402 
00406   std::vector<const LinkModel*>                         link_model_vector_;
00407 
00409   std::vector<std::string>                              link_model_name_vector_;
00410 
00412   std::vector<std::string>                              link_model_with_geometry_name_vector_;
00413 
00415   std::vector<const LinkModel*>                         updated_link_model_vector_;
00416 
00418   std::set<const LinkModel*>                            updated_link_model_set_;
00419 
00421   std::vector<std::string>                              updated_link_model_name_vector_;
00422 
00424   std::set<std::string>                                 updated_link_model_name_set_;
00425 
00427   std::vector<const LinkModel*>                         updated_link_model_with_geometry_vector_;
00428 
00430   std::set<const LinkModel*>                            updated_link_model_with_geometry_set_;
00431 
00433   std::vector<std::string>                              updated_link_model_with_geometry_name_vector_;
00434 
00436   std::set<std::string>                                 updated_link_model_with_geometry_name_set_;
00437 
00439   unsigned int                                          variable_count_;
00440 
00442   std::vector<std::string>                              subgroup_names_;
00443 
00445   bool                                                  is_end_effector_;
00446 
00448   std::vector<std::string>                              attached_end_effector_names_;
00449 
00451   std::pair<std::string, std::string>                   end_effector_parent_;
00452 
00454   std::string                                           end_effector_name_;
00455 
00456   bool                                                  is_chain_;
00457 
00458   std::pair<SolverAllocatorFn, SolverAllocatorMapFn>    solver_allocators_;
00459 
00460   kinematics::KinematicsBaseConstPtr                    solver_instance_const_;
00461 
00462   kinematics::KinematicsBasePtr                         solver_instance_;
00463 
00464   std::vector<unsigned int>                             ik_joint_bijection_;
00465 
00466   double                                                default_ik_timeout_;
00467 
00468   unsigned int                                          default_ik_attempts_;
00469 
00471   std::map<std::string, std::map<std::string, double> > default_states_;
00472 };
00473 
00474 }
00475 
00476 #endif


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