brom_drake Introduction 3 - ShowMeThisModel

March 30 2025

TL;DR

One of the most questions I see that people have (and try to answer with simulation) is: How do I See the robot's pose/position at X point in time. We've built the class `ShowMeThisModel` to answer this question. Simply give your model (i.e., your .urdf or .sdf) to the class and then use a few extra lines of Drake code to show the model in a specific position.

Simple diagram containing affine system which drives a 'slider block' in simulation with a ground plane below.

`ShowMeThisModel` is a brom_drake Production that holds your given model in fixed joint positions (you can choose these) for however long you like.

See several examples for how to use it in this directory.

What does the robot look like in this position?

This question happens A LOT when trying to run a robot simulation. Some reasons why you might ask it:

  • Your collision-checking function claims that a certain configuration of the robot is causing the robot to collide with the environment, but you don't know why.
  • You want to double check that the direction of one of your force commands is aligned with the correct part of the robot during operation.

How would you do this in Drake?

There are a number of ways that you could do this, some more complicated than others. The method that I recommend (and that you can take advantage of with the ShowMeThisModel object is) to:

  1. Load your model into a MultibodyPlant
  2. Weld the model to the scene so that it doesn't "fall away".
  3. Finalize the MultibodyPlant.
  4. Create a Drake LeafSystem which uses the SetPositions method to fix the robot in a given position.
  5. Build Drake diagram around these systems.
  6. Simulate!
This sounds like a lot (and it is if you're unfamiliar with Drake), so we've built a simple to use object that does all of this for you. It's called ShowMeThisModel.

I will not describe each of the steps above in this post. I think that they could each use a separate, digestable post of their own. When I complete each of those posts, I will add links here. :)

How do I use ShowMeThisModel?

Like most of the other Productions in brom_drake, ShowMeThisModel is used to build a "scene" in Drake that you can then easily simulate using Drake's simulator. To see how quickly you can go from the ShowMeThisModel Production to a simulation, look at the following code:

        
from brom_drake.productions import ShowMeThisModel

""" Your amazing code """

# Visualize the URDF using the "show-me-this-model" feature
time_step = 1e-3
production = ShowMeThisModel(
    str(path_to_urdf),
    time_step=time_step,
    with_these_joint_positions=[0.0, 0.0, -np.pi/4.0, 0.0, 0.0, 0.0], # list has 6 items for a 6 DoF robot
)

# Build Diagram
diagram, diagram_context = production.add_cast_and_build()

# Set up simulation
simulator = Simulator(diagram, diagram_context)
simulator.set_target_realtime_rate(1.0)
simulator.set_publish_every_time_step(False)

# Run simulation
simulator.Initialize()
simulator.AdvanceTo(15.0)

""" More of your amazing code """
        
    

In the above code, the creation of a ShowMeThisModel object simply saves most of the configuration of the production. Then, when the user wants to complete steps 1 through 5 from the above list, they run the add_cast_and_build function which adds the "cast" of robot models and Drake LeafSystems that are needed to show the robot in our desired position.

Once the Diagram has been built, we can simulate the scene just like we would any other in Drake: by creating a Simulator object for it.

There are additional features in ShowMeThisModel that you can take advantage of, as well. I will try to include those in the Wiki, but if you don't see details on those features or have a suggestion for what we should build next, then let me know!