solver_factory.h
Go to the documentation of this file.
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_FACTORIES_SOLVER_FACTORY_H
00019 #define COB_TWIST_CONTROLLER_CONSTRAINT_SOLVERS_FACTORIES_SOLVER_FACTORY_H
00020 
00021 #include <set>
00022 #include <Eigen/Core>
00023 #include <Eigen/SVD>
00024 #include <kdl/jntarray.hpp>
00025 
00026 #include "cob_twist_controller/damping_methods/damping_base.h"
00027 #include "cob_twist_controller/constraints/constraint_base.h"
00028 #include "cob_twist_controller/task_stack/task_stack_controller.h"
00029 
00031 class ISolverFactory
00032 {
00033     public:
00034         virtual Eigen::MatrixXd calculateJointVelocities(Matrix6Xd_t& jacobian_data,
00035                                                          const Vector6d_t& in_cart_velocities,
00036                                                          const JointStates& joint_states,
00037                                                          boost::shared_ptr<DampingBase>& damping_method,
00038                                                          std::set<ConstraintBase_t>& constraints) const = 0;
00039 
00040         virtual ~ISolverFactory() {}
00041 };
00042 
00044 template <typename T>
00045 class SolverFactory : public ISolverFactory
00046 {
00047     public:
00048         SolverFactory(const TwistControllerParams& params,
00049                       const LimiterParams& limiter_params,
00050                       TaskStackController_t& task_stack_controller)
00051         {
00052             constraint_solver_.reset(new T(params, limiter_params, task_stack_controller));
00053         }
00054 
00055         ~SolverFactory()
00056         {
00057             constraint_solver_.reset();
00058         }
00059 
00071         Eigen::MatrixXd calculateJointVelocities(Matrix6Xd_t& jacobian_data,
00072                                                  const Vector6d_t& in_cart_velocities,
00073                                                  const JointStates& joint_states,
00074                                                  boost::shared_ptr<DampingBase>& damping_method,
00075                                                  std::set<ConstraintBase_t>& constraints) const
00076         {
00077             constraint_solver_->setJacobianData(jacobian_data);
00078             constraint_solver_->setConstraints(constraints);
00079             constraint_solver_->setDamping(damping_method);
00080             Eigen::MatrixXd new_q_dot = constraint_solver_->solve(in_cart_velocities, joint_states);
00081             return new_q_dot;
00082         }
00083 
00084     private:
00085         boost::shared_ptr<T> constraint_solver_;
00086 };
00087 
00088 #endif  // COB_TWIST_CONTROLLER_CONSTRAINT_SOLVERS_FACTORIES_SOLVER_FACTORY_H


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Jun 6 2019 21:19:26