You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When constructing a quadratic cost, there are restrictions on the size of the input matrices Q and b. But these aren't being checked, so if a user specifies inputs of the wrong size, no error is thrown. Instead, uninitialized values will be used in the construction of the cost or constraint, leading to cryptic downstream errors.
Here's a simple example in python, demonstrating that the matrix shape is not being checked:
import numpy as np
from pydrake.all import QuadraticCost
QuadraticCost(np.eye(3), np.zeros(2), 1)
Since pybind is built in the release mode, it bypasses the check.
@jwnimmer-tri I can activate the check in the release mode. But what would be our general strategy? It is quite hard for python users to switch to debug mode, so shall we prefer DRAKE_DEMAND to DRAKE_ASSERT in our C++ code?
See #7827. The functions DRAKE_DEMAND and DRAKE_ASSERT are only appropriate for Drake checking its own internal invariants. User input should always be checked with DRAKE_THROW_UNLESS (or something similar, like an if-test with a throw statement).
What happened?
When constructing a quadratic cost, there are restrictions on the size of the input matrices Q and b. But these aren't being checked, so if a user specifies inputs of the wrong size, no error is thrown. Instead, uninitialized values will be used in the construction of the cost or constraint, leading to cryptic downstream errors.
Here's a simple example in python, demonstrating that the matrix shape is not being checked:
Version
b37aa69
What operating system are you using?
No response
What installation option are you using?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: