RobotLocomotion / drake

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

Getting `UpdateHessianType()` warnings in Drake 1.29.0 #21552

Open sea-bass opened 3 weeks ago

sea-bass commented 3 weeks ago

What happened?

When I upgraded from Drake 1.28.0 to 1.29.0, I started getting these really loud warnings printed to my console:

WARNING:drake:UpdateHessianType(): Unable to determine Hessian type of the Quadratic Constraint.
Falling back to indefinite Hessian type.

Seems to be directly due to https://github.com/RobotLocomotion/drake/pull/21411

Nothing else seems to have been affected, but I'd like to be able to resolve these in some way. Are there any resources for what this may mean, and how to fix it?

My offending constraints look as follows:

        for n in range(num_dofs):
           for k in range(num_waypoints - 1):
                prog.AddConstraint(
                    xc[k, n]
                    == 0.5 * (x[k, n] + x[k + 1, n])
                    + (h[k] / 8.0) * (x_d[k, n] - x_d[k + 1, n])
                )

Where xc, x, x_d, and h are all continuous variables in my program. By process of elimination, it seems that the issue is in the multiplication of h[k] by the sub-elements of x_d, since that is the quadratic term.

Version

1.29.0

What operating system are you using?

Ubuntu 24.04

What installation option are you using?

pip install drake

Relevant log output

No response

sea-bass commented 3 weeks ago

Update: I could get around it by being very explicit...

from pydrake.solvers import QuadraticConstraint
prog.AddQuadraticConstraint(
    0.5 * (x[k, n] + x[k + 1, n])
    + (h[k] / 8.0) * (x_d[k, n] - x_d[k + 1, n]) 
    - xc[k, n],
    0.0, 0.0, QuadraticConstraint.HessianType.kIndefinite)
hongkai-dai commented 3 weeks ago

@sea-bass as you have found out, explicitly specifying the Hessian type would resolve your problem. I filed the PR #21553