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 #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