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_LOOKAT_H 00019 #define COB_TWIST_CONTROLLER_KINEMATIC_EXTENSIONS_KINEMATIC_EXTENSION_LOOKAT_H 00020 00021 #include <string> 00022 #include <vector> 00023 #include <limits> 00024 #include <ros/ros.h> 00025 00026 #include <boost/shared_ptr.hpp> 00027 #include <boost/thread/mutex.hpp> 00028 #include <kdl_parser/kdl_parser.hpp> 00029 #include <kdl/chainjnttojacsolver.hpp> 00030 #include <kdl/chainfksolverpos_recursive.hpp> 00031 #include <tf_conversions/tf_kdl.h> 00032 #include <tf/transform_broadcaster.h> 00033 #include <Eigen/Geometry> 00034 00035 #include "cob_twist_controller/kinematic_extensions/kinematic_extension_base.h" 00036 #include "cob_twist_controller/utils/simpson_integrator.h" 00037 00038 /* BEGIN KinematicExtensionLookat ****************************************************************************************/ 00040 class KinematicExtensionLookat : public KinematicExtensionBase 00041 { 00042 public: 00043 explicit KinematicExtensionLookat(const TwistControllerParams& params) 00044 : KinematicExtensionBase(params) 00045 { 00046 if (!initExtension()) 00047 { 00048 ROS_ERROR("Initialization failed"); 00049 } 00050 } 00051 00052 ~KinematicExtensionLookat() {} 00053 00054 bool initExtension(); 00055 virtual KDL::Jacobian adjustJacobian(const KDL::Jacobian& jac_chain); 00056 virtual JointStates adjustJointStates(const JointStates& joint_states); 00057 virtual LimiterParams adjustLimiterParams(const LimiterParams& limiter_params); 00058 virtual void processResultExtension(const KDL::JntArray& q_dot_ik); 00059 00060 private: 00061 unsigned int ext_dof_; 00062 KDL::Chain chain_ext_; 00063 KDL::Chain chain_full_; 00064 JointStates joint_states_ext_; 00065 JointStates joint_states_full_; 00066 std::vector<double> limits_ext_max_; 00067 std::vector<double> limits_ext_min_; 00068 std::vector<double> limits_ext_vel_; 00069 std::vector<double> limits_ext_acc_; 00070 00071 boost::shared_ptr<KDL::ChainJntToJacSolver> jnt2jac_; 00072 boost::shared_ptr<KDL::ChainFkSolverPos_recursive> fk_solver_ext_; 00073 00074 boost::shared_ptr<SimpsonIntegrator> integrator_; 00075 00076 boost::mutex mutex_; 00077 ros::Timer timer_; 00078 tf::TransformBroadcaster br_; 00079 void broadcastFocusFrame(const ros::TimerEvent& event); 00080 }; 00081 /* END KinematicExtensionLookat **********************************************************************************************/ 00082 00083 #endif // COB_TWIST_CONTROLLER_KINEMATIC_EXTENSIONS_KINEMATIC_EXTENSION_LOOKAT_H