00001 /* 00002 * Software License Agreement (Apache License) 00003 * 00004 * Copyright (c) 2013, Southwest Research Institute 00005 * 00006 * Licensed under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00019 00020 #ifndef GOAL_AVOID_SINGULARITIES_H 00021 #define GOAL_AVOID_SINGULARITIES_H 00022 00023 #include "constrained_ik/constraint.h" 00024 00025 namespace constrained_ik 00026 { 00027 namespace constraints 00028 { 00029 00034 class AvoidSingularities: public Constraint 00035 { 00036 public: 00037 AvoidSingularities(); 00038 virtual ~AvoidSingularities() {}; 00039 00043 virtual Eigen::MatrixXd calcJacobian(); 00044 00049 virtual Eigen::VectorXd calcError(); 00050 00054 virtual bool checkStatus() const { return true;}; //always return true 00055 00059 double getWeight() {return weight_;} 00060 00064 void setWeight(double weight) {weight_ = weight;}; 00065 00070 virtual void update(const SolverState &state); 00071 00072 protected: 00073 double weight_; 00074 double enable_threshold_, ignore_threshold_; // how small singular value must be to trigger avoidance, how small is too small 00075 bool avoidance_enabled_; 00076 double smallest_sv_; 00077 Eigen::VectorXd Ui_, Vi_; 00078 Eigen::MatrixXd jacobian_orig_; // current jacobian 00079 00080 Eigen::MatrixXd jacobianPartialDerivative(size_t jntIdx, double eps=1e-6); 00081 00082 }; // class AvoidSingularities 00083 00084 } // namespace constraints 00085 } // namespace constrained_ik 00086 00087 00088 #endif // GOAL_AVOID_SINGULARITIES_H 00089