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 #include <set>
00019 #include <cmath>
00020
00021 #include "cob_twist_controller/constraint_solvers/solvers/gradient_projection_method_solver.h"
00022
00028 Eigen::MatrixXd GradientProjectionMethodSolver::solve(const Vector6d_t& in_cart_velocities,
00029 const JointStates& joint_states)
00030 {
00031 Eigen::MatrixXd damped_pinv = pinv_calc_.calculate(this->params_, this->damping_, this->jacobian_data_);
00032 Eigen::MatrixXd pinv = pinv_calc_.calculate(this->jacobian_data_);
00033
00034 Eigen::MatrixXd particular_solution = damped_pinv * in_cart_velocities;
00035
00036
00037
00038 Eigen::MatrixXd ident = Eigen::MatrixXd::Identity(pinv.rows(), this->jacobian_data_.cols());
00039 Eigen::MatrixXd projector = ident - pinv * this->jacobian_data_;
00040
00041 Eigen::MatrixXd homogeneous_solution = Eigen::MatrixXd::Zero(particular_solution.rows(), particular_solution.cols());
00042 KDL::JntArrayVel predict_jnts_vel(joint_states.current_q_.rows());
00043
00044 for (std::set<ConstraintBase_t>::iterator it = this->constraints_.begin(); it != this->constraints_.end(); ++it)
00045 {
00046 ROS_DEBUG_STREAM("task id: " << (*it)->getTaskId());
00047 (*it)->update(joint_states, predict_jnts_vel, this->jacobian_data_);
00048 Eigen::VectorXd q_dot_0 = (*it)->getPartialValues();
00049 Eigen::MatrixXd tmp_projection = projector * q_dot_0;
00050 double activation_gain = (*it)->getActivationGain();
00051 double constraint_k_H = (*it)->getSelfMotionMagnitude(particular_solution, tmp_projection);
00052 homogeneous_solution += (constraint_k_H * activation_gain * tmp_projection);
00053 }
00054
00055 Eigen::MatrixXd qdots_out = particular_solution + this->params_.k_H * homogeneous_solution;
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 return qdots_out;
00076 }