Debian Codegraph @

orocos_kdl/src/chainiksolvervel_wdls.hpp

raw symbols SCIP
1 // Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>cxx . . $ `<file>/orocos_kdl/src/chainiksolvervel_wdls.hpp`/
2
3 // Version: 1.0
4 // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
5 // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
6 // URL: http://www.orocos.org/kdl
7
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
22 #ifndef KDL_CHAIN_IKSOLVERVEL_WDLS_HPP
23 #define KDL_CHAIN_IKSOLVERVEL_WDLS_HPPcxx . . $ `orocos_kdl/src/chainiksolvervel_wdls.hpp:23:9`!
24
25 #include "chainiksolver.hpp"cxx . . $ `<file>/orocos_kdl/src/chainiksolver.hpp`/
26 #include "chainjnttojacsolver.hpp"cxx . . $ `<file>/orocos_kdl/src/chainjnttojacsolver.hpp`/
27 #include <Eigen/Core>
28
29 namespace KDLcxx . . $ KDL/
30 {
31 /**
32 * Implementation of a inverse velocity kinematics algorithm based
33 * on the weighted pseudo inverse with damped least-square to calculate the velocity
34 * transformation from Cartesian to joint space of a general
35 * KDL::Chain. It uses a svd-calculation based on householders
36 * rotations.
37 *
38 * J# = M_q*Vb*pinv_dls(Db)*Ub'*M_x
39 *
40 * where B = Mx*J*Mq
41 *
42 * and B = Ub*Db*Vb' is the SVD decomposition of B
43 *
44 * Mq and Mx represent, respectively, the joint-space and task-space weighting
45 * matrices.
46 * Please refer to the documentation of setWeightJS(const Eigen::MatrixXd& Mq)
47 * and setWeightTS(const Eigen::MatrixXd& Mx) for details on the effects of
48 * these matrices.
49 *
50 * For more details on Weighted Pseudo Inverse, see :
51 * 1) [Ben Israel 03] A. Ben Israel & T.N.E. Greville.
52 * Generalized Inverses : Theory and Applications,
53 * second edition. Springer, 2003. ISBN 0-387-00293-6.
54 *
55 * 2) [Doty 93] K. L. Doty, C. Melchiorri & C. Boniveto.
56 * A theory of generalized inverses applied to Robotics.
57 * The International Journal of Robotics Research,
58 * vol. 12, no. 1, pages 1-19, february 1993.
59 *
60 *
61 * @ingroup KinematicFamily
62 */
63 class ChainIkSolverVel_wdlscxx . . $ KDL/ChainIkSolverVel_wdls# : public ChainIkSolverVelcxx . . $ KDL/ChainIkSolverVel#
64 {
65 public:
66 /// solution converged but (pseudo)inverse is singular
67 static const int E_CONVERGE_PINV_SINGULARcxx . . $ KDL/ChainIkSolverVel_wdls#E_CONVERGE_PINV_SINGULAR. = +100;
68
69 /**
70 * Constructor of the solver
71 *
72 * @param chain the chain to calculate the inverse velocity
73 * kinematics for
74 * @param eps if a singular value is below this value, its
75 * inverse is set to zero, default: 0.00001
76 * @param maxiter maximum iterations for the svd calculation,
77 * default: 150
78 *
79 */
80
81 explicit ChainIkSolverVel_wdlscxx . . $ KDL/ChainIkSolverVel_wdls#ChainIkSolverVel_wdls(b70972e169095351).(const Chaincxx . . $ KDL/Chain#& chain,double eps=0.00001,int maxiter=150);
82 //=ublas::identity_matrix<double>
83 ~cxx . . $ KDL/ChainIkSolverVel_wdls#`~ChainIkSolverVel_wdls`(ced63f7c635d850d).ChainIkSolverVel_wdlscxx . . $ KDL/ChainIkSolverVel_wdls#();
84
85 /**
86 * Find an output joint velocity \a qdot_out, given a starting joint pose
87 * \a q_init and a desired cartesian velocity \a v_in
88 *
89 * @return
90 * E_NOERROR=svd solution converged in maxiter
91 * E_SVD_FAILED=svd solution failed
92 * E_CONVERGE_PINV_SINGULAR=svd solution converged but (pseudo)inverse singular
93 *
94 * @note if E_CONVERGE_PINV_SINGULAR returned then converged and can
95 * continue motion, but have degraded solution
96 *
97 * @note If E_SVD_FAILED returned, then getSvdResult() returns the error
98 * code from the SVD algorithm.
99 */
100 virtual int CartToJntcxx . . $ KDL/ChainIkSolverVel_wdls#CartToJnt(961079fc69a8143e).(const JntArraycxx . . $ KDL/JntArray#& q_in, const Twistcxx . . $ KDL/Twist#& v_in, JntArraycxx . . $ KDL/JntArray#& qdot_out);
101 /**
102 * not (yet) implemented.
103 *
104 */
105 virtual int CartToJntcxx . . $ KDL/ChainIkSolverVel_wdls#CartToJnt(175220d2a2cf196f).(const JntArraycxx . . $ KDL/JntArray#& /*q_init*/, const FrameVelcxx . . $ KDL/FrameVel#& /*v_in*/, JntArrayVelcxx . . $ KDL/JntArrayVel#& /*q_out*/){return -1;};
106
107 /**
108 * Set the joint space weighting matrix
109 *
110 * @param weight_js joint space weighting symmetric matrix,
111 * default : identity. M_q : This matrix being used as a
112 * weight for the norm of the joint space speed it HAS TO BE
113 * symmetric and positive definite. We can actually deal with
114 * matrices containing a symmetric and positive definite block
115 * and 0s otherwise. Taking a diagonal matrix as an example, a
116 * 0 on the diagonal means that the corresponding joints will
117 * not contribute to the motion of the system. On the other
118 * hand, the bigger the value, the most the corresponding
119 * joint will contribute to the overall motion. The obtained
120 * solution q_dot will actually minimize the weighted norm
121 * sqrt(q_dot'*(M_q^-2)*q_dot). In the special case we deal
122 * with, it does not make sense to invert M_q but what is
123 * important is the physical meaning of all this : a joint
124 * that has a zero weight in M_q will not contribute to the
125 * motion of the system and this is equivalent to saying that
126 * it gets an infinite weight in the norm computation. For
127 * more detailed explanation : [email protected]
128 *
129 * @return success/error code
130 */
131 int setWeightJScxx . . $ KDL/ChainIkSolverVel_wdls#setWeightJS(4d524befcd4cbb1d).(const Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd#& Mq);
132
133 /**
134 * Set the task space weighting matrix
135 *
136 * @param weight_ts task space weighting symmetric matrix,
137 * default: identity M_x : This matrix being used as a weight
138 * for the norm of the error (in terms of task space speed) it
139 * HAS TO BE symmetric and positive definite. We can actually
140 * deal with matrices containing a symmetric and positive
141 * definite block and 0s otherwise. Taking a diagonal matrix
142 * as an example, a 0 on the diagonal means that the
143 * corresponding task coordinate will not be taken into
144 * account (ie the corresponding error can be really big). If
145 * the rank of the jacobian is equal to the number of task
146 * space coordinates which do not have a 0 weight in M_x, the
147 * weighting will actually not impact the results (ie there is
148 * an exact solution to the velocity inverse kinematics
149 * problem). In cases without an exact solution, the bigger
150 * the value, the most the corresponding task coordinate will
151 * be taken into account (ie the more the corresponding error
152 * will be reduced). The obtained solution will minimize the
153 * weighted norm sqrt(|x_dot-Jq_dot|'*(M_x^2)*|x_dot-Jq_dot|).
154 * For more detailed explanation : [email protected]
155 *
156 * @return success/error code
157 */
158 int setWeightTScxx . . $ KDL/ChainIkSolverVel_wdls#setWeightTS(4d524befcd4cbb1d).(const Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd#& Mx);
159
160 /**
161 * Set lambda
162 */
163 void setLambdacxx . . $ KDL/ChainIkSolverVel_wdls#setLambda(ba8836b59fb42830).(const double lambda);
164 /**
165 * Set eps
166 */
167 void setEpscxx . . $ KDL/ChainIkSolverVel_wdls#setEps(ba8836b59fb42830).(const double eps_in);
168 /**
169 * Set maxIter
170 */
171 void setMaxItercxx . . $ KDL/ChainIkSolverVel_wdls#setMaxIter(d4f767463ce0a6b3).(const int maxiter_in);
172
173 /**
174 * Request the number of singular values of the jacobian that are < eps;
175 * if the number of near zero singular values is > jac.col()-jac.row(),
176 * then the jacobian pseudoinverse is singular
177 */
178 unsigned int getNrZeroSigmascxx . . $ KDL/ChainIkSolverVel_wdls#getNrZeroSigmas(ddd8539a2fcdd4ce).()const {return nrZeroSigmascxx . . $ KDL/ChainIkSolverVel_wdls#nrZeroSigmas.;};
179
180 /**
181 * Request the minimum of the first six singular values
182 */
183 double getSigmaMincxx . . $ KDL/ChainIkSolverVel_wdls#getSigmaMin(21b6c25e127938e2).()const {return sigmaMincxx . . $ KDL/ChainIkSolverVel_wdls#sigmaMin.;};
184
185 /**
186 * Request the six singular values of the Jacobian
187 */
188 int getSigmacxx . . $ KDL/ChainIkSolverVel_wdls#getSigma(9f5a56d7ee91eb72).(Eigencxx . . $ Eigen/::VectorXdcxx . . $ Eigen/VectorXd#& Sout);
189
190 /**
191 * Request the value of eps
192 */
193 double getEpscxx . . $ KDL/ChainIkSolverVel_wdls#getEps(21b6c25e127938e2).()const {return epscxx . . $ KDL/ChainIkSolverVel_wdls#eps.;};
194
195 /**
196 * Request the value of lambda for the minimum
197 */
198 double getLambdacxx . . $ KDL/ChainIkSolverVel_wdls#getLambda(21b6c25e127938e2).()const {return lambdacxx . . $ KDL/ChainIkSolverVel_wdls#lambda.;};
199
200 /**
201 * Request the scaled value of lambda for the minimum
202 * singular value 1-6
203 */
204 double getLambdaScaledcxx . . $ KDL/ChainIkSolverVel_wdls#getLambdaScaled(21b6c25e127938e2).()const {return lambda_scaledcxx . . $ KDL/ChainIkSolverVel_wdls#lambda_scaled.;};
205
206 /**
207 * Retrieve the latest return code from the SVD algorithm
208 * @return 0 if CartToJnt() not yet called, otherwise latest SVD result code.
209 */
210 int getSVDResultcxx . . $ KDL/ChainIkSolverVel_wdls#getSVDResult(455f465bc33b4cdf).()const {return svdResultcxx . . $ KDL/ChainIkSolverVel_wdls#svdResult.;};
211
212 /// @copydoc KDL::SolverI::strError()
213 virtual const char* strErrorcxx . . $ KDL/ChainIkSolverVel_wdls#strError(afbf07f2bc1a9437).(const int error) const;
214
215 /// @copydoc KDL::SolverI::updateInternalDataStructures()
216 virtual void updateInternalDataStructurescxx . . $ KDL/ChainIkSolverVel_wdls#updateInternalDataStructures(49f6e7a06ebc5aa8).();
217
218 private:
219 const Chaincxx . . $ KDL/Chain#& chaincxx . . $ KDL/ChainIkSolverVel_wdls#chain.;
220 ChainJntToJacSolvercxx . . $ KDL/ChainJntToJacSolver# jnt2jaccxx . . $ KDL/ChainIkSolverVel_wdls#jnt2jac.;
221 unsigned int njcxx . . $ KDL/ChainIkSolverVel_wdls#nj.;
222 Jacobiancxx . . $ KDL/Jacobian# jaccxx . . $ KDL/ChainIkSolverVel_wdls#jac.;
223 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# Ucxx . . $ KDL/ChainIkSolverVel_wdls#U.;
224 Eigencxx . . $ Eigen/::VectorXdcxx . . $ Eigen/VectorXd# Scxx . . $ KDL/ChainIkSolverVel_wdls#S.;
225 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# Vcxx . . $ KDL/ChainIkSolverVel_wdls#V.;
226 double epscxx . . $ KDL/ChainIkSolverVel_wdls#eps.;
227 int maxitercxx . . $ KDL/ChainIkSolverVel_wdls#maxiter.;
228 Eigencxx . . $ Eigen/::VectorXdcxx . . $ Eigen/VectorXd# tmpcxx . . $ KDL/ChainIkSolverVel_wdls#tmp.;
229 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# tmp_jaccxx . . $ KDL/ChainIkSolverVel_wdls#tmp_jac.;
230 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# tmp_jac_weight1cxx . . $ KDL/ChainIkSolverVel_wdls#tmp_jac_weight1.;
231 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# tmp_jac_weight2cxx . . $ KDL/ChainIkSolverVel_wdls#tmp_jac_weight2.;
232 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# tmp_tscxx . . $ KDL/ChainIkSolverVel_wdls#tmp_ts.;
233 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# tmp_jscxx . . $ KDL/ChainIkSolverVel_wdls#tmp_js.;
234 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# weight_tscxx . . $ KDL/ChainIkSolverVel_wdls#weight_ts.;
235 Eigencxx . . $ Eigen/::MatrixXdcxx . . $ Eigen/MatrixXd# weight_jscxx . . $ KDL/ChainIkSolverVel_wdls#weight_js.;
236 double lambdacxx . . $ KDL/ChainIkSolverVel_wdls#lambda.;
237 double lambda_scaledcxx . . $ KDL/ChainIkSolverVel_wdls#lambda_scaled.;
238 unsigned int nrZeroSigmascxx . . $ KDL/ChainIkSolverVel_wdls#nrZeroSigmas. ;
239 int svdResultcxx . . $ KDL/ChainIkSolverVel_wdls#svdResult.;
240 double sigmaMincxx . . $ KDL/ChainIkSolverVel_wdls#sigmaMin.;
241 };
242 }
243 #endif
244