RobotLocomotion / drake

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

JointSliders (and ModelVisualizer by proxy) should use multibody position limits in default limits #20419

Closed RussTedrake closed 11 months ago

RussTedrake commented 11 months ago

Currently multibody/meshcat/joint_sliders promises, e.g.

@param lower_limit (Optional) The lower limit of the slider will be the maximum value of this number and any limit specified in the Joint. May be a single value or else a vector of length plant.num_positions(). If no value is provided, a sensible default will be used.

The most sensisble default, I would think, is any position limit known by the multibodyplant. But those are not currently used. It should be a quick and easy fix.

(I thought we had an issue for this, but I couldn't find it.)

jwnimmer-tri commented 11 months ago

JointSliders (and ModelVisualizer by proxy) should use multibody position limits in default limits

When I run run model visualizer on the iiwa14, the sliders do use the limits from the file. The code is here: https://github.com/RobotLocomotion/drake/blob/c3ded7f8727941f112e94998ec14d69c51cfcd5b/multibody/meshcat/joint_sliders.cc#L190-L196

Could you provide an example of what isn't working for you?

RussTedrake commented 11 months ago

Ok. It is working afterall. I tricked myself using

visualizer = ModelVisualizer(meshcat=meshcat)
ConfigureParser(visualizer.parser())
visualizer.AddModels(url="package://manipulation/mobile_iiwa14_primitive_collision.urdf")
plant = visualizer.parser().plant()
plant.WeldFrames(plant.world_frame(), plant.GetFrameByName("base"))
visualizer.Finalize()
visualizer.Run(loop_once=not running_as_notebook)

but without the WeldFrames in the first go. Without the weldframes (which ModelVisualizer doesn't make super easy), we have sliders for the (automatic) floating base.

In my mobile_iiwa variant, I had added initial prismatic joints named base_x, base_y, and base_z. The z joint was supposed to be limited... it was my bad fortune that I had a slider with the same name that had no limits. And reading the code, I didn't see the plant limits in the first batch of logic resolving the limits.