RobotLocomotion / drake

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

World body stores NaN parameters in context #14399

Open joemasterjohn opened 3 years ago

joemasterjohn commented 3 years ago

Because each body declares inertial parameters based off of their default parameters, the world body declares a default SpatialInertia in the context as its inertial parameters:

18 numeric parameter groups with
   10 parameters
     nan nan nan nan nan nan nan nan nan nan

This has come up a few times as a red herring when trying to track down the reason for MBP throwing an error (stack overflow question) and is at the very least concerning looking to users inspecting the context. While the NaNs in the context are not really a bug (world body is handled as a special case in plant/tree and its default inertial parameters are truly NaN), there might be reason to omit them.

The headache with omiting them for the world_body (or any other body with uninitialized parameters) is that methods such as RigidBody::get_mass(context) and RigidBody::CalcSpatialInertiaInBodyFrame(context) will need special logic to detect that it is world_body and NOT retrieve values from the context in that case.

cc: @sherm1 @amcastro-tri thoughts?

sherm1 commented 3 years ago

It does seem bad that World's mass properties are parameters though -- doesn't that mean someone could change them? That doesn't seem like a good idea! My inclination would be to special-case World as a body whose mass properties are fixed and cannot be changed via parameters.

amcastro-tri commented 3 years ago

I agree with @sherm1, we should not be able to specify parameters for the world. Of course there are different ways to accomplish this in software.

An option: