Something went wrong on our end
-
Médéric Fourmy authored
Refactoring, difference between simulated and estimation noise, disturbance selection for vbc, Iw and Lgesti
Médéric Fourmy authoredRefactoring, difference between simulated and estimation noise, disturbance selection for vbc, Iw and Lgesti
mcapi_utils.cpp 2.03 KiB
#include "mcapi_utils.h"
Vector3d computeAccFromSpatial(const Vector3d& ddr, const Vector3d& w, const Vector3d& dr)
{
return ddr + w.cross(dr);
}
std::vector<Vector3d> contacts_from_footrect_center()
{
// compute feet corners coordinates like from the leg_X_6_joint
double lx = 0.1;
double ly = 0.065;
double lz = 0.107;
std::vector<Vector3d> contacts; contacts.resize(4);
contacts[0] = {-lx, -ly, -lz};
contacts[1] = {-lx, ly, -lz};
contacts[2] = { lx, -ly, -lz};
contacts[3] = { lx, ly, -lz};
return contacts;
}
Matrix<double, 6, 1> contact_force_to_wrench(const std::vector<Vector3d>& contacts,
const Matrix<double, 12, 1>& cf12)
{
Vector3d f = cf12.segment<3>(0) + cf12.segment<3>(3) + cf12.segment<3>(6) + cf12.segment<3>(9);
Vector3d tau = contacts[0].cross(cf12.segment<3>(0))
+ contacts[1].cross(cf12.segment<3>(3))
+ contacts[2].cross(cf12.segment<3>(6))
+ contacts[3].cross(cf12.segment<3>(9));
Matrix<double, 6, 1> wrench; wrench << f, tau;
return wrench;
}
Matrix3d compute_Iw(pinocchio::Model& model,
pinocchio::Data& data,
VectorXd& q_static,
Vector3d& b_p_bc)
{
MatrixXd b_Mc = pinocchio::crba(model, data, q_static); // mass matrix at b frame expressed in b frame
// MatrixXd b_Mc = crba(model_dist, data_dist, q_static); // mass matrix at b frame expressed in b frame
MatrixXd b_I_b = b_Mc.topLeftCorner<6,6>(); // inertia matrix at b frame expressed in b frame
pinocchio::SE3 bTc (Eigen::Matrix3d::Identity(), b_p_bc); // "no free flyer robot -> c frame oriented the same as b"
pinocchio::SE3 cTb = bTc.inverse();
// Ic = cXb^star * Ib * bXc = bXc^T * Ib * bXc
// c_I_c block diagonal:
// [m*Id3, 03;
// 0, Iw]
MatrixXd c_I_c = cTb.toDualActionMatrix() * b_I_b * bTc.toActionMatrix();
Matrix3d b_Iw = c_I_c.bottomRightCorner<3,3>(); // meas
return b_Iw;
}