Orocos KDL
frames.hpp
1/***************************************************************************
2 frames.hpp `- description
3 -------------------------
4 begin : June 2006
5 copyright : (C) 2006 Erwin Aertbelien
6 email : firstname.lastname@mech.kuleuven.be
7
8 History (only major changes)( AUTHOR-Description ) :
9
10 ***************************************************************************
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of the GNU Lesser General Public *
13 * License as published by the Free Software Foundation; either *
14 * version 2.1 of the License, or (at your option) any later version. *
15 * *
16 * This library is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19 * Lesser General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU Lesser General Public *
22 * License along with this library; if not, write to the Free Software *
23 * Foundation, Inc., 59 Temple Place, *
24 * Suite 330, Boston, MA 02111-1307 USA *
25 * *
26 ***************************************************************************/
27
37 * A naming convention of objects of the type defined in this file :
38 * (1) Frame : F...
39 * Rotation : R ...
40 * (2) Twist : T ...
41 * Wrench : W ...
42 * Vector : V ...
43 * This prefix is followed by :
44 * for category (1) :
45 * F_A_B : w.r.t. frame A, frame B expressed
46 * ( each column of F_A_B corresponds to an axis of B,
47 * expressed w.r.t. frame A )
48 * in mathematical convention :
49 * A
50 * F_A_B == F
51 * B
52 *
53 * for category (2) :
54 * V_B : a vector expressed w.r.t. frame B
55 *
56 * This can also be prepended by a name :
57 * e.g. : temporaryV_B
58 *
59 * With this convention one can write :
60 *
61 * F_A_B = F_B_A.Inverse();
62 * F_A_C = F_A_B * F_B_C;
63 * V_B = F_B_C * V_C; // both translation and rotation
64 * V_B = R_B_C * V_C; // only rotation
65 * \endverbatim
66 *
67 * \par CONVENTIONS FOR WHEN USED WITH ROBOTS :
68 *
69 * \verbatim
70 * world : represents the frame ([1 0 0,0 1 0,0 0 1],[0 0 0]')
71 * mp : represents mounting plate of a robot
72 * (i.e. everything before MP is constructed by robot manufacturer
73 * everything after MP is tool )
74 * tf : represents task frame of a robot
75 * (i.e. frame in which motion and force control is expressed)
76 * sf : represents sensor frame of a robot
77 * (i.e. frame at which the forces measured by the force sensor
78 * are expressed )
79 *
80 * Frame F_world_mp=...;
81 * Frame F_mp_sf(..)
82 * Frame F_mp_tf(,.)
83 *
84 * Wrench are measured in sensor frame SF, so one could write :
85 * Wrench_tf = F_mp_tf.Inverse()* ( F_mp_sf * Wrench_sf );
86 * \endverbatim
87 *
88 * \par CONVENTIONS REGARDING UNITS :
89 * Any consistent series of units can be used, e.g. N,mm,Nmm,..mm/sec
90 *
91 * \par Twist and Wrench transformations
92 * 3 different types of transformations do exist for the twists
93 * and wrenches.
94 *
95 * \verbatim
96 * 1) Frame * Twist or Frame * Wrench :
97 * this transforms both the velocity/force reference point
98 * and the basis to which the twist/wrench are expressed.
99 * 2) Rotation * Twist or Rotation * Wrench :
100 * this transforms the basis to which the twist/wrench are
101 * expressed, but leaves the reference point intact.
102 * 3) Twist.RefPoint(v_base_AB) or Wrench.RefPoint(v_base_AB)
103 * this transforms only the reference point. v is expressed
104 * in the same base as the twist/wrench and points from the
105 * old reference point to the new reference point.
106 * \endverbatim
107 *
108 *\par Spatial cross products
109 * Let m be a 6D motion vector (Twist) and f be a 6D force vector (Wrench)
110 * attached to a rigid body moving with a certain velocity v (Twist). Then
111 *\verbatim
112 * 1) m_dot = v cross m or Twist=Twist*Twist
113 * 2) f_dot = v cross f or Wrench=Twist*Wrench
114 *\endverbatim
115 *
116 * \par Complexity
117 * Sometimes the amount of work is given in the documentation
118 * e.g. 6M+3A means 6 multiplications and 3 additions.
119 *
120 * \author
121 * Erwin Aertbelien, Div. PMA, Dep. of Mech. Eng., K.U.Leuven
122 *
123 ****************************************************************************/
124#ifndef KDL_FRAMES_H
125#define KDL_FRAMES_H
126
127
128#include "utilities/kdl-config.h"
129#include "utilities/utility.h"
130#include "utilities/hash_combine.h"
131
132#include <functional>
133
135
136namespace KDL {
137
138
139class Vector;
140class Rotation;
141class Frame;
142class Wrench;
143class Twist;
145class Rotation2;
146class Frame2;
147
148
149// Equal is friend function, but default arguments for friends are forbidden (ยง8.3.6.4)
150inline bool Equal(const Vector& a,const Vector& b,double eps=epsilon);
151inline bool Equal(const Frame& a,const Frame& b,double eps=epsilon);
152inline bool Equal(const Twist& a,const Twist& b,double eps=epsilon);
153inline bool Equal(const Wrench& a,const Wrench& b,double eps=epsilon);
154inline bool Equal(const Vector2& a,const Vector2& b,double eps=epsilon);
155inline bool Equal(const Rotation2& a,const Rotation2& b,double eps=epsilon);
156inline bool Equal(const Frame2& a,const Frame2& b,double eps=epsilon);
158
163{
164public:
165 double data[3];
166 //! Does not initialise the Vector to zero. use Vector::Zero() or SetToZero for that
167 inline Vector() {data[0]=data[1]=data[2] = 0.0;}
168
170 inline Vector(double x,double y, double z);
171
173 inline Vector(const Vector& arg);
174
176 inline Vector& operator = ( const Vector& arg);
177
179 inline double operator()(int index) const;
180
181 //! Access to elements, range checked when NDEBUG is not set, from 0..2
182 inline double& operator() (int index);
183
185 double operator[] ( int index ) const
187 return this->operator() ( index );
188 }
189
190
191 double& operator[] ( int index )
193 return this->operator() ( index );
194 }
195
196 inline double x() const;
197 inline double y() const;
198 inline double z() const;
199 inline void x(double);
200 inline void y(double);
201 inline void z(double);
202
204 inline void ReverseSign();
205
206
208 inline Vector& operator-=(const Vector& arg);
209
212 inline Vector& operator +=(const Vector& arg);
213
215 inline friend Vector operator*(const Vector& lhs,double rhs);
216
217 inline friend Vector operator*(double lhs,const Vector& rhs);
219
220 inline friend Vector operator/(const Vector& lhs,double rhs);
221 inline friend Vector operator+(const Vector& lhs,const Vector& rhs);
222 inline friend Vector operator-(const Vector& lhs,const Vector& rhs);
223 inline friend Vector operator*(const Vector& lhs,const Vector& rhs);
224 inline friend Vector operator-(const Vector& arg);
225 inline friend double dot(const Vector& lhs,const Vector& rhs);
226
229 inline friend void SetToZero(Vector& v);
230
232 inline static Vector Zero();
239 double Normalize(double eps=epsilon);
240
241
242 double Norm(double eps=epsilon) const;
244
245
247 inline void Set2DXY(const Vector2& v);
248 //! a 3D vector where the 2D vector v is put in the YZ plane
249 inline void Set2DYZ(const Vector2& v);
251 inline void Set2DZX(const Vector2& v);
252
253 inline void Set2DPlane(const Frame& F_someframe_XY,const Vector2& v_XY);
254
255
257
258 inline friend bool Equal(const Vector& a,const Vector& b,double eps);
261 inline friend bool operator==(const Vector& a,const Vector& b);
263 inline friend bool operator!=(const Vector& a,const Vector& b);
265 friend class Rotation;
266 friend class Frame;
267};
268
269
270/**
271 \brief represents rotations in 3 dimensional space.
272
273 This class represents a rotation matrix with the following
274 conventions :
275 \verbatim
276 Suppose V2 = R*V, (1)
277 V is expressed in frame B
278 V2 is expressed in frame A
279 This matrix R consists of 3 columns [ X,Y,Z ],
280 X,Y, and Z contain the axes of frame B, expressed in frame A
281 Because of linearity expr(1) is valid.
282 \endverbatim
283 This class only represents rotational_interpolation, not translation
284 Two interpretations are possible for rotation angles.
285 * if you rotate with angle around X frame A to have frame B,
286 then the result of SetRotX is equal to frame B expressed wrt A.
287 In code:
288 \verbatim
289 Rotation R;
290 F_A_B = R.SetRotX(angle);
291 \endverbatim
292 * Secondly, if you take the following code :
293 \verbatim
294 Vector p,p2; Rotation R;
295 R.SetRotX(angle);
296 p2 = R*p;
297 \endverbatim
298 then the frame p2 is rotated around X axis with (-angle).
299 Analogue reasonings can be applyd to SetRotY,SetRotZ,SetRot
300 \par type
301 Concrete implementation
302*/
304{
305public:
306 double data[9];
307
308 inline Rotation() {
309 *this = Rotation::Identity();
310 }
311 inline Rotation(double Xx,double Yx,double Zx,
312 double Xy,double Yy,double Zy,
313 double Xz,double Yz,double Zz);
314 inline Rotation(const Vector& x,const Vector& y,const Vector& z);
315
316 inline Rotation(const Rotation& arg);
317
318 inline Rotation& operator=(const Rotation& arg);
319
320 //! Defines a multiplication R*V between a Rotation R and a Vector V.
321 //! Complexity : 9M+6A
322 inline Vector operator*(const Vector& v) const;
323
325 inline double& operator()(int i,int j);
326
327 //! Access to elements 0..2,0..2, bounds are checked when NDEBUG is not set
328 inline double operator() (int i,int j) const;
329
330 friend Rotation operator *(const Rotation& lhs,const Rotation& rhs);
331
333 inline void SetInverse();
334
335
336 inline Rotation Inverse() const;
337
339 inline Vector Inverse(const Vector& v) const;
340
342 inline Wrench Inverse(const Wrench& arg) const;
343
344
345 inline Twist Inverse(const Twist& arg) const;
348 inline static Rotation Identity();
349
350
351// = Rotations
353 inline static Rotation RotX(double angle);
355 inline static Rotation RotY(double angle);
356 //! The Rot... static functions give the value of the appropriate rotation matrix back.
357 inline static Rotation RotZ(double angle);
360 inline void DoRotX(double angle);
362 //! DoRot... functions are only defined when they can be executed more efficiently
363 inline void DoRotY(double angle);
366 inline void DoRotZ(double angle);
371 // @see Rot2 if you want to handle this error in another way.
372 static Rotation Rot(const Vector& rotvec,double angle);
375 static Rotation Rot2(const Vector& rotvec,double angle);
376
377
379 Vector GetRot() const;
384
384 * to be +/- Z-axis
385 * in the case of angle == PI : 2 solutions, positive Z-component
386 * of the axis is chosen.
387 * @result returns the rotation angle (between [0..PI] )
388 */
389 double GetRotAngle(Vector& axis,double eps=epsilon) const;
390
391
394
395 * - then around new Z with gamma.
396 * Invariants:
397 * - EulerZYX(alpha,beta,gamma) == EulerZYX(alpha +/- PHI, -beta, gamma +/- PI)
398 * - (angle + 2*k*PI)
399 **/
400 static Rotation EulerZYZ(double Alfa,double Beta,double Gamma);
406
407 Variables are bound by:
408 - (-PI < alpha <= PI),
409 - (0 <= beta <= PI),
410 - (-PI < gamma <= PI)
411
412 if beta==0 or beta==PI, then alpha and gamma are not unique, in this case gamma is chosen to be zero.
413 Invariants:
414 - EulerZYX(alpha,beta,gamma) == EulerZYX(alpha +/- PI, -beta, gamma +/- PI)
415 - angle + 2*k*PI
416 */
417 void GetEulerZYZ(double& alpha,double& beta,double& gamma) const;
421 static Rotation Quaternion(double x,double y,double z, double w);
422
423 //! Get the quaternion of this matrix
424 //! \post the norm of (x,y,z,w) is 1
425 void GetQuaternion(double& x,double& y,double& z, double& w) const;
426
427
429 * Gives back a rotation matrix specified with RPY convention:
430 * first rotate around X with roll, then around the
431 * old Y with pitch, then around old Z with yaw
432 *
433 * Invariants:
434 * - RPY(roll,pitch,yaw) == RPY( roll +/- PI, PI-pitch, yaw +/- PI )
435 * - angles + 2*k*PI
436 */
437 static Rotation RPY(double roll,double pitch,double yaw);
438
439
441 - -PI <= Yaw <= PI
442 - -PI/2 <= PITCH <= PI/2
443
444 convention :
445 - first rotate around X with roll,
446 - then around the old Y with pitch,
447 - then around old Z with yaw
448
449 if pitch == PI/2 or pitch == -PI/2, multiple solutions for gamma and alpha exist. The solution where roll==0
450 is chosen.
451
452 Invariants:
453 - RPY(roll,pitch,yaw) == RPY( roll +/- PI, PI-pitch, yaw +/- PI )
454 - angles + 2*k*PI
455
456**/
457 void GetRPY(double& roll,double& pitch,double& yaw) const;
458
467
467 * Invariants:
468 * - EulerZYX(alpha,beta,gamma) == EulerZYX(alpha +/- PI, PI-beta, gamma +/- PI)
469 * - (angle + 2*k*PI)
470 **/
471 inline static Rotation EulerZYX(double Alfa,double Beta,double Gamma) {
472 return RPY(Gamma,Beta,Alfa);
473 }
474
475
476 * First rotate around Z with alfa,
477 * then around the new Y with beta, then around
478 * new X with gamma.
479 *
480 * Range of the results of GetEulerZYX :
481 * - -PI <= alfa <= PI
482 * - -PI <= gamma <= PI
483 * - -PI/2 <= beta <= PI/2
484 *
485 * if beta == PI/2 or beta == -PI/2, multiple solutions for gamma and alpha exist. The solution where gamma==0
486 * is chosen.
487 *
488 *
489 * Invariants:
490 * - EulerZYX(alpha,beta,gamma) == EulerZYX(alpha +/- PI, PI-beta, gamma +/- PI)
491 * - and also (angle + 2*k*PI)
492 *
493 * Closely related to RPY-convention.
494 **/
495 inline void GetEulerZYX(double& Alfa,double& Beta,double& Gamma) const {
496 GetRPY(Gamma,Beta,Alfa);
497 }
498
499 //! Transformation of the base to which the twist is expressed.
500 //! Complexity : 18M+12A
501 //! @see Frame*Twist for a transformation that also transforms
502 //! the velocity reference point.
503 inline Twist operator * (const Twist& arg) const;
504
507
509 inline Wrench operator * (const Wrench& arg) const;
510
512 inline Vector UnitX() const {
513 return Vector(data[0],data[3],data[6]);
514 }
515
516 //! Access to the underlying unitvectors of the rotation matrix
517 inline void UnitX(const Vector& X) {
518 data[0] = X(0);
519 data[3] = X(1);
520 data[6] = X(2);
522
524 inline Vector UnitY() const {
525 return Vector(data[1],data[4],data[7]);
526 }
529 inline void UnitY(const Vector& X) {
530 data[1] = X(0);
531 data[4] = X(1);
532 data[7] = X(2);
533 }
534
535
536 inline Vector UnitZ() const {
537 return Vector(data[2],data[5],data[8]);
538 }
539
541 inline void UnitZ(const Vector& X) {
542 data[2] = X(0);
543 data[5] = X(1);
544 data[8] = X(2);
546
549 friend bool Equal(const Rotation& a,const Rotation& b,double eps);
550
552 friend bool operator==(const Rotation& a,const Rotation& b);
553 //! The literal inequality operator!=()
554 friend bool operator!=(const Rotation& a,const Rotation& b);
555
556 friend class Frame;
558 bool operator==(const Rotation& a,const Rotation& b);
559 bool Equal(const Rotation& a,const Rotation& b,double eps=epsilon);
560
561
562
572class Frame {
573public:
576
577public:
578
579 inline Frame(const Rotation& R,const Vector& V);
580
582 explicit inline Frame(const Vector& V);
584 explicit inline Frame(const Rotation& R);
585
586 inline Frame() {}
588 inline Frame(const Frame& arg);
591 //\TODO should be formulated as a constructor
592 void Make4x4(double* d);
593
596 inline double operator()(int i,int j);
597
600 inline double operator() (int i,int j) const;
601
602// = Inverse
604 inline Frame Inverse() const;
605
606 //! The same as p2=R.Inverse()*p but more efficient.
607 inline Vector Inverse(const Vector& arg) const;
608
610 inline Wrench Inverse(const Wrench& arg) const;
613 inline Twist Inverse(const Twist& arg) const;
614
616 inline Frame& operator = (const Frame& arg);
617
620 inline Vector operator * (const Vector& arg) const;
621
625 //! of only the base to which the twist is expressed.
626 //!
627 //! Complexity : 24M+18A
628 inline Wrench operator * (const Wrench& arg) const;
629
636 inline Twist operator * (const Twist& arg) const;
637
638 //! Composition of two frames.
639 inline friend Frame operator *(const Frame& lhs,const Frame& rhs);
640
642 inline static Frame Identity();
643
644
645 //! frame. This frame is integrated into an updated frame with
646 //! <samplefrequency>. Very simple first order integration rule.
647 inline void Integrate(const Twist& t_this,double frequency);
648
649 /*
650 // DH_Craig1989 : constructs a transformationmatrix
651 // T_link(i-1)_link(i) with the Denavit-Hartenberg convention as
652 // described in the Craigs book: Craig, J. J.,Introduction to
653 // Robotics: Mechanics and Control, Addison-Wesley,
654 // isbn:0-201-10326-5, 1986.
655 //
656 // Note that the frame is a redundant way to express the information
657 // in the DH-convention.
658 // \verbatim
659 // Parameters in full : a(i-1),alpha(i-1),d(i),theta(i)
660 //
661 // axis i-1 is connected by link i-1 to axis i numbering axis 1
662 // to axis n link 0 (immobile base) to link n
663 //
664 // link length a(i-1) length of the mutual perpendicular line
665 // (normal) between the 2 axes. This normal runs from (i-1) to
666 // (i) axis.
667 //
668 // link twist alpha(i-1): construct plane perpendicular to the
669 // normal project axis(i-1) and axis(i) into plane angle from
670 // (i-1) to (i) measured in the direction of the normal
671 //
672 // link offset d(i) signed distance between normal (i-1) to (i)
673 // and normal (i) to (i+1) along axis i joint angle theta(i)
674 // signed angle between normal (i-1) to (i) and normal (i) to
675 // (i+1) along axis i
676 //
677 // First and last joints : a(0)= a(n) = 0
678 // alpha(0) = alpha(n) = 0
679 //
680 // PRISMATIC : theta(1) = 0 d(1) arbitrarily
681 //
682 // REVOLUTE : theta(1) arbitrarily d(1) = 0
683 //
684 // Not unique : if intersecting joint axis 2 choices for normal
685 // Frame assignment of the DH convention : Z(i-1) follows axis
686 // (i-1) X(i-1) is the normal between axis(i-1) and axis(i)
687 // Y(i-1) follows out of Z(i-1) and X(i-1)
688 //
689 // a(i-1) = distance from Z(i-1) to Z(i) along X(i-1)
690 // alpha(i-1) = angle between Z(i-1) to Z(i) along X(i-1)
691 // d(i) = distance from X(i-1) to X(i) along Z(i)
692 // theta(i) = angle between X(i-1) to X(i) along X(i)
693 // \endverbatim
694 */
695 static Frame DH_Craig1989(double a,double alpha,double d,double theta);
696
697 // DH : constructs a transformationmatrix T_link(i-1)_link(i) with
698 // the Denavit-Hartenberg convention as described in the original
699 // publictation: Denavit, J. and Hartenberg, R. S., A kinematic
700 // notation for lower-pair mechanisms based on matrices, ASME
701 // Journal of Applied Mechanics, 23:215-221, 1955.
702
703 static Frame DH(double a,double alpha,double d,double theta);
704
705
708 inline friend bool Equal(const Frame& a,const Frame& b,double eps);
709
711 inline friend bool operator==(const Frame& a,const Frame& b);
713 inline friend bool operator!=(const Frame& a,const Frame& b);
714};
715
716
723class Twist {
724public:
727public:
728
730 Twist():vel(),rot() {};
731
732 Twist(const Vector& _vel,const Vector& _rot):vel(_vel),rot(_rot) {};
733
734 inline Twist& operator-=(const Twist& arg);
735 inline Twist& operator+=(const Twist& arg);
737 inline double& operator()(int i);
741 inline double operator()(int i) const;
742
743 double operator[] ( int index ) const
744 {
745 return this->operator() ( index );
747
748 double& operator[] ( int index )
749 {
750 return this->operator() ( index );
752
753 inline friend Twist operator*(const Twist& lhs,double rhs);
754 inline friend Twist operator*(double lhs,const Twist& rhs);
755 inline friend Twist operator/(const Twist& lhs,double rhs);
756 inline friend Twist operator+(const Twist& lhs,const Twist& rhs);
757 inline friend Twist operator-(const Twist& lhs,const Twist& rhs);
758 inline friend Twist operator-(const Twist& arg);
759 inline friend double dot(const Twist& lhs,const Wrench& rhs);
760 inline friend double dot(const Wrench& rhs,const Twist& lhs);
761 inline friend void SetToZero(Twist& v);
763 inline friend Twist operator*(const Twist& lhs,const Twist& rhs);
765 inline friend Wrench operator*(const Twist& lhs,const Wrench& rhs);
768 static inline Twist Zero();
769
770
771 inline void ReverseSign();
772
777
778 //! Complexity : 6M+6A
779 inline Twist RefPoint(const Vector& v_base_AB) const;
780
781
784 inline friend bool Equal(const Twist& a,const Twist& b,double eps);
787 inline friend bool operator==(const Twist& a,const Twist& b);
788
789 inline friend bool operator!=(const Twist& a,const Twist& b);
790
791// = Friends
792 friend class Rotation;
793 friend class Frame;
795
796
799
805class AccelerationTwist {
806public:
807 Vector trans; //!< The translational acceleration of that point
808 Vector rot; //!< The rotational acceleration of that point.
809public:
810
812 AccelerationTwist():trans(),rot() {};
813
814 AccelerationTwist(const Vector& _trans,const Vector& _rot):trans(_trans),rot(_rot) {};
815
816 inline AccelerationTwist& operator-=(const AccelerationTwist& arg);
817 inline AccelerationTwist& operator+=(const AccelerationTwist& arg);
818
819 inline double& operator()(int i);
823 inline double operator()(int i) const;
824
825 double operator[] ( int index ) const
827 return this->operator() ( index );
828 }
829
830 double& operator[] ( int index )
831 {
832 return this->operator() ( index );
833 }
834
835 inline friend AccelerationTwist operator*(const AccelerationTwist& lhs,double rhs);
836 inline friend AccelerationTwist operator*(double lhs,const AccelerationTwist& rhs);
837 inline friend AccelerationTwist operator/(const AccelerationTwist& lhs,double rhs);
838 inline friend AccelerationTwist operator+(const AccelerationTwist& lhs,const AccelerationTwist& rhs);
839 inline friend AccelerationTwist operator-(const AccelerationTwist& lhs,const AccelerationTwist& rhs);
840 inline friend AccelerationTwist operator-(const AccelerationTwist& arg);
841 //inline friend double dot(const AccelerationTwist& lhs,const Wrench& rhs);
842 //inline friend double dot(const Wrench& rhs,const AccelerationTwist& lhs);
843 inline friend void SetToZero(AccelerationTwist& v);
844
845
847 static inline AccelerationTwist Zero();
850 inline void ReverseSign();
851
852 //! Changes the reference point of the AccelerationTwist.
853 //! The vector v_base_AB is expressed in the same base as the AccelerationTwist
854 //! The vector v_base_AB is a vector from the old point to
855 //! the new point.
856 //!
857 //! Complexity : 6M+6A
858 inline AccelerationTwist RefPoint(const Vector& v_base_AB) const;
859
860
861 //! do not use operator == because the definition of Equal(.,.) is slightly
862 //! different. It compares whether the 2 arguments are equal in an eps-interval
863 inline friend bool Equal(const AccelerationTwist& a,const AccelerationTwist& b,double eps=epsilon);
864
866 inline friend bool operator==(const AccelerationTwist& a,const AccelerationTwist& b);
868 inline friend bool operator!=(const AccelerationTwist& a,const AccelerationTwist& b);
869
870// = Friends
871 friend class Rotation;
872 friend class Frame;
873
874};
878
879 * This class represents a Wrench. A Wrench is the force and torque applied at a point
880 */
882{
886public:
890 Wrench(const Vector& _force,const Vector& _torque):force(_force),torque(_torque) {};
892// = Operators
893 inline Wrench& operator-=(const Wrench& arg);
894 inline Wrench& operator+=(const Wrench& arg);
895
896
897 inline double& operator()(int i);
898
900
901 inline double operator()(int i) const;
902
903 double operator[] ( int index ) const
904 {
905 return this->operator() ( index );
906 }
907
908 double& operator[] ( int index )
909 {
910 return this->operator() ( index );
911 }
912
913 //! Scalar multiplication
914 inline friend Wrench operator*(const Wrench& lhs,double rhs);
916 inline friend Wrench operator*(double lhs,const Wrench& rhs);
918 inline friend Wrench operator/(const Wrench& lhs,double rhs);
920 inline friend Wrench operator+(const Wrench& lhs,const Wrench& rhs);
921 inline friend Wrench operator-(const Wrench& lhs,const Wrench& rhs);
922
924 inline friend Wrench operator-(const Wrench& arg);
928 inline friend void SetToZero(Wrench& v);
929
930
931 static inline Wrench Zero();
932
934 inline void ReverseSign();
935
936 //! Changes the reference point of the wrench.
937 //! The vector v_base_AB is expressed in the same base as the twist
938 //! The vector v_base_AB is a vector from the old point to
939 //! the new point.
940 //!
941 //! Complexity : 6M+6A
942 inline Wrench RefPoint(const Vector& v_base_AB) const;
943
944
945
946 //! different. It compares whether the 2 arguments are equal in an eps-interval
947 inline friend bool Equal(const Wrench& a,const Wrench& b,double eps);
948
950 inline friend bool operator==(const Wrench& a,const Wrench& b);
951
952 inline friend bool operator!=(const Wrench& a,const Wrench& b);
953
954 friend class Rotation;
955 friend class Frame;
956};
957
958
961{
962 double data[2];
963public:
965 Vector2() {data[0]=data[1] = 0.0;}
966 inline Vector2(double x,double y);
967 inline Vector2(const Vector2& arg);
968
969 inline Vector2& operator = ( const Vector2& arg);
970
972 inline double operator()(int index) const;
973
974 //! Access to elements, range checked when NDEBUG is not set, from 0..1
975 inline double& operator() (int index);
976
977
978 double operator[] ( int index ) const
980 return this->operator() ( index );
981 }
982
984 double& operator[] ( int index )
985 {
986 return this->operator() ( index );
987 }
988
989 inline double x() const;
990 inline double y() const;
991 inline void x(double);
992 inline void y(double);
993
994 inline void ReverseSign();
995 inline Vector2& operator-=(const Vector2& arg);
996 inline Vector2& operator +=(const Vector2& arg);
997
998
999 inline friend Vector2 operator*(const Vector2& lhs,double rhs);
1000 inline friend Vector2 operator*(double lhs,const Vector2& rhs);
1001 inline friend Vector2 operator/(const Vector2& lhs,double rhs);
1002 inline friend Vector2 operator+(const Vector2& lhs,const Vector2& rhs);
1003 inline friend Vector2 operator-(const Vector2& lhs,const Vector2& rhs);
1004 inline friend Vector2 operator*(const Vector2& lhs,const Vector2& rhs);
1005 inline friend Vector2 operator-(const Vector2& arg);
1006 inline friend void SetToZero(Vector2& v);
1007
1009 inline static Vector2 Zero();
1010
1013 * if v is smaller than eps, Vector(1,0,0) is returned with norm 0.
1014 * if this is not good, check the return value of this method.
1015 */
1016 double Normalize(double eps=epsilon);
1019 double Norm(double eps=epsilon) const;
1020
1021 //! projects v in its XY plane, and sets *this to these values
1022 inline void Set3DXY(const Vector& v);
1023
1024
1025 inline void Set3DYZ(const Vector& v);
1026
1028 inline void Set3DZX(const Vector& v);
1029
1033 inline void Set3DPlane(const Frame& F_someframe_XY,const Vector& v_someframe);
1034
1035
1038 inline friend bool Equal(const Vector2& a,const Vector2& b,double eps);
1039
1040 //! The literal equality operator==(), also identical.
1041 inline friend bool operator==(const Vector2& a,const Vector2& b);
1043 inline friend bool operator!=(const Vector2& a,const Vector2& b);
1044
1045 friend class Rotation2;
1046};
1047
1048
1049
1050//! of the methods see Rotation class.
1052{
1053 double s,c;
1055 //! from outside, this class behaves as if it would store the complete 2x2 matrix.
1056public:
1058 Rotation2() {c=1.0;s=0.0;}
1059
1060 explicit Rotation2(double angle_rad):s(sin(angle_rad)),c(cos(angle_rad)) {}
1061
1062 Rotation2(double ca,double sa):s(sa),c(ca){}
1063
1065
1066 inline Rotation2& operator=(const Rotation2& arg);
1067 inline Vector2 operator*(const Vector2& v) const;
1068
1069 inline double operator() (int i,int j) const;
1070
1071 inline friend Rotation2 operator *(const Rotation2& lhs,const Rotation2& rhs);
1073 inline void SetInverse();
1074 inline Rotation2 Inverse() const;
1075 inline Vector2 Inverse(const Vector2& v) const;
1077 inline void SetIdentity();
1078 inline static Rotation2 Identity();
1079
1080
1081 //! The SetRot.. functions set the value of *this to the appropriate rotation matrix.
1082 inline void SetRot(double angle);
1083
1084
1085 inline static Rotation2 Rot(double angle);
1086
1088 inline double GetRot() const;
1089
1092 inline friend bool Equal(const Rotation2& a,const Rotation2& b,double eps);
1093};
1094
1095
1099 {
1100public:
1103
1104public:
1105
1106 inline Frame2(const Rotation2& R,const Vector2& V);
1107 explicit inline Frame2(const Vector2& V);
1108 explicit inline Frame2(const Rotation2& R);
1109 inline Frame2(void);
1110 inline Frame2(const Frame2& arg);
1111 inline void Make4x4(double* d);
1112
1115 inline double operator()(int i,int j);
1116
1119 inline double operator() (int i,int j) const;
1120
1121 inline void SetInverse();
1122 inline Frame2 Inverse() const;
1123 inline Vector2 Inverse(const Vector2& arg) const;
1124 inline Frame2& operator = (const Frame2& arg);
1125 inline Vector2 operator * (const Vector2& arg) const;
1126 inline friend Frame2 operator *(const Frame2& lhs,const Frame2& rhs);
1127 inline void SetIdentity();
1128 inline void Integrate(const Twist& t_this,double frequency);
1129 inline static Frame2 Identity() {
1131 tmp.SetIdentity();
1132 return tmp;
1133 }
1134 inline friend bool Equal(const Frame2& a,const Frame2& b,double eps);
1135};
1136
1138
1140 * see diff for Rotation matrices for further background information.
1141 *
1142 * \param p_w_a start vector a expressed to some frame w
1143 * \param p_w_b end vector b expressed to some frame w .
1144 * \param dt [optional][obsolete] time interval over which the numerical differentiation takes place.
1145 * \return the difference (b-a) expressed to the frame w.
1146 */
1147IMETHOD Vector diff(const Vector& p_w_a,const Vector& p_w_b,double dt=1);
1148
1155
1157 * This definition is chosen in this way to facilitate numerical differentiation.
1158 * With this definition diff(a,b) == -diff(b,a).
1159 *
1160 * The diff() function is overloaded for all classes in frames.hpp and framesvel.hpp, such that
1161 * numerical differentiation, equality checks with tolerances, etc. can be performed
1162 * without caring exactly on which type the operation is performed.
1163 *
1164 * \param R_a_b1: The rotation matrix \f$ _a^{b1} R \f$ of b1 with respect to frame a.
1165 * \param R_a_b2: The Rotation matrix \f$ _a^{b2} R \f$ of b2 with respect to frame a.
1166 * \param dt [optional][obsolete] time interval over which the numerical differentiation takes place. By default this is set to 1.0.
1167 * \return rotation axis to rotate from b1 to b2, scaled by the rotation angle, expressed in frame a.
1168 * \warning - The result is not a rotational vector, i.e. it is not a mathematical vector.
1169 * (no communitative addition).
1171 * \warning - When used in the context of numerical differentiation, with the frames b1 and b2 very
1172 * close to each other, the semantics correspond to the twist, scaled by the time.
1174 * \warning - For angles equal to \f$ \pi \f$, The negative of the
1175 * return value is equally valid.
1176 */
1177IMETHOD Vector diff(const Rotation& R_a_b1,const Rotation& R_a_b2,double dt=1);
1178
1187IMETHOD Twist diff(const Frame& F_a_b1,const Frame& F_a_b2,double dt=1);
1188
1193IMETHOD Twist diff(const Twist& a,const Twist& b,double dt=1);
1194
1199IMETHOD Wrench diff(const Wrench& W_a_p1,const Wrench& W_a_p2,double dt=1);
1200
1208IMETHOD Vector addDelta(const Vector& p_w_a,const Vector& p_w_da,double dt=1);
1209
1216 * \param R_w_a Rotation matrix of frame a expressed to some frame w.
1217 * \param da_w axis and angle of the rotation expressed to some frame w.
1218 * \returns the rotation matrix resulting from the rotation of frame a by the axis and angle
1219 * specified with da. The resulting rotation matrix is expressed with respect to
1220 * frame w.
1221 */
1222IMETHOD Rotation addDelta(const Rotation& R_w_a,const Vector& da_w,double dt=1);
1223
1224
1225 * returns the frame resulting from the rotation of frame a by the axis and angle
1226 * specified in da_w and the translation of the origin (also specified in da_w).
1227 *
1228 * see also the corresponding diff() routine.
1229 * \param R_w_a Rotation matrix of frame a expressed to some frame w.
1230 * \param da_w axis and angle of the rotation (da_w.rot), together with a displacement vector for the origin (da_w.vel), expressed to some frame w.
1231 * \returns the frame resulting from the rotation of frame a by the axis and angle
1232 * specified with da.rot, and the translation of the origin da_w.vel . The resulting frame is expressed with respect to frame w.
1233 */
1234IMETHOD Frame addDelta(const Frame& F_w_a,const Twist& da_w,double dt=1);
1235
1238
1239 * \param a a twist wrt some frame
1240 * \param da a twist difference wrt some frame
1241 * \returns The twist (a+da) wrt the corresponding frame.
1242 */
1243IMETHOD Twist addDelta(const Twist& a,const Twist&da,double dt=1);
1245
1249
1249 * see also the corresponding diff() routine.
1250 * \param a a wrench wrt some frame
1251 * \param da a wrench difference wrt some frame
1252 * \returns the wrench (a+da) wrt the corresponding frame.
1254IMETHOD Wrench addDelta(const Wrench& a,const Wrench&da,double dt=1);
1255
1256#ifdef KDL_INLINE
1257#include "frames.inl"
1258#endif
1259
1260}
1261
1262template<> struct std::hash<KDL::Vector>
1263{
1264 std::size_t operator()(KDL::Vector const& v) const noexcept
1265 {
1266 size_t seed = 0;
1267 KDL::hash_combine(seed, v.x());
1268 KDL::hash_combine(seed, v.y());
1269 KDL::hash_combine(seed, v.z());
1270 return seed;
1271 }
1272};
1273
1274template<> struct std::hash<KDL::Rotation>
1275{
1276 std::size_t operator()(KDL::Rotation const& r) const noexcept
1277 {
1278 size_t seed = 0;
1279 double x, y, z, w;
1280 r.GetQuaternion(x, y, z, w);
1281 KDL::hash_combine(seed, x);
1282 KDL::hash_combine(seed, y);
1283 KDL::hash_combine(seed, z);
1284 KDL::hash_combine(seed, w);
1285 return seed;
1286 }
1287};
1288
1289template<> struct std::hash<KDL::Frame>
1290{
1291 std::size_t operator()(KDL::Frame const& f) const noexcept
1292 {
1293 size_t seed = 0;
1294 KDL::hash_combine(seed, f.p);
1295 KDL::hash_combine(seed, f.M);
1296 return seed;
1297 }
1298};
1300template<> struct std::hash<KDL::Wrench>
1301{
1302 std::size_t operator()(KDL::Wrench const& w) const noexcept
1304 size_t seed = 0;
1305 KDL::hash_combine(seed, w.force);
1306 KDL::hash_combine(seed, w.torque);
1307 return seed;
1308 }
1309};
1310
1311template<> struct std::hash<KDL::Twist>
1313 std::size_t operator()(KDL::Twist const& t) const noexcept
1314 {
1315 size_t seed = 0;
1316 KDL::hash_combine(seed, t.vel);
1317 KDL::hash_combine(seed, t.rot);
1318 return seed;
1319 }
1320};
1321
1322template<> struct std::hash<KDL::Vector2>
1323{
1324 std::size_t operator()(KDL::Vector2 const& v) const noexcept
1326 size_t seed = 0;
1327 KDL::hash_combine(seed, v.x());
1328 KDL::hash_combine(seed, v.y());
1329 return seed;
1330 }
1331};
1333template<> struct std::hash<KDL::Rotation2>
1334{
1335 std::size_t operator()(KDL::Rotation2 const& r) const noexcept
1336 {
1337 size_t seed = 0;
1338 KDL::hash_combine(seed, r.GetRot());
1339 return seed;
1340 }
1342
1343template<> struct std::hash<KDL::Frame2>
1344{
1345 std::size_t operator()(KDL::Frame2 const& f) const noexcept
1346 {
1347 size_t seed = 0;
1348 KDL::hash_combine(seed, f.p);
1349 KDL::hash_combine(seed, f.M);
1350 return seed;
1351 }
1352};
1353
1354#endif
A 2D frame class, for further documentation see the Frames class for methods with unchanged semantics...
Definition frames.hpp:1099
void SetInverse()
Definition frames.hpp:952
void SetIdentity()
Definition frames.hpp:946
friend bool Equal(const Frame2 &a, const Frame2 &b, double eps)
Definition frames.hpp:1064
static Frame2 Identity()
Definition frames.hpp:1129
void Integrate(const Twist &t_this, double frequency)
Frame2(void)
Definition frames.hpp:910
Frame2 Inverse() const
Definition frames.hpp:960
double operator()(int i, int j)
Treats a frame as a 3x3 matrix and returns element i,j Access to elements 0..2,0.....
Definition frames.hpp:979
Rotation2 M
Orientation of the Frame.
Definition frames.hpp:1102
Vector2 p
origine of the Frame
Definition frames.hpp:1101
void Make4x4(double *d)
Frame2(const Rotation2 &R, const Vector2 &V)
Definition frames.hpp:925
Vector2 operator*(const Vector2 &arg) const
Definition frames.hpp:936
Frame2 & operator=(const Frame2 &arg)
Definition frames.hpp:967
represents a frame transformation in 3D space (rotation + translation)
Definition frames.hpp:572
Frame & operator=(const Frame &arg)
Normal copy-by-value semantics.
Definition frames.hpp:429
Frame Inverse() const
Gives back inverse transformation of a Frame.
Definition frames.hpp:423
double operator()(int i, int j)
Treats a frame as a 4x4 matrix and returns element i,j Access to elements 0..3,0.....
Definition frames.hpp:668
Rotation M
Orientation of the Frame.
Definition frames.hpp:575
void Make4x4(double *d)
Reads data from an double array.
static Frame Identity()
Definition frames.hpp:701
friend bool Equal(const Frame &a, const Frame &b, double eps)
do not use operator == because the definition of Equal(.,.) is slightly different....
Definition frames.hpp:1040
static Frame DH_Craig1989(double a, double alpha, double d, double theta)
static Frame DH(double a, double alpha, double d, double theta)
Frame(const Rotation &R, const Vector &V)
Definition frames.hpp:401
friend bool operator==(const Frame &a, const Frame &b)
The literal equality operator==(), also identical.
Definition frames.hpp:1276
void Integrate(const Twist &t_this, double frequency)
The twist <t_this> is expressed wrt the current frame. This frame is integrated into an updated frame...
Definition frames.hpp:625
Vector p
origine of the Frame
Definition frames.hpp:574
Vector operator*(const Vector &arg) const
Transformation of the base to which the vector is expressed.
Definition frames.hpp:413
Frame()
Definition frames.hpp:586
friend bool operator!=(const Frame &a, const Frame &b)
The literal inequality operator!=().
Definition frames.hpp:1285
A 2D Rotation class, for conventions see Rotation. For further documentation of the methods see Rotat...
Definition frames.hpp:1052
Vector2 operator*(const Vector2 &v) const
Definition frames.hpp:857
double GetRot() const
Gets the angle (in radians).
Definition frames.hpp:905
void SetIdentity()
Definition frames.hpp:891
Rotation2(double ca, double sa)
Definition frames.hpp:1062
static Rotation2 Rot(double angle)
The Rot... static functions give the value of the appropriate rotation matrix bac.
Definition frames.hpp:901
void SetRot(double angle)
The SetRot.. functions set the value of *this to the appropriate rotation matrix.
Definition frames.hpp:897
void SetInverse()
Definition frames.hpp:875
Rotation2()
c,s represent cos(angle), sin(angle), this also represents first col. of rot matrix from outside,...
Definition frames.hpp:1058
double operator()(int i, int j) const
Access to elements 0..1,0..1, bounds are checked when NDEBUG is not set.
Definition frames.hpp:861
Rotation2 & operator=(const Rotation2 &arg)
Definition frames.hpp:852
static Rotation2 Identity()
Definition frames.hpp:887
Rotation2 Inverse() const
Definition frames.hpp:879
friend bool Equal(const Rotation2 &a, const Rotation2 &b, double eps)
do not use operator == because the definition of Equal(.,.) is slightly different....
Definition frames.hpp:1060
represents rotations in 3 dimensional space.
Definition frames.hpp:304
void GetEulerZYZ(double &alpha, double &beta, double &gamma) const
Vector operator*(const Vector &v) const
Defines a multiplication R*V between a Rotation R and a Vector V. Complexity : 9M+6A.
Definition frames.hpp:527
Vector GetRot() const
Returns a vector with the direction of the equiv. axis and its norm is angle.
void GetRPY(double &roll, double &pitch, double &yaw) const
static Rotation Rot(const Vector &rotvec, double angle)
Along an arbitrary axes. It is not necessary to normalize rotvec. returns identity rotation matrix in...
static Rotation RotX(double angle)
The Rot... static functions give the value of the appropriate rotation matrix back.
Definition frames.hpp:606
Vector UnitY() const
Access to the underlying unitvectors of the rotation matrix.
Definition frames.hpp:524
void UnitZ(const Vector &X)
Access to the underlying unitvectors of the rotation matrix.
Definition frames.hpp:541
static Rotation Identity()
Gives back an identity rotaton matrix.
Definition frames.hpp:553
void DoRotZ(double angle)
The DoRot... functions apply a rotation R to *this,such that *this = *this * Rot.....
Definition frames.hpp:589
Vector UnitZ() const
Access to the underlying unitvectors of the rotation matrix.
Definition frames.hpp:536
static Rotation RPY(double roll, double pitch, double yaw)
Vector UnitX() const
Access to the underlying unitvectors of the rotation matrix.
Definition frames.hpp:512
Rotation()
Definition frames.hpp:308
static Rotation EulerZYZ(double Alfa, double Beta, double Gamma)
double GetRotAngle(Vector &axis, double eps=epsilon) const
static Rotation EulerZYX(double Alfa, double Beta, double Gamma)
Definition frames.hpp:471
void DoRotX(double angle)
The DoRot... functions apply a rotation R to *this,such that *this = *this * Rot.....
Definition frames.hpp:557
static Rotation Quaternion(double x, double y, double z, double w)
Gives back a rotation matrix specified with Quaternion convention the norm of (x,y,...
friend bool operator==(const Rotation &a, const Rotation &b)
The literal equality operator==(), also identical.
friend bool operator!=(const Rotation &a, const Rotation &b)
The literal inequality operator!=().
Definition frames.hpp:1328
static Rotation RotY(double angle)
The Rot... static functions give the value of the appropriate rotation matrix back.
Definition frames.hpp:611
double & operator()(int i, int j)
Access to elements 0..2,0..2, bounds are checked when NDEBUG is not set.
Definition frames.hpp:489
void SetInverse()
Sets the value of *this to its inverse.
Definition frames.hpp:654
void UnitX(const Vector &X)
Access to the underlying unitvectors of the rotation matrix.
Definition frames.hpp:517
Rotation Inverse() const
Gives back the inverse rotation matrix of *this.
Definition frames.hpp:638
double data[9]
Definition frames.hpp:306
void DoRotY(double angle)
The DoRot... functions apply a rotation R to *this,such that *this = *this * Rot.....
Definition frames.hpp:573
void GetQuaternion(double &x, double &y, double &z, double &w) const
Get the quaternion of this matrix.
Rotation & operator=(const Rotation &arg)
Definition frames.hpp:521
static Rotation Rot2(const Vector &rotvec, double angle)
Along an arbitrary axes. rotvec should be normalized.
void GetEulerZYX(double &Alfa, double &Beta, double &Gamma) const
Definition frames.hpp:495
void UnitY(const Vector &X)
Access to the underlying unitvectors of the rotation matrix.
Definition frames.hpp:529
static Rotation RotZ(double angle)
The Rot... static functions give the value of the appropriate rotation matrix back.
Definition frames.hpp:616
friend bool Equal(const Rotation &a, const Rotation &b, double eps)
do not use operator == because the definition of Equal(.,.) is slightly different....
friend class Frame
Definition frames.hpp:556
represents both translational and rotational velocities.
Definition frames.hpp:723
friend Twist operator*(const Twist &lhs, double rhs)
Definition frames.hpp:346
Twist(const Vector &_vel, const Vector &_rot)
Definition frames.hpp:732
void ReverseSign()
Reverses the sign of the twist.
Definition frames.hpp:297
friend double dot(const Twist &lhs, const Wrench &rhs)
Definition frames.hpp:1017
Twist & operator+=(const Twist &arg)
Definition frames.hpp:320
friend bool operator==(const Twist &a, const Twist &b)
The literal equality operator==(), also identical.
Definition frames.hpp:1303
Vector rot
The rotational velocity of that point.
Definition frames.hpp:726
friend Twist operator-(const Twist &lhs, const Twist &rhs)
Definition frames.hpp:367
Twist()
The default constructor initialises to Zero via the constructor of Vector.
Definition frames.hpp:730
Twist RefPoint(const Vector &v_base_AB) const
Changes the reference point of the twist. The vector v_base_AB is expressed in the same base as the t...
Definition frames.hpp:303
friend void SetToZero(Twist &v)
Definition frames.hpp:1072
friend Twist operator/(const Twist &lhs, double rhs)
Definition frames.hpp:356
friend class Rotation
Definition frames.hpp:792
Twist & operator-=(const Twist &arg)
Definition frames.hpp:313
friend bool Equal(const Twist &a, const Twist &b, double eps)
do not use operator == because the definition of Equal(.,.) is slightly different....
Definition frames.hpp:1050
friend Twist operator+(const Twist &lhs, const Twist &rhs)
Definition frames.hpp:362
double operator[](int index) const
Definition frames.hpp:743
Vector vel
The velocity of that point.
Definition frames.hpp:725
double & operator()(int i)
index-based access to components, first vel(0..2), then rot(3..5)
Definition frames.hpp:327
friend class Frame
Definition frames.hpp:793
friend bool operator!=(const Twist &a, const Twist &b)
The literal inequality operator!=().
Definition frames.hpp:1312
static Twist Zero()
Definition frames.hpp:291
2D version of Vector
Definition frames.hpp:961
friend bool operator!=(const Vector2 &a, const Vector2 &b)
The literal inequality operator!=().
Definition frames.hpp:1341
double x() const
Definition frames.hpp:800
friend Vector2 operator-(const Vector2 &lhs, const Vector2 &rhs)
Definition frames.hpp:751
friend Vector2 operator*(const Vector2 &lhs, double rhs)
Definition frames.hpp:756
friend bool Equal(const Vector2 &a, const Vector2 &b, double eps)
do not use operator == because the definition of Equal(.,.) is slightly different....
Definition frames.hpp:1055
double operator()(int index) const
Access to elements, range checked when NDEBUG is not set, from 0..1.
Definition frames.hpp:789
friend bool operator==(const Vector2 &a, const Vector2 &b)
The literal equality operator==(), also identical.
Definition frames.hpp:1332
double operator[](int index) const
Equivalent to double operator()(int index) const.
Definition frames.hpp:978
Vector2 & operator-=(const Vector2 &arg)
Definition frames.hpp:778
double Normalize(double eps=epsilon)
double y() const
Definition frames.hpp:801
Vector2()
Does not initialise to Zero().
Definition frames.hpp:965
Vector2 & operator+=(const Vector2 &arg)
Definition frames.hpp:771
friend Vector2 operator/(const Vector2 &lhs, double rhs)
Definition frames.hpp:766
void Set3DYZ(const Vector &v)
projects v in its YZ plane, and sets *this to these values
Definition frames.hpp:826
friend class Rotation2
Definition frames.hpp:1045
friend void SetToZero(Vector2 &v)
Definition frames.hpp:1081
friend Vector2 operator*(const Vector2 &lhs, const Vector2 &rhs)
friend Vector2 operator+(const Vector2 &lhs, const Vector2 &rhs)
Definition frames.hpp:746
void Set3DZX(const Vector &v)
projects v in its ZX plane, and sets *this to these values
Definition frames.hpp:832
void ReverseSign()
Definition frames.hpp:807
static Vector2 Zero()
Definition frames.hpp:785
double Norm(double eps=epsilon) const
void Set3DXY(const Vector &v)
projects v in its XY plane, and sets *this to these values
Definition frames.hpp:820
Vector2 & operator=(const Vector2 &arg)
Definition frames.hpp:738
void Set3DPlane(const Frame &F_someframe_XY, const Vector &v_someframe)
projects v_someframe in the XY plane of F_someframe_XY, and sets *this to these values expressed wrt ...
Definition frames.hpp:839
A concrete implementation of a 3 dimensional vector class.
Definition frames.hpp:163
void Set2DZX(const Vector2 &v)
a 3D vector where the 2D vector v is put in the ZX plane
Definition frames.hpp:476
friend double dot(const Vector &lhs, const Vector &rhs)
Definition frames.hpp:1013
Vector & operator=(const Vector &arg)
Assignment operator. The normal copy by value semantics.
Definition frames.hpp:50
friend bool Equal(const Vector &a, const Vector &b, double eps)
do not use operator == because the definition of Equal(.,.) is slightly different....
Definition frames.hpp:1033
friend void SetToZero(Vector &v)
To have a uniform operator to put an element to zero, for scalar values and for objects.
Definition frames.hpp:1069
friend Vector operator+(const Vector &lhs, const Vector &rhs)
Definition frames.hpp:58
friend Vector operator/(const Vector &lhs, double rhs)
Scalar division is defined.
Definition frames.hpp:102
friend bool operator==(const Vector &a, const Vector &b)
The literal equality operator==(), also identical.
Definition frames.hpp:1289
Vector & operator-=(const Vector &arg)
subtracts a vector from the Vector object itself
Definition frames.hpp:130
double operator[](int index) const
Equivalent to double operator()(int index) const.
Definition frames.hpp:185
double z() const
Definition frames.hpp:78
Vector & operator+=(const Vector &arg)
Adds a vector from the Vector object itself.
Definition frames.hpp:121
double x() const
Definition frames.hpp:76
void Set2DXY(const Vector2 &v)
a 3D vector where the 2D vector v is put in the XY plane
Definition frames.hpp:459
void Set2DYZ(const Vector2 &v)
a 3D vector where the 2D vector v is put in the YZ plane
Definition frames.hpp:467
double Normalize(double eps=epsilon)
void Set2DPlane(const Frame &F_someframe_XY, const Vector2 &v_XY)
a 3D vector where the 2D vector v_XY is put in the XY plane of the frame F_someframe_XY.
Definition frames.hpp:708
Vector()
Does not initialise the Vector to zero. use Vector::Zero() or SetToZero for that.
Definition frames.hpp:167
double data[3]
Definition frames.hpp:165
friend class Rotation
Definition frames.hpp:265
static Vector Zero()
Definition frames.hpp:139
double operator()(int index) const
Access to elements, range checked when NDEBUG is not set, from 0..2.
Definition frames.hpp:144
friend Vector operator*(const Vector &lhs, double rhs)
Scalar multiplication is defined.
Definition frames.hpp:84
friend Vector operator-(const Vector &lhs, const Vector &rhs)
Definition frames.hpp:67
double Norm(double eps=epsilon) const
friend bool operator!=(const Vector &a, const Vector &b)
The literal inequality operator!=().
Definition frames.hpp:1299
friend class Frame
Definition frames.hpp:266
void ReverseSign()
Reverses the sign of the Vector object itself.
Definition frames.hpp:441
double y() const
Definition frames.hpp:77
represents both translational and rotational acceleration.
Definition frames.hpp:882
friend bool Equal(const Wrench &a, const Wrench &b, double eps)
do not use operator == because the definition of Equal(.,.) is slightly different....
Definition frames.hpp:1045
Wrench & operator-=(const Wrench &arg)
Definition frames.hpp:210
friend Wrench operator+(const Wrench &lhs, const Wrench &rhs)
Definition frames.hpp:259
Wrench & operator+=(const Wrench &arg)
Definition frames.hpp:217
Vector force
Force that is applied at the origin of the current ref frame.
Definition frames.hpp:884
friend bool operator==(const Wrench &a, const Wrench &b)
The literal equality operator==(), also identical.
Definition frames.hpp:1316
friend Wrench operator/(const Wrench &lhs, double rhs)
Scalar division.
Definition frames.hpp:253
Wrench()
Does initialise force and torque to zero via the underlying constructor of Vector.
Definition frames.hpp:889
double & operator()(int i)
index-based access to components, first force(0..2), then torque(3..5)
Definition frames.hpp:224
Wrench(const Vector &_force, const Vector &_torque)
Definition frames.hpp:890
Wrench RefPoint(const Vector &v_base_AB) const
Changes the reference point of the wrench. The vector v_base_AB is expressed in the same base as the ...
Definition frames.hpp:198
friend Wrench operator-(const Wrench &lhs, const Wrench &rhs)
Definition frames.hpp:264
friend class Rotation
Definition frames.hpp:954
static Wrench Zero()
Definition frames.hpp:186
friend bool operator!=(const Wrench &a, const Wrench &b)
The literal inequality operator!=().
Definition frames.hpp:1325
Vector torque
Torque that is applied at the origin of the current ref frame.
Definition frames.hpp:885
double operator[](int index) const
Definition frames.hpp:903
friend Wrench operator*(const Wrench &lhs, double rhs)
Scalar multiplication.
Definition frames.hpp:243
void ReverseSign()
Reverses the sign of the current Wrench.
Definition frames.hpp:192
friend void SetToZero(Wrench &v)
Sets the Wrench to Zero, to have a uniform function that sets an object or double to zero.
Definition frames.hpp:1076
friend class Frame
Definition frames.hpp:955
Definition articulatedbodyinertia.hpp:32
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
Definition rall1d.h:313
bool operator==(const Rotation &a, const Rotation &b)
void hash_combine(std::size_t &seed, const T &v)
Combine hash of object v to the seed.
Definition hash_combine.h:18
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
Definition frames.hpp:1130
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
Definition rall1d.h:321
IMETHOD Vector addDelta(const Vector &p_w_a, const Vector &p_w_da, double dt=1)
adds vector da to vector a. see also the corresponding diff() routine.
Definition frames.hpp:1157
IMETHOD bool Equal(const FrameAcc &r1, const FrameAcc &r2, double eps=epsilon)
Definition frameacc.hpp:394
double epsilon
default precision while comparing with Equal(..,..) functions. Initialized at 0.0000001.
std::size_t operator()(KDL::Frame2 const &f) const noexcept
Definition frames.hpp:1345
std::size_t operator()(KDL::Frame const &f) const noexcept
Definition frames.hpp:1291
std::size_t operator()(KDL::Rotation2 const &r) const noexcept
Definition frames.hpp:1335
std::size_t operator()(KDL::Rotation const &r) const noexcept
Definition frames.hpp:1276
std::size_t operator()(KDL::Twist const &t) const noexcept
Definition frames.hpp:1313
std::size_t operator()(KDL::Vector2 const &v) const noexcept
Definition frames.hpp:1324
std::size_t operator()(KDL::Vector const &v) const noexcept
Definition frames.hpp:1264
std::size_t operator()(KDL::Wrench const &w) const noexcept
Definition frames.hpp:1302