36#ifndef RBDL_USE_CASADI_MATH
43 unsigned int n = A.
rows();
47 size_t *pivot =
new size_t[n];
54 for (i = 0; i < n; i++)
57 for (j = 0; j < n; j++) {
63 for (k = j; k < n; k++) {
68 unsigned int p_swap = pivot[j];
76 for (i = j + 1; i < n; i++) {
77 if (
Scalar(
fabs(A(j,pivot[j]))) <=
Scalar(std::numeric_limits<double>::epsilon())) {
78 std::cerr <<
"Error: pivoting failed for matrix A = " << std::endl;
79 std::cerr <<
"A = " << std::endl << A << std::endl;
80 std::cerr <<
"b = " << b << std::endl;
83 Scalar d = A(i,pivot[j])/A(j,pivot[j]);
87 for (k = j; k < n; k++) {
88 A(i,pivot[k]) -= A(j,pivot[k]) * d;
100 for (j = i + 1; j < n; j++) {
101 px[i] += A(i,pivot[j]) * px[j];
103 px[i] = (b[i] - px[i]) / A(i,pivot[i]);
108 for (i = 0; i < n; i++) {
131 assert (row < 2 && col < 2);
133 dest(row*3,col*3) = matrix(0,0);
134 dest(row*3,col*3 + 1) = matrix(0,1);
135 dest(row*3,col*3 + 2) = matrix(0,2);
137 dest(row*3 + 1,col*3) = matrix(1,0);
138 dest(row*3 + 1,col*3 + 1) = matrix(1,1);
139 dest(row*3 + 1,col*3 + 2) = matrix(1,2);
141 dest(row*3 + 2,col*3) = matrix(2,0);
142 dest(row*3 + 2,col*3 + 1) = matrix(2,1);
143 dest(row*3 + 2,col*3 + 2) = matrix(2,2);
146#ifndef RBDL_USE_CASADI_MATH
151 assert (epsilon >=
Scalar(0.));
154 for (i = 0; i < 6; i++) {
155 for (j = 0; j < 6; j++) {
157 std::cerr <<
"Expected:"
158 << std::endl << matrix_a << std::endl
159 <<
"but was" << std::endl
160 << matrix_b << std::endl;
173 assert (epsilon >=
Scalar(0.));
176 for (i = 0; i < 6; i++) {
178 std::cerr <<
"Expected:"
179 << std::endl << vector_a << std::endl
180 <<
"but was" << std::endl
181 << vector_b << std::endl;
196 return inertia + mass * com_cross * com_cross.transpose();
201 1., 0., 0., 0., 0., 0.,
202 0., 1., 0., 0., 0., 0.,
203 0., 0., 1., 0., 0., 0.,
204 0., r[2], -r[1], 1., 0., 0.,
205 -r[2], 0., r[0], 0., 1., 0.,
206 r[1], -r[0], 0., 0., 0., 1.
216 1., 0., 0., 0., 0., 0.,
217 0., c, s, 0., 0., 0.,
218 0., -s, c, 0., 0., 0.,
219 0., 0., 0., 1., 0., 0.,
220 0., 0., 0., 0., c, s,
221 0., 0., 0., 0., -s, c
231 c, 0., -s, 0., 0., 0.,
232 0., 1., 0., 0., 0., 0.,
233 s, 0., c, 0., 0., 0.,
234 0., 0., 0., c, 0., -s,
235 0., 0., 0., 0., 1., 0.,
246 c, s, 0., 0., 0., 0.,
247 -s, c, 0., 0., 0., 0.,
248 0., 0., 1., 0., 0., 0.,
249 0., 0., 0., c, s, 0.,
250 0., 0., 0., -s, c, 0.,
251 0., 0., 0., 0., 0., 1.
262 for (
unsigned int i = 0; i < model.qdot_size; i++) {
263 for (
unsigned int j = i + 1; j < model.qdot_size; j++) {
268 for (
unsigned int k = model.qdot_size; k > 0; k--) {
269 H(k - 1,k - 1) =
sqrt (H(k - 1,k - 1));
270 unsigned int i = model.lambda_q[k];
272 H(k - 1,i - 1) = H(k - 1,i - 1) / H(k - 1,k - 1);
273 i = model.lambda_q[i];
276 i = model.lambda_q[k];
280 H(i - 1,j - 1) = H(i - 1,j - 1) - H(k - 1,i - 1) * H(k - 1, j - 1);
281 j = model.lambda_q[j];
283 i = model.lambda_q[i];
289 assert (0 && !
"Not yet implemented!");
293 assert (0 && !
"Not yet implemented!");
297 assert (0 && !
"Not yet implemented!");
301 for (
unsigned int i = 1; i <= model.qdot_size; i++) {
302 unsigned int j = model.lambda_q[i];
304 x[i - 1] = x[i - 1] - L(i - 1,j - 1) * x[j - 1];
305 j = model.lambda_q[j];
307 x[i - 1] = x[i - 1] / L(i - 1,i - 1);
312 for (
unsigned int i = model.qdot_size; i > 0; i--) {
313 x[i - 1] = x[i - 1] / L(i - 1,i - 1);
314 unsigned int j = model.lambda_q[i];
316 x[j - 1] = x[j - 1] - L(i - 1,j - 1) * x[i - 1];
317 j = model.lambda_q[j];
unsigned int rows() const
unsigned int cols() const
unsigned int size() const
static MX_Xd_dynamic Zero(unsigned int nrows, unsigned int ncols=1)
SpatialMatrix_t SpatialMatrix
RBDL_DLLAPI SpatialMatrix XtransRotZYXEuler(const Vector3d &displacement, const Vector3d &zyx_euler)
Creates a spatial transformation for given parameters.
RBDL_DLLAPI SpatialMatrix Xrotx_mat(const Scalar &xrot)
Creates a rotational transformation around the X-axis.
RBDL_DLLAPI void SpatialMatrixSetSubmatrix(SpatialMatrix &dest, unsigned int row, unsigned int col, const Matrix3d &matrix)
RBDL_DLLAPI void SparseMultiplyLx(Model &model, Math::MatrixNd &L)
RBDL_DLLAPI void SparseFactorizeLTL(Model &model, Math::MatrixNd &H)
RBDL_DLLAPI void SparseSolveLx(Model &model, Math::MatrixNd &L, Math::VectorNd &x)
RBDL_DLLAPI bool LinSolveGaussElimPivot(MatrixNd A, VectorNd b, VectorNd &x)
Solves a linear system using gaussian elimination with pivoting.
Matrix3d VectorCrossMatrix(const Vector3d &vector)
RBDL_DLLAPI bool SpatialVectorCompareEpsilon(const SpatialVector &vector_a, const SpatialVector &vector_b, Scalar epsilon)
RBDL_DLLAPI void SparseMultiplyHx(Model &model, Math::MatrixNd &L)
RBDL_DLLAPI void SparseSolveLTx(Model &model, Math::MatrixNd &L, Math::VectorNd &x)
RBDL_DLLAPI SpatialMatrix Xroty_mat(const Scalar &yrot)
Creates a rotational transformation around the Y-axis.
RBDL_DLLAPI void SparseMultiplyLTx(Model &model, Math::MatrixNd &L)
RBDL_DLLAPI Matrix3d parallel_axis(const Matrix3d &inertia, Scalar mass, const Vector3d &com)
Translates the inertia matrix to a new center.
RBDL_DLLAPI SpatialMatrix Xrotz_mat(const Scalar &zrot)
Creates a rotational transformation around the Z-axis.
RBDL_DLLAPI SpatialMatrix Xtrans_mat(const Vector3d &r)
Creates a transformation of a linear displacement.
RBDL_DLLAPI Matrix3d Matrix3dZero
RBDL_DLLAPI SpatialVector SpatialVectorZero(0., 0., 0., 0., 0., 0.)
RBDL_DLLAPI Matrix3d Matrix3dIdentity
RBDL_DLLAPI Vector3d Vector3dZero
RBDL_DLLAPI bool SpatialMatrixCompareEpsilon(const SpatialMatrix &matrix_a, const SpatialMatrix &matrix_b, Scalar epsilon)
MX_Xd_dynamic fabs(const MX_Xd_dynamic &m)
MX_Xd_scalar sqrt(const MX_Xd_scalar &x)
MX_Xd_scalar cos(const MX_Xd_scalar &x)
MX_Xd_scalar sin(const MX_Xd_scalar &x)