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

py systems: Enable / show example of doing convertible VectorSystem #10745

Closed
EricCousineau-TRI opened this issue Feb 22, 2019 · 5 comments
Closed
Assignees
Labels
component: pydrake Python API and its supporting Starlark macros configuration: python priority: medium type: usability When a feature is awkward, confusing, or undiscoverable

Comments

@EricCousineau-TRI
Copy link
Contributor

EricCousineau-TRI commented Feb 22, 2019

From @RussTedrake's pain points:

RuntimeError: The object named [] of type drake::pydrake::(anonymous)::Impl::PyVectorSystem does not support ToAutoDiffXd.

There are examples of doing scalar convertible types here:
https://github.com/RobotLocomotion/drake/tree/ffaa013/bindings/pydrake/systems/test/scalar_conversion_test.py#L12

However, I should inspect how hard it is to allow intermediate C++ base classes (e.g. VectorSystem) to do scalar conversion through this shindig. If it's messy / boilerplatey, will consider just reimplementing the intermediate in Python or what not.
Either one shouldn't be that hard.

@RussTedrake
Copy link
Contributor

RussTedrake commented Feb 24, 2019

Thanks! My "pain point" request has two parts. (1) just being able to convert subclasses of VectorSystem... which I think is just a matter of declaring the ScalarConverter versions of the constructor, etc(?), and (2) getting rid of the boilerplate around the python system conversion.

EDIT(eric): Moved pain point (2) to #10755.

@EricCousineau-TRI
Copy link
Contributor Author

I would like this issue to focus on the first pain point, will create a separate one for the second. Thanks!

@EricCousineau-TRI
Copy link
Contributor Author

User ran into this pain point again on StackOverflow: https://stackoverflow.com/questions/57512465/class-implementation-in-python

Upon revisiting this, though, it seems like it may be more complicated: VectorSystem overloads depend on reference semantics between C++ Eigen matrices and Python NumPy arrays, which is still not supported (#8116).

That issue is a still be nebulous due to the NumPy version requirements + potential for segfaults.

Proposed solutions:

  • First try to make the error message encountered a little more tractable for users.
  • Briefly see what's involved in the dtype stuff - knowing that it may open a can of worms.
  • Try out @jwnimmer-tri's suggestion in making a pure Python sugar class, and ditch overloading of the C++ VectorSystem in Python.
    • Caveat here is any analysis that is constrained to VectorSystem; I should see what methods those are.

@jwnimmer-tri
Copy link
Collaborator

Caveat here is any analysis that is constrained to VectorSystem; I should see what methods those are.

TTBOMK nothing uses the type of a VectorSystem to infer facts. It should always just be asking quacks-like questions as in "Is this System SISO", etc.

Or in other words, I would be happy to break any code that uses the runtime type of a VectorSystem to infer facts.

@EricCousineau-TRI EricCousineau-TRI added the component: pydrake Python API and its supporting Starlark macros label May 2, 2020
@jwnimmer-tri jwnimmer-tri added the type: usability When a feature is awkward, confusing, or undiscoverable label May 22, 2023
@jwnimmer-tri
Copy link
Collaborator

Per #20989 (comment), we should disprefer VectorSystem in the first place, so there's no point in gold-plating its Python bindings.

@jwnimmer-tri jwnimmer-tri closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2024
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 configuration: python priority: medium type: usability When a feature is awkward, confusing, or undiscoverable
Projects
None yet
Development

No branches or pull requests

3 participants