Can I visualize (but not simulate) using drake?

46 views Asked by At

I want to visualize a path without simulating, i.e. solving forward in time, or detecting collisions, etc; I just want it to draw on the screen. I realize meshcat does this on its own, and I don't need drake for that, but drake makes importing my robot so easy.

Ideally, I'm looking for an attribute that can give me a meshcat.visualizer.Visualizer object with my robot in it. I already have code that uses the meshcat Animation class to draw, I just need some help finding the meshcat.visualizer.Visualizer object.

Is there anything that exposes this?

I tried looking around in documentation to see if anything exposes this attribute, or if anything could be used to replace it. Everything I've found so far is of class pydrake.geometry.MeshcatVisualizer or pydrake.visualization.ModelVisualizer, neither of which are the "raw" meshcat.visualizer.Visualizer.

I did also consider attaching a fake time to the whole thing, and then doing some kind of velocity control, and turn off collisions. I think pydrake.geometry.MeshcatVisualizer is probably pretty well set up for that, and I could probably just use StartRecording(), maybe, but it feels bad to attach time to something that doesn't have a time.

1

There are 1 answers

2
Russ Tedrake On BEST ANSWER

Assuming I've understood correctly, I have a method which accomplishes roughly this available here.

The implementation is effectively what you suggested:

    plant_context = plant.GetMyContextFromRoot(root_context)
    visualizer_context = visualizer.GetMyContextFromRoot(root_context)

    visualizer.StartRecording(False)

    for t in np.append(
        np.arange(trajectory.start_time(), trajectory.end_time(), time_step),
        trajectory.end_time(),
    ):
        root_context.SetTime(t)
        plant.SetPositions(plant_context, trajectory.value(t))
        visualizer.ForcedPublish(visualizer_context)

    visualizer.StopRecording()
    visualizer.PublishRecording()