srv_kinematics_plugin.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2014, JSK, The University of Tokyo.
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 JSK, The University of Tokyo 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: Dave Coleman, Masaki Murooka
00036    Desc:   Connects MoveIt to any inverse kinematics solver via a ROS service call
00037            Supports planning groups with multiple tip frames
00038            \todo: better support for mimic joints
00039            \todo: better support for redundant joints
00040 */
00041 
00042 #ifndef MOVEIT_ROS_PLANNING_SRV_KINEMATICS_PLUGIN_
00043 #define MOVEIT_ROS_PLANNING_SRV_KINEMATICS_PLUGIN_
00044 
00045 // ROS
00046 #include <ros/ros.h>
00047 
00048 // System
00049 #include <boost/shared_ptr.hpp>
00050 
00051 // ROS msgs
00052 #include <geometry_msgs/PoseStamped.h>
00053 #include <moveit_msgs/GetPositionFK.h>
00054 #include <moveit_msgs/GetPositionIK.h>
00055 #include <moveit_msgs/GetKinematicSolverInfo.h>
00056 #include <moveit_msgs/MoveItErrorCodes.h>
00057 
00058 // MoveIt!
00059 #include <moveit/kinematics_base/kinematics_base.h>
00060 #include <moveit/robot_model/robot_model.h>
00061 #include <moveit/robot_state/robot_state.h>
00062 
00063 namespace srv_kinematics_plugin
00064 {
00069 class SrvKinematicsPlugin : public kinematics::KinematicsBase
00070 {
00071 public:
00075   SrvKinematicsPlugin();
00076 
00077   virtual bool
00078   getPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state,
00079                 std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
00080                 const kinematics::KinematicsQueryOptions& options = kinematics::KinematicsQueryOptions()) const;
00081 
00082   virtual bool
00083   searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
00084                    std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
00085                    const kinematics::KinematicsQueryOptions& options = kinematics::KinematicsQueryOptions()) const;
00086 
00087   virtual bool
00088   searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
00089                    const std::vector<double>& consistency_limits, std::vector<double>& solution,
00090                    moveit_msgs::MoveItErrorCodes& error_code,
00091                    const kinematics::KinematicsQueryOptions& options = kinematics::KinematicsQueryOptions()) const;
00092 
00093   virtual bool searchPositionIK(
00094       const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
00095       std::vector<double>& solution, const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
00096       const kinematics::KinematicsQueryOptions& options = kinematics::KinematicsQueryOptions()) const;
00097 
00098   virtual bool
00099   searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
00100                    const std::vector<double>& consistency_limits, std::vector<double>& solution,
00101                    const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
00102                    const kinematics::KinematicsQueryOptions& options = kinematics::KinematicsQueryOptions()) const;
00103 
00104   virtual bool getPositionFK(const std::vector<std::string>& link_names, const std::vector<double>& joint_angles,
00105                              std::vector<geometry_msgs::Pose>& poses) const;
00106 
00107   virtual bool initialize(const std::string& robot_description, const std::string& group_name,
00108                           const std::string& base_name, const std::string& tip_frame, double search_discretization)
00109   {
00110     std::vector<std::string> tip_frames;
00111     tip_frames.push_back(tip_frame);
00112     return initialize(robot_description, group_name, base_name, tip_frames, search_discretization);
00113   }
00114 
00115   virtual bool initialize(const std::string& robot_description, const std::string& group_name,
00116                           const std::string& base_name, const std::vector<std::string>& tip_frames,
00117                           double search_discretization);
00118 
00122   const std::vector<std::string>& getJointNames() const;
00123 
00127   const std::vector<std::string>& getLinkNames() const;
00128 
00132   const std::vector<std::string>& getVariableNames() const;
00133 
00134 protected:
00135   virtual bool
00136   searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
00137                    std::vector<double>& solution, const IKCallbackFn& solution_callback,
00138                    moveit_msgs::MoveItErrorCodes& error_code, const std::vector<double>& consistency_limits,
00139                    const kinematics::KinematicsQueryOptions& options = kinematics::KinematicsQueryOptions()) const;
00140 
00141   virtual bool
00142   searchPositionIK(const std::vector<geometry_msgs::Pose>& ik_poses, const std::vector<double>& ik_seed_state,
00143                    double timeout, const std::vector<double>& consistency_limits, std::vector<double>& solution,
00144                    const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
00145                    const kinematics::KinematicsQueryOptions& options = kinematics::KinematicsQueryOptions()) const;
00146 
00147   virtual bool setRedundantJoints(const std::vector<unsigned int>& redundant_joint_indices);
00148 
00149 private:
00150   bool timedOut(const ros::WallTime& start_time, double duration) const;
00151 
00152   int getJointIndex(const std::string& name) const;
00153 
00154   bool isRedundantJoint(unsigned int index) const;
00155 
00156   bool active_; 
00158   moveit_msgs::KinematicSolverInfo ik_group_info_; 
00160   unsigned int dimension_; 
00162   robot_model::RobotModelPtr robot_model_;
00163   robot_model::JointModelGroup* joint_model_group_;
00164 
00165   robot_state::RobotStatePtr robot_state_;
00166 
00167   int num_possible_redundant_joints_;
00168 
00169   boost::shared_ptr<ros::ServiceClient> ik_service_client_;
00170 };
00171 }
00172 
00173 #endif


moveit_kinematics
Author(s): Dave Coleman , Ioan Sucan , Sachin Chitta
autogenerated on Mon Apr 23 2018 10:25:23