RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.27k stars 1.26k forks source link

Eigen 3.4 vs Investigate symbolic_ldlt.h #15444

Closed jwnimmer-tri closed 3 years ago

jwnimmer-tri commented 3 years ago

The //multibody/plant:multibody_plant_symbolic_test is failing in our Eigen 3.4 canary branch at #15142, during MultibodyPlantSymbolicTest.Pendulum.

The exception is "[this empty] environment does not have an entry for the variable tau", with the LDLT code in the gdb backtrace.

We should dig in to see if our LDLT trick in symbolic_ldlt.h is perhaps not sufficient anymore.

jwnimmer-tri commented 3 years ago

Looks like the problem is in TriangularSolveVector.h:117, which has gained a new guard as of Eigen 3.4 in ec323b7 for performance.

if(numext::not_equal_strict(rhs[i],RhsScalar(0)))

In turns out that we have rhs[i] as a Variable in the symbolic plant, at this point.

#9  in Formula::operator bool (this=...) at drake/common/symbolic_formula.h:206
#10 in Eigen::numext::not_equal_strict<Expression, Expression> (x=..., y=...) at drake/common/symbolic_formula.h:1347
#11 in Eigen::internal::triangular_solve_vector<Expression, Expression, long, 1, 5, false, 0>::run (size=1, _lhs=..., lhsStride=1,  rhs=...) at Eigen/src/Core/products/TriangularSolverVector.h:117
#12 in Eigen::internal::triangular_solver_selector<Eigen::Matrix<Expression, -1, -1, 0, 6, 6> const, Eigen::Matrix<Expression, -1, 1, 0, 6, 1>, 1, 5, 0, 1>::run (lhs=..., rhs=...) at Eigen/src/Core/SolveTriangular.h:73
#13 in Eigen::TriangularViewImpl<Eigen::Matrix<Expression, -1, -1, 0, 6, 6> const, 5u, Eigen::Dense>::solveInPlace<1, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> > (this=..., _other=...) at Eigen/src/Core/SolveTriangular.h:182
#14 in Eigen::TriangularViewImpl<Eigen::Matrix<Expression, -1, -1, 0, 6, 6> const, 5u, Eigen::Dense>::solveInPlace<Eigen::Matrix<Expression, -1, 1, 0, 6, 1> > (this=..., other=...) at Eigen/src/Core/TriangularMatrix.h:522
#15 in Eigen::LDLT<Eigen::Matrix<Expression, -1, -1, 0, 6, 6>, 1>::_solve_impl_transposed<true, Eigen::Matrix<Expression, -1, 1, 0, 6, 1>, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> > (this=..., rhs=..., dst=...) at Eigen/src/Cholesky/LDLT.h:581
#16 in Eigen::LDLT<Eigen::Matrix<Expression, -1, -1, 0, 6, 6>, 1>::_solve_impl<Eigen::Matrix<Expression, -1, 1, 0, 6, 1>, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> > (this=..., rhs=..., dst=...) at Eigen/src/Cholesky/LDLT.h:569
#17 in Eigen::internal::Assignment<Eigen::Matrix<Expression, -1, 1, 0, 6, 1>, Eigen::Solve<Eigen::LDLT<Eigen::Matrix<Expression, -1, -1, 0, 6, 6>, 1>, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> >, Eigen::internal::assign_op<Expression, Expression>, Eigen::internal::Dense2Dense, void>::run (dst=..., src=...) at Eigen/src/Core/Solve.h:147
#18 in Eigen::internal::call_assignment_no_alias<Eigen::Matrix<Expression, -1, 1, 0, 6, 1>, Eigen::Solve<Eigen::LDLT<Eigen::Matrix<Expression, -1, -1, 0, 6, 6>, 1>, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> >, Eigen::internal::assign_op<Expression, Expression> > (dst=..., src=..., func=...) at Eigen/src/Core/AssignEvaluator.h:890
#19 in Eigen::PlainObjectBase<Eigen::Matrix<Expression, -1, 1, 0, 6, 1> >::_set_noalias<Eigen::Solve<Eigen::LDLT<Eigen::Matrix<Expression, -1, -1, 0, 6, 6>, 1>, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> > > (this=..., other=...) at Eigen/src/Core/PlainObjectBase.h:797
#20 in Eigen::PlainObjectBase<Eigen::Matrix<Expression, -1, 1, 0, 6, 1> >::PlainObjectBase<Eigen::Solve<Eigen::LDLT<Eigen::Matrix<Expression, -1, -1, 0, 6, 6>, 1>, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> > > (this=..., other=...) at Eigen/src/Core/PlainObjectBase.h:594
#21 in Eigen::Matrix<Expression, -1, 1, 0, 6, 1>::Matrix<Eigen::Solve<Eigen::LDLT<Eigen::Matrix<Expression, -1, -1, 0, 6, 6>, 1>, Eigen::Matrix<Expression, -1, 1, 0, 6, 1> > > (this=..., other=...) at Eigen/src/Core/Matrix.h:423
#22 in drake::multibody::internal::BodyNode<Expression>::CalcArticulatedBodyAccelerations_BaseToTip (this=..., pc=..., abic=..., aba_force_cache=..., H_PB_W=...,  Ab_WB=..., ac=...) at drake/multibody/tree/body_node.h:1263