kdl_kinematics_plugin.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 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: Sachin Chitta, David Lu!!, Ugo Cupcic */
36 
37 #ifndef MOVEIT_ROS_PLANNING_KDL_KINEMATICS_PLUGIN_
38 #define MOVEIT_ROS_PLANNING_KDL_KINEMATICS_PLUGIN_
39 
40 // ROS
41 #include <ros/ros.h>
43 
44 // ROS msgs
45 #include <geometry_msgs/PoseStamped.h>
46 #include <moveit_msgs/GetPositionFK.h>
47 #include <moveit_msgs/GetPositionIK.h>
48 #include <moveit_msgs/KinematicSolverInfo.h>
49 #include <moveit_msgs/MoveItErrorCodes.h>
50 
51 // KDL
52 #include <kdl/jntarray.hpp>
53 #include <kdl/chainiksolvervel_pinv.hpp>
54 #include <kdl/chainiksolverpos_nr_jl.hpp>
55 #include <kdl/chainfksolverpos_recursive.hpp>
59 
60 // MoveIt!
64 
65 namespace kdl_kinematics_plugin
66 {
71 {
72 public:
77 
78  virtual bool
79  getPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state,
80  std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
82 
83  virtual bool
84  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
85  std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
87 
88  virtual bool
89  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
90  const std::vector<double>& consistency_limits, std::vector<double>& solution,
91  moveit_msgs::MoveItErrorCodes& error_code,
93 
94  virtual bool searchPositionIK(
95  const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
96  std::vector<double>& solution, const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
98 
99  virtual bool
100  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
101  const std::vector<double>& consistency_limits, std::vector<double>& solution,
102  const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
104 
105  virtual bool getPositionFK(const std::vector<std::string>& link_names, const std::vector<double>& joint_angles,
106  std::vector<geometry_msgs::Pose>& poses) const;
107 
108  virtual bool initialize(const std::string& robot_description, const std::string& group_name,
109  const std::string& base_name, const std::string& tip_name, double search_discretization);
110 
114  const std::vector<std::string>& getJointNames() const;
115 
119  const std::vector<std::string>& getLinkNames() const;
120 
121 protected:
138  bool searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
139  std::vector<double>& solution, const IKCallbackFn& solution_callback,
140  moveit_msgs::MoveItErrorCodes& error_code, const std::vector<double>& consistency_limits,
142 
143  virtual bool setRedundantJoints(const std::vector<unsigned int>& redundant_joint_indices);
144 
145 private:
146  bool timedOut(const ros::WallTime& start_time, double duration) const;
147 
156  bool checkConsistency(const KDL::JntArray& seed_state, const std::vector<double>& consistency_limit,
157  const KDL::JntArray& solution) const;
158 
159  int getJointIndex(const std::string& name) const;
160 
161  int getKDLSegmentIndex(const std::string& name) const;
162 
163  void getRandomConfiguration(KDL::JntArray& jnt_array, bool lock_redundancy) const;
164 
172  void getRandomConfiguration(const KDL::JntArray& seed_state, const std::vector<double>& consistency_limits,
173  KDL::JntArray& jnt_array, bool lock_redundancy) const;
174 
175  bool isRedundantJoint(unsigned int index) const;
176 
177  bool active_;
179  moveit_msgs::KinematicSolverInfo ik_chain_info_;
181  moveit_msgs::KinematicSolverInfo fk_chain_info_;
184 
185  unsigned int dimension_;
190 
191  robot_model::RobotModelPtr robot_model_;
192 
193  robot_state::RobotStatePtr state_, state_2_;
194 
196  std::vector<unsigned int> redundant_joints_map_index_;
197 
198  // Storage required for when the set of redundant joints is reset
199  bool position_ik_; // whether this solver is only being used for position ik
200  robot_model::JointModelGroup* joint_model_group_;
202  double epsilon_;
203  std::vector<JointMimic> mimic_joints_;
204 };
205 }
206 
207 #endif
int getKDLSegmentIndex(const std::string &name) const
virtual bool initialize(const std::string &robot_description, const std::string &group_name, const std::string &base_name, const std::string &tip_name, double search_discretization)
robot_model::JointModelGroup * joint_model_group_
virtual bool setRedundantJoints(const std::vector< unsigned int > &redundant_joint_indices)
void getRandomConfiguration(KDL::JntArray &jnt_array, bool lock_redundancy) const
bool timedOut(const ros::WallTime &start_time, double duration) const
int getJointIndex(const std::string &name) const
random_numbers::RandomNumberGenerator random_number_generator_
virtual bool getPositionFK(const std::vector< std::string > &link_names, const std::vector< double > &joint_angles, std::vector< geometry_msgs::Pose > &poses) const
unsigned int index
bool checkConsistency(const KDL::JntArray &seed_state, const std::vector< double > &consistency_limit, const KDL::JntArray &solution) const
Check whether the solution lies within the consistency limit of the seed state.
Specific implementation of kinematics using KDL. This version can be used with any robot...
options
moveit_msgs::KinematicSolverInfo fk_chain_info_
const std::vector< std::string > & getJointNames() const
Return all the joint names in the order they are used internally.
boost::function< void(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_solution, moveit_msgs::MoveItErrorCodes &error_code)> IKCallbackFn
virtual bool getPositionIK(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_seed_state, std::vector< double > &solution, moveit_msgs::MoveItErrorCodes &error_code, const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions()) const
moveit_msgs::KinematicSolverInfo ik_chain_info_
bool isRedundantJoint(unsigned int index) const
std::vector< unsigned int > redundant_joints_map_index_
const std::vector< std::string > & getLinkNames() const
Return all the link names in the order they are represented internally.
virtual bool searchPositionIK(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_seed_state, double timeout, std::vector< double > &solution, moveit_msgs::MoveItErrorCodes &error_code, const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions()) const


moveit_kinematics
Author(s): Dave Coleman , Ioan Sucan , Sachin Chitta
autogenerated on Wed Apr 18 2018 02:49:42