RobotLocomotion / drake

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

pydrake: GetPropertyOrDefault() error, "Requested 'double', but found 'drake::pydrake::Object'" #15640

Closed EricCousineau-TRI closed 3 years ago

EricCousineau-TRI commented 3 years ago

Per Slack: https://drakedevelopers.slack.com/archives/C2WBPQDB7/p1629426512085800?thread_ts=1629402163.077600&cid=C2WBPQDB7

Found by @Brian-Acosta; reproduction code here: https://github.com/DAIRLab/dairlib/tree/5c2ef7c3291e4c8cad00f11f9547e13153a2603a/examples/cubesim

Seems to be setting values with doubles, but instead getting cryptic errors like:

Traceback (most recent call last):
  File "{runfiles}/drake/tmp/cube_sim_test.py", line 91, in <module>
    sim.simulate(2.0)
  File "{runfiles}/drake/tmp/cube_sim_test.py", line 80, in simulate
    self.sim.AdvanceTo(time)
RuntimeError: GetPropertyOrDefault(): The property ('material', 'hunt_crossley_dissipation') exists, but is of a different type. Requested 'double', but found 'drake::pydrake::Object'
EricCousineau-TRI commented 3 years ago

Ported repro to Drake: https://github.com/EricCousineau-TRI/drake/tree/issue-15640-wip/tmp (commit: ff73f75cab)

EricCousineau-TRI commented 3 years ago

K, if I register Value[double] (commit: 97744bc712), I see a better error message:

RuntimeError: GetProperty(): The property ('material', 'coulomb_friction') exists, but is of a different type. Requested 'drake::multibody::CoulombFriction<double>', but found 'double'

So it seems like that we namely need Value[float]. Then that last error was just b/c minor typo in repro (commit a40e3607e6)