lma_kinematics_plugin.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2016, CRI group, NTU, Singapore
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 CRI group 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: Francisco Suarez-Ruiz */
36 
37 #ifndef MOVEIT_ROS_PLANNING_LMA_KINEMATICS_PLUGIN_H
38 #define MOVEIT_ROS_PLANNING_LMA_KINEMATICS_PLUGIN_H
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 lma_kinematics_plugin
66 {
72 {
73 public:
78 
79  virtual bool
80  getPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state,
81  std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
83 
84  virtual bool
85  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
86  std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
88 
89  virtual bool
90  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
91  const std::vector<double>& consistency_limits, std::vector<double>& solution,
92  moveit_msgs::MoveItErrorCodes& error_code,
94 
95  virtual bool
96  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
97  std::vector<double>& solution, const IKCallbackFn& solution_callback,
98  moveit_msgs::MoveItErrorCodes& error_code,
100 
101  virtual bool
102  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
103  const std::vector<double>& consistency_limits, std::vector<double>& solution,
104  const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
106 
107  virtual bool getPositionFK(const std::vector<std::string>& link_names, const std::vector<double>& joint_angles,
108  std::vector<geometry_msgs::Pose>& poses) const;
109 
110  virtual bool initialize(const std::string& robot_description, const std::string& group_name,
111  const std::string& base_name, const std::string& tip_name, double search_discretization);
112 
116  const std::vector<std::string>& getJointNames() const;
117 
121  const std::vector<std::string>& getLinkNames() const;
122 
123 protected:
140  bool searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
141  std::vector<double>& solution, const IKCallbackFn& solution_callback,
142  moveit_msgs::MoveItErrorCodes& error_code, const std::vector<double>& consistency_limits,
144 
145  virtual bool setRedundantJoints(const std::vector<unsigned int>& redundant_joint_indices);
146 
147 private:
148  bool timedOut(const ros::WallTime& start_time, double duration) const;
149 
158  bool checkConsistency(const KDL::JntArray& seed_state, const std::vector<double>& consistency_limit,
159  const KDL::JntArray& solution) const;
160 
161  int getJointIndex(const std::string& name) const;
162 
163  int getKDLSegmentIndex(const std::string& name) const;
164 
165  void getRandomConfiguration(KDL::JntArray& jnt_array, bool lock_redundancy) const;
166 
174  void getRandomConfiguration(const KDL::JntArray& seed_state, const std::vector<double>& consistency_limits,
175  KDL::JntArray& jnt_array, bool lock_redundancy) const;
176 
177  bool isRedundantJoint(unsigned int index) const;
178 
179  bool active_;
181  moveit_msgs::KinematicSolverInfo ik_chain_info_;
183  moveit_msgs::KinematicSolverInfo fk_chain_info_;
186 
187  unsigned int dimension_;
192 
193  robot_model::RobotModelPtr robot_model_;
194 
195  robot_state::RobotStatePtr state_, state_2_;
196 
198  std::vector<unsigned int> redundant_joints_map_index_;
199 
200  // Storage required for when the set of redundant joints is reset
201  bool position_ik_; // whether this solver is only being used for position ik
202  robot_model::JointModelGroup* joint_model_group_;
204  double epsilon_;
205  std::vector<JointMimic> mimic_joints_;
206 };
207 }
208 
209 #endif
bool timedOut(const ros::WallTime &start_time, double duration) const
int getJointIndex(const std::string &name) const
const std::vector< std::string > & getJointNames() const
Return all the joint names in the order they are used internally.
moveit_msgs::KinematicSolverInfo fk_chain_info_
int getKDLSegmentIndex(const std::string &name) const
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
options
Specific implementation of kinematics using Levenberg-Marquardt method available at KDL...
virtual bool setRedundantJoints(const std::vector< unsigned int > &redundant_joint_indices)
boost::function< void(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_solution, moveit_msgs::MoveItErrorCodes &error_code)> IKCallbackFn
const std::vector< std::string > & getLinkNames() const
Return all the link names in the order they are represented internally.
void getRandomConfiguration(KDL::JntArray &jnt_array, bool lock_redundancy) const
random_numbers::RandomNumberGenerator random_number_generator_
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
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.
moveit_msgs::KinematicSolverInfo ik_chain_info_
robot_model::JointModelGroup * joint_model_group_
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
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)
bool isRedundantJoint(unsigned int index) const
std::vector< unsigned int > redundant_joints_map_index_


moveit_kinematics
Author(s): Dave Coleman , Ioan Sucan , Sachin Chitta
autogenerated on Sun Oct 18 2020 13:17:53