Blender V4.3
eigen_types.hpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Benoit Bolsee
2 *
3 * SPDX-License-Identifier: LGPL-2.1-or-later */
4
9#ifndef EIGEN_TYPES_HPP_
10#define EIGEN_TYPES_HPP_
11
12#include <Eigen/Core>
13#include "kdl/frames.hpp"
14#include "kdl/tree.hpp"
15#include "kdl/chain.hpp"
16#include "kdl/jacobian.hpp"
17#include "kdl/jntarray.hpp"
18
19
20namespace iTaSC{
21
22using KDL::Twist;
23using KDL::Frame;
24using KDL::Joint;
25using KDL::Inertia;
26using KDL::SegmentMap;
27using KDL::Tree;
28using KDL::JntArray;
29using KDL::Jacobian;
30using KDL::Segment;
31using KDL::Rotation;
32using KDL::Vector;
33using KDL::Vector2;
34using KDL::Chain;
35
36extern const Frame F_identity;
37
38#define e_scalar double
39#define e_vector Eigen::Matrix<e_scalar, Eigen::Dynamic, 1>
40#define e_zero_vector Eigen::Matrix<e_scalar, Eigen::Dynamic, 1>::Zero
41#define e_matrix Eigen::Matrix<e_scalar, Eigen::Dynamic, Eigen::Dynamic>
42#define e_matrix6 Eigen::Matrix<e_scalar,6,6>
43#define e_identity_matrix Eigen::Matrix<e_scalar, Eigen::Dynamic, Eigen::Dynamic>::Identity
44#define e_scalar_vector Eigen::Matrix<e_scalar, Eigen::Dynamic, 1>::Constant
45#define e_zero_matrix Eigen::Matrix<e_scalar, Eigen::Dynamic, Eigen::Dynamic>::Zero
46#define e_random_matrix Eigen::Matrix<e_scalar, Eigen::Dynamic, Eigen::Dynamic>::Random
47#define e_vector6 Eigen::Matrix<e_scalar,6,1>
48#define e_vector3 Eigen::Matrix<e_scalar,3,1>
49
50class Range {
51public:
52 int start;
53 int count;
54 Range(int _start, int _count) { start = _start; count=_count; }
55 Range(const Range& other) { start=other.start; count=other.count; }
56};
57
58template<typename MatrixType> inline Eigen::Block<MatrixType> project(MatrixType& m, Range r)
59{
60 return Eigen::Block<MatrixType>(m,r.start,0,r.count,1);
61}
62
63template<typename MatrixType> inline Eigen::Block<MatrixType> project(MatrixType& m, Range r, Range c)
64{
65 return Eigen::Block<MatrixType>(m,r.start,c.start,r.count,c.count);
66}
67
68template<typename Derived> inline static int changeBase(Eigen::MatrixBase<Derived>& J, const Frame& T) {
69
70 if (J.rows() != 6)
71 return -1;
72 for (int j = 0; j < J.cols(); ++j) {
73 typename Derived::ColXpr Jj = J.col(j);
74 Twist arg;
75 for(unsigned int i=0;i<6;++i)
76 arg(i)=Jj[i];
77 Twist tmp(T*arg);
78 for(unsigned int i=0;i<6;++i)
79 Jj[i]=e_scalar(tmp(i));
80 }
81 return 0;
82}
83
84}
85#endif /* UBLAS_TYPES_HPP_ */
This class encapsulates a serial kinematic interconnection structure. It is build out of segments.
Definition chain.hpp:36
represents a frame transformation in 3D space (rotation + translation)
Definition frames.hpp:526
This class encapsulates a simple joint, that is with one parameterized degree of freedom and with sca...
Definition joint.hpp:43
represents rotations in 3 dimensional space.
Definition frames.hpp:299
This class encapsulates a simple segment, that is a "rigid body" (i.e., a frame and an inertia) with ...
Definition segment.hpp:46
This class encapsulates a tree kinematic interconnection structure. It is build out of segments.
Definition tree.hpp:68
represents both translational and rotational velocities.
Definition frames.hpp:679
2D version of Vector
Definition frames.hpp:916
A concrete implementation of a 3 dimensional vector class.
Definition frames.hpp:143
Range(int _start, int _count)
Range(const Range &other)
#define e_scalar
std::map< std::string, TreeElement, std::less< std::string >, Eigen::aligned_allocator< std::pair< const std::string, TreeElement > > > SegmentMap
Definition tree.hpp:37
const Frame F_identity
static int changeBase(Eigen::MatrixBase< Derived > &J, const Frame &T)
Eigen::Block< MatrixType > project(MatrixType &m, Range r)