9 #ifndef IIT_RBD_UTILS_H_ 10 #define IIT_RBD_UTILS_H_ 33 template <
typename Scalar>
37 return std::abs(x) < thresh ? 0 : x;
43 template <
typename Scalar>
57 out << 0 , -in(2), in(1),
69 template <
typename Derived>
73 eigen_assert(mx.rows() == 3 && mx.cols() == 3);
89 << cy*cz, cx*sz+sx*sy*cz, sx*sz-cx*sy*cz,
90 -cy*sz, cx*cz-sx*sy*sz, cx*sy*sz+sx*cz,
99 double cx = std::cos(rx);
100 double sx = std::sin(rx);
101 double cy = std::cos(ry);
102 double sy = std::sin(ry);
103 double cz = std::cos(rz);
104 double sz = std::sin(rz);
106 ret << cy*cz, cx*sz+sx*sy*cz, sx*sz-cx*sy*cz,
107 -cy*sz, cx*cz-sx*sy*sz, cx*sy*sz+sx*cz,
112 #define block31 template block<3,1> 113 #define block33 template block<3,3> 115 template <
typename Scalar>
118 mx.block33(0,3).setZero();
120 mx.block33(3,3) = mx.block33(0,0);
122 template <
typename Scalar>
126 mx.block33(3,0).setZero();
127 mx.block33(3,3) = mx.block33(0,0);
130 template <
typename D1,
typename D2>
133 eigen_assert(mx.rows() == 3 && mx.cols() == 3);
134 typedef typename D2::Scalar
Scalar;
137 << static_cast<Scalar>(0.0) , -in(2), in(1),
138 in(2),
static_cast<Scalar
>(0.0) , -in(0),
139 -in(1), in(0),
static_cast<Scalar
>(0.0);
142 template <
typename Derived>
144 eigen_assert(homT.rows() == 4 && homT.cols() == 4);
145 return homT.block31(0,3);
147 template <
typename Derived>
149 eigen_assert(homT.rows() == 4 && homT.cols() == 4);
150 return homT.block33(0,0);
152 template <
typename Derived>
154 eigen_assert(homT.rows() == 4 && homT.cols() == 4);
155 return homT.block31(0,2);
173 template <
typename Derived,
typename Other>
178 eigen_assert(homT.rows() == 4 && homT.cols() == 4);
179 eigen_assert(vect3d.rows() == 3 && vect3d.cols() == 1);
185 std::srand(std::time(NULL));
186 for(
int i=0;
i<6;
i++) {
187 vec(
i) = ((double)std::rand()) / RAND_MAX;
194 std::srand(std::time(NULL));
195 g(
LX) = ((double)std::rand()) / RAND_MAX;
196 g(
LY) = ((double)std::rand()) / RAND_MAX;
197 g(
LZ) = ((double)std::rand()) / RAND_MAX;
206 std::cerr <<
"Not enough arguments" << std::endl;
209 for(
int i=0;
i<6;
i++) {
210 vec(
i) = std::atof(argv[
i]);
static Mat33< Scalar > buildInertiaTensor(Scalar Ixx, Scalar Iyy, Scalar Izz, Scalar Ixy, Scalar Ixz, Scalar Iyz)
Definition: utils.h:44
double ixx
Definition: utils.h:25
static const MatrixBlock< const Derived, 3, 1 > zAxis(const MatrixBase< Derived > &homT)
Definition: utils.h:153
static void randomGravity(VelocityVector &g)
Definition: utils.h:191
double ixz
Definition: utils.h:25
Cored::Vector3 Vector3d
Definition: rbd.h:137
CwiseAlmostZeroOp(const Scalar &threshold)
Definition: utils.h:35
static void randomVec(Vector6D &vec)
Definition: utils.h:183
static void fillAsCrossProductMatrix(const MatrixBase< D2 > &in, const MatrixBase< D1 > &mx)
Definition: utils.h:131
static const MatrixBlock< const Derived, 3, 1 > positionVector(const MatrixBase< Derived > &homT)
Definition: utils.h:143
static void fillAsForceCrossProductMx(const Vec6< Scalar > &v, Mat66< Scalar > &mx)
Definition: utils.h:123
ct::core::ADCodegenLinearizer< state_dim, control_dim >::ADCGScalar Scalar
typename Core< S >::Matrix33 Mat33
Definition: types.h:23
static const MatrixBlock< const Derived, 3, 3 > rotationMx(const MatrixBase< Derived > &homT)
Definition: utils.h:148
static void fillAsRotationMatrix(double rx, double ry, double rz, const MatrixBase< Derived > &mx)
Definition: utils.h:70
Eigen::Block< XprType, R, C > MatrixBlock
Definition: rbd.h:57
Part3D angularPart(Vector6D &f)
Definition: rbd.h:154
double ixy
Definition: utils.h:25
typename Core< S >::Vector6 Vec6
Definition: types.h:26
typename Core< S >::Matrix66 Mat66
Definition: types.h:24
static void fillAsMotionCrossProductMx(const Vec6< Scalar > &v, Mat66< Scalar > &mx)
Definition: utils.h:116
Cored::VelocityVector VelocityVector
Definition: rbd.h:142
Eigen::MatrixBase< Derived > MatrixBase
Definition: rbd.h:51
Cored::Matrix33 Matrix33d
Definition: rbd.h:136
static Vector3d transform(const MatrixBase< Derived > &homT, const MatrixBase< Other > &vect3d)
Definition: utils.h:174
const Scalar operator()(const Scalar &x) const
Definition: utils.h:36
Cored::Vector6D Vector6D
Definition: rbd.h:141
double iyz
Definition: utils.h:25
Part3D linearPart(Vector6D &f)
Definition: rbd.h:157
static Matrix33d buildCrossProductMatrix(const Vector3d &in)
Definition: utils.h:55
static void cmdlineargs_spatialv(int argc, char **argv, iit::rbd::Vector6D &vec)
Definition: utils.h:202
static Matrix33d buildRotationMatrix(double rx, double ry, double rz)
Definition: utils.h:98
double izz
Definition: utils.h:25
double iyy
Definition: utils.h:25