00001 /* 00002 * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA) 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 00018 #ifndef COB_TWIST_CONTROLLER_KINEMATIC_EXTENSIONS_KINEMATIC_EXTENSION_DOF_H 00019 #define COB_TWIST_CONTROLLER_KINEMATIC_EXTENSIONS_KINEMATIC_EXTENSION_DOF_H 00020 00021 #include <string> 00022 #include <vector> 00023 00024 #include <ros/ros.h> 00025 #include <geometry_msgs/Twist.h> 00026 #include <Eigen/Geometry> 00027 00028 #include "cob_twist_controller/kinematic_extensions/kinematic_extension_base.h" 00029 00030 /* BEGIN KinematicExtensionDOF ****************************************************************************************/ 00032 class KinematicExtensionDOF : public KinematicExtensionBase 00033 { 00034 public: 00035 explicit KinematicExtensionDOF(const TwistControllerParams& params) 00036 : KinematicExtensionBase(params) 00037 {} 00038 00039 ~KinematicExtensionDOF() {} 00040 00041 virtual bool initExtension() = 0; 00042 virtual KDL::Jacobian adjustJacobian(const KDL::Jacobian& jac_chain) = 0; 00043 virtual JointStates adjustJointStates(const JointStates& joint_states) = 0; 00044 virtual LimiterParams adjustLimiterParams(const LimiterParams& limiter_params) = 0; 00045 virtual void processResultExtension(const KDL::JntArray& q_dot_ik) = 0; 00046 00047 KDL::Jacobian adjustJacobianDof(const KDL::Jacobian& jac_chain, const KDL::Frame eb_frame_ct, const KDL::Frame cb_frame_eb, const ActiveCartesianDimension active_dim); 00048 00049 protected: 00050 unsigned int ext_dof_; 00051 std::vector<std::string> joint_names_; 00052 JointStates joint_states_; 00053 std::vector<double> limits_max_; 00054 std::vector<double> limits_min_; 00055 std::vector<double> limits_vel_; 00056 std::vector<double> limits_acc_; 00057 }; 00058 /* END KinematicExtensionDOF **********************************************************************************************/ 00059 00060 /* BEGIN KinematicExtensionBaseActive ****************************************************************************************/ 00062 class KinematicExtensionBaseActive : public KinematicExtensionDOF 00063 { 00064 public: 00065 explicit KinematicExtensionBaseActive(const TwistControllerParams& params) 00066 : KinematicExtensionDOF(params) 00067 { 00068 base_vel_pub_ = nh_.advertise<geometry_msgs::Twist>("base/command", 1); 00069 00070 min_vel_lin_base_ = 0.005; // used to avoid infinitesimal motion 00071 min_vel_rot_base_ = 0.005; // used to avoid infinitesimal motion 00072 max_vel_lin_base_ = 0.5; 00073 max_vel_rot_base_ = 0.5; 00074 00075 if (!initExtension()) 00076 { 00077 ROS_ERROR("Initialization failed"); 00078 } 00079 } 00080 00081 ~KinematicExtensionBaseActive() {} 00082 00083 bool initExtension(); 00084 KDL::Jacobian adjustJacobian(const KDL::Jacobian& jac_chain); 00085 JointStates adjustJointStates(const JointStates& joint_states); 00086 LimiterParams adjustLimiterParams(const LimiterParams& limiter_params); 00087 void processResultExtension(const KDL::JntArray& q_dot_ik); 00088 00089 void baseTwistCallback(const geometry_msgs::Twist::ConstPtr& msg); 00090 00091 private: 00092 ros::Publisher base_vel_pub_; 00093 00094 double min_vel_lin_base_; 00095 double min_vel_rot_base_; 00096 double max_vel_lin_base_; 00097 double max_vel_rot_base_; 00098 }; 00099 /* END KinematicExtensionBaseActive **********************************************************************************************/ 00100 00101 #endif // COB_TWIST_CONTROLLER_KINEMATIC_EXTENSIONS_KINEMATIC_EXTENSION_DOF_H