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_CONSTRAINT_SOLVERS_SOLVERS_CONSTRAINT_SOLVER_BASE_H 00019 #define COB_TWIST_CONTROLLER_CONSTRAINT_SOLVERS_SOLVERS_CONSTRAINT_SOLVER_BASE_H 00020 00021 #include <set> 00022 #include <Eigen/Core> 00023 #include <kdl/jntarray.hpp> 00024 #include <boost/shared_ptr.hpp> 00025 #include <cob_twist_controller/inverse_jacobian_calculations/inverse_jacobian_calculation.h> 00026 #include "cob_twist_controller/damping_methods/damping_base.h" 00027 #include "cob_twist_controller/constraints/constraint_base.h" 00028 #include "cob_twist_controller/cob_twist_controller_data_types.h" 00029 #include "cob_twist_controller/task_stack/task_stack_controller.h" 00030 00032 template <typename PINV = PInvBySVD> 00033 class ConstraintSolver 00034 { 00035 public: 00042 virtual Eigen::MatrixXd solve(const Vector6d_t& in_cart_velocities, 00043 const JointStates& joint_states) = 0; 00044 00049 inline void setDamping(boost::shared_ptr<DampingBase>& damping) 00050 { 00051 this->damping_ = damping; 00052 } 00053 00058 inline void setConstraints(std::set<ConstraintBase_t>& constraints) 00059 { 00060 this->constraints_.clear(); 00061 this->constraints_ = constraints; 00062 } 00063 00067 inline void clearConstraints() 00068 { 00069 this->constraints_.clear(); 00070 } 00071 00075 virtual void setJacobianData(const Matrix6Xd_t& jacobian_data) 00076 { 00077 this->jacobian_data_ = jacobian_data; 00078 } 00079 00080 virtual ~ConstraintSolver() 00081 { 00082 this->clearConstraints(); 00083 } 00084 00085 ConstraintSolver(const TwistControllerParams& params, 00086 const LimiterParams& limiter_params, 00087 TaskStackController_t& task_stack_controller) : 00088 params_(params), 00089 limiter_params_(limiter_params), 00090 task_stack_controller_(task_stack_controller) 00091 {} 00092 00093 protected: 00095 std::set<ConstraintBase_t> constraints_; 00096 const TwistControllerParams& params_; 00097 const LimiterParams& limiter_params_; 00098 Matrix6Xd_t jacobian_data_; 00099 boost::shared_ptr<DampingBase> damping_; 00100 PINV pinv_calc_; 00101 TaskStackController_t& task_stack_controller_; 00102 }; 00103 00104 #endif // COB_TWIST_CONTROLLER_CONSTRAINT_SOLVERS_SOLVERS_CONSTRAINT_SOLVER_BASE_H