Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00029 #include <vector>
00030 #include <string>
00031 #include <boost/scoped_ptr.hpp>
00032
00033 #include <ros/ros.h>
00034 #include <tf/transform_listener.h>
00035 #include <geometry_msgs/PoseStamped.h>
00036 #include <kdl_parser/kdl_parser.hpp>
00037
00038 #include <kdl/tree.hpp>
00039 #include <kdl/frames.hpp>
00040 #include <kdl/jntarray.hpp>
00041
00042 #include <kdl/treefksolver.hpp>
00043 #include <kdl/treeiksolver.hpp>
00044 #include <kdl/treefksolverpos_recursive.hpp>
00045 #include <kdl/treeiksolvervel_wdls.hpp>
00046 #include <tree_kinematics/treeiksolverpos_online.hpp>
00047
00048
00049 #include <boost/scoped_ptr.hpp>
00050
00051 #include <kinematics_msgs/KinematicSolverInfo.h>
00052 #include <kinematics_msgs/GetKinematicSolverInfo.h>
00053 #include <tree_kinematics/get_tree_position_ik.h>
00054 #include <kinematics_msgs/GetPositionFK.h>
00055
00056
00057 namespace tree_kinematics
00058 {
00059
00068 class TreeKinematics
00069 {
00070 public:
00071 TreeKinematics(): nh_private_("~")
00072 {
00073 loop_count_ = 1;
00074 ik_srv_duration_ = 0.0;
00075 ik_srv_duration_median_ = 0.0;
00076 ik_duration_ = 0.0;
00077 ik_duration_median_ = 0.0;
00078 };
00079
00080 ~TreeKinematics(){};
00081
00093 bool init();
00094
00109 bool getPositionFk(kinematics_msgs::GetPositionFK::Request& request,
00110 kinematics_msgs::GetPositionFK::Response& response);
00111
00125 bool getPositionIk(tree_kinematics::get_tree_position_ik::Request &request,
00126 tree_kinematics::get_tree_position_ik::Response &response);
00127
00128 private:
00129 ros::NodeHandle nh_, nh_private_;
00130 KDL::Tree kdl_tree_;
00131 std::string tree_root_name_;
00132 unsigned int nr_of_jnts_;
00133 int srv_call_frequency_;
00134 KDL::MatrixXd js_w_matr_;
00135 KDL::MatrixXd ts_w_matr_;
00136 double lambda_;
00137
00138 boost::scoped_ptr<KDL::TreeFkSolverPos> fk_solver_;
00139 boost::scoped_ptr<KDL::TreeIkSolverVel_wdls> ik_vel_solver_;
00140 boost::scoped_ptr<KDL::TreeIkSolverPos_Online> ik_pos_solver_;
00141
00142 ros::ServiceServer fk_service_, ik_service_;
00143 tf::TransformListener tf_listener_;
00144 kinematics_msgs::KinematicSolverInfo info_;
00145
00162 bool loadModel(const std::string xml,
00163 KDL::Tree& kdl_tree,
00164 std::string& tree_root_name,
00165 unsigned int& nr_of_jnts,
00166 KDL::JntArray& joint_min,
00167 KDL::JntArray& joint_max,
00168 KDL::JntArray& joint_vel_max);
00169
00187 bool readJoints(urdf::Model& robot_model,
00188 KDL::Tree& kdl_tree,
00189 std::string& tree_root_name,
00190 unsigned int& nr_of_jnts,
00191 KDL::JntArray& joint_min,
00192 KDL::JntArray& joint_max,
00193 KDL::JntArray& joint_vel_max);
00194
00204 int getJointIndex(const std::string& name);
00205
00206 unsigned int loop_count_;
00207 double ik_srv_duration_, ik_srv_duration_median_, ik_duration_, ik_duration_median_;
00208 };
00209
00210 }
00211