Closed erwincoumans closed 3 years ago
Swapped the 6,3 to 3,6 indices for the transposed case in mass_matrix.hpp:
if (mb.is_floating()) {
Fi = mb[j].X_parent.apply(Fi, true);
Algebra::assign_block(*M, Fi, 0, qd_i, 6, 3);
Algebra::assign_block(*M,Algebra::transpose(Fi), qd_i, 0, 3, 6);
}
then some NaN appears here (NaN was introduced somewhere inside mb_constraintsolver->resolve_collision) apparently, the mass matrix cannot be inverted (leading to NaN).
> laikago_opengl_eigen_example.exe!tds::forward_kinematics<tds::EigenAlgebraT<double>>(tds::MultiBody<tds::EigenAlgebraT<double>> & mb, const Eigen::Matrix<double,-1,1,0,-1,1> & q, const Eigen::Matrix<double,-1,1,0,-1,1> & qd, const Eigen::Matrix<double,-1,1,0,-1,1> & qdd) Line 37 C++
laikago_opengl_eigen_example.exe!tds::forward_dynamics<tds::EigenAlgebraT<double>>(tds::MultiBody<tds::EigenAlgebraT<double>> & mb, const Eigen::Matrix<double,-1,1,0,-1,1> & q, const Eigen::Matrix<double,-1,1,0,-1,1> & qd, const Eigen::Matrix<double,-1,1,0,-1,1> & tau, const Eigen::Matrix<double,3,1,0,3,1> & gravity, Eigen::Matrix<double,-1,1,0,-1,1> & qdd) Line 47 C++
laikago_opengl_eigen_example.exe!tds::forward_dynamics<tds::EigenAlgebraT<double>>(tds::MultiBody<tds::EigenAlgebraT<double>> & mb, const Eigen::Matrix<double,3,1,0,3,1> & gravity) Line 304 C++
laikago_opengl_eigen_example.exe!LaikagoSimulation<tds::EigenAlgebraT<double>>::operator()(const std::vector<double,std::allocator<double>> & v) Line 174 C++
laikago_opengl_eigen_example.exe!main(int argc, char * * argv) Line 364 C++
Hi Erwin,
Sorry it took so long but I finally got to looking at it. It was a copy/paste error in lines 101/102. I changed
(*M)(qd_i + ii, qd_j) = Hij[ii]; (*M)(qd_j, qd_i + ii) = Hij[ii];
to
(*M)(qd_i, qd_j + ii) = Hij[ii]; (*M)(qd_j + ii, qd_i) = Hij[ii];
and that, together with the change you wrote in the comment fixed it. I'll make a new pull request for the fix.
Thanks a lot for spending time on this Paul, very much appreciate it!
Unzip/copy attached into the examples directory and compile and run. They are modified to load the humanoid urdf with spherical joints. Below are also callstacks pointing to the assert (in Visual Studio).
Eigen version: laikago_opengl_example.zip
callstack:
Tiny (has known issues with spherical, so best to get Eigen version fixed first) tiny_urdf_parser_opengl_example.zip
callstack: