avoid_joint_limits.h
Go to the documentation of this file.
00001 /*
00002  * avoid_joint_limits.h
00003  *
00004  *  Created on: Sep 23, 2013
00005  *      Author: dsolomon
00006  */
00007 /*
00008  * Software License Agreement (Apache License)
00009  *
00010  * Copyright (c) 2013, Southwest Research Institute
00011  *
00012  * Licensed under the Apache License, Version 2.0 (the "License");
00013  * you may not use this file except in compliance with the License.
00014  * You may obtain a copy of the License at
00015  *
00016  *   http://www.apache.org/licenses/LICENSE-2.0
00017  *
00018  * Unless required by applicable law or agreed to in writing, software
00019  * distributed under the License is distributed on an "AS IS" BASIS,
00020  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00021  * See the License for the specific language governing permissions and
00022  * limitations under the License.
00023  */
00024 
00025 #ifndef AVOID_JOINT_LIMITS_H_
00026 #define AVOID_JOINT_LIMITS_H_
00027 
00028 #include "constrained_ik/constraint.h"
00029 #include <vector>
00030 
00031 namespace constrained_ik
00032 {
00033 namespace constraints
00034 {
00035 
00041 class AvoidJointLimits: public Constraint
00042 {
00043 public:
00044     AvoidJointLimits(): Constraint(), weight_(1.0), threshold_(0.05) {};
00045     virtual ~AvoidJointLimits() {};
00046 
00051     virtual Eigen::MatrixXd calcJacobian();
00052 
00057     virtual Eigen::VectorXd calcError();
00058 
00063     virtual bool checkStatus() const;// { return limited_joints_.size() < 1;/*true;*/ }  // always satisfied, even if "close to limits"
00064 
00070     virtual void init(const Constrained_IK* ik);
00071 
00075     virtual void reset();
00076 
00081     virtual void update(const SolverState &state);
00082 
00086     double getWeight() {return weight_;};
00087 
00091     void setWeight(const double &weight) {weight_ = weight;};
00092 
00093 protected:
00094 
00095     struct LimitsT
00096     {
00097       double min_pos;       // minimum joint position
00098       double max_pos;       // maximum joint position
00099 //      double range;
00100       double lower_thresh;  // lower threshold at which limiting begins
00101       double upper_thresh;  // upper threshold at which limiting begins
00102       double e;             // threshold as a distance from limit
00103       double k3;            // factor used in cubic velocity ramp
00104 
00110       LimitsT(double minPos, double maxPos, double threshold);
00111 
00117       double cubicVelRamp(double angle, double limit) const;
00118     };
00119 
00120     std::vector<LimitsT> limits_;
00121     std::vector<int> limited_joints_;  // list of joints that will be constrained
00122     double weight_;
00123     double threshold_;   // threshold (% of range) at which to engage limit avoidance
00124 
00129     bool nearLowerLimit(size_t idx);
00130 
00135     bool nearUpperLimit(size_t idx);
00136 
00137 };
00138 
00139 } /* namespace constraints */
00140 } /* namespace constrained_ik */
00141 #endif /* AVOID_JOINT_LIMITS_H_ */


constrained_ik
Author(s): Chris Lewis , Jeremy Zoss , Dan Solomon
autogenerated on Mon Oct 6 2014 00:52:26