Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydrake math: .multiply shouldn't lose shape information #13885

Closed
EricCousineau-TRI opened this issue Aug 17, 2020 · 1 comment · Fixed by #13886
Closed

pydrake math: .multiply shouldn't lose shape information #13885

EricCousineau-TRI opened this issue Aug 17, 2020 · 1 comment · Fixed by #13886
Assignees
Labels
component: pydrake Python API and its supporting Starlark macros priority: medium unused team: manipulation

Comments

@EricCousineau-TRI
Copy link
Contributor

EricCousineau-TRI commented Aug 17, 2020

@kunimatsu-tri ran into the following issue:

import numpy as np
from pydrake.math import RigidTransform

a = np.array([0., 0., 0.])
b = a.reshape((3, 1))
c = np.array([[1., 2., 3.], [4., 5., 6]]).T
X = RigidTransform()

for v in [a, b, c]:
    mul_shape = (X @ v).shape
    print(f"{v.shape} => {mul_shape}")

Output:

(3,) => (3,)
(3, 1) => (3,)
(3, 2) => (3, 2)

Note how the case with b loses shape information, from (3, 1) to (3,).

From docs:
https://drake.mit.edu/pydrake/pydrake.math.html#pydrake.math.RigidTransform_.RigidTransform_[float].multiply

Specifically, we're looking at the interplay btw these two overloads:

2. multiply(self: pydrake.math.RigidTransform_[float], p_BoQ_B: numpy.ndarray[numpy.float64[3, 1]]) -> numpy.ndarray[numpy.float64[3, 1]]

3. multiply(self: pydrake.math.RigidTransform_[float], p_BoQ_B: numpy.ndarray[numpy.float64[3, n]]) -> numpy.ndarray[numpy.float64[3, n]]

In pybind11, float64[3, 1] gets intercepted as a vector (overload 2), and when it says it returns float64[3, 1], it really means it returns float64[3].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pydrake Python API and its supporting Starlark macros priority: medium unused team: manipulation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant