vincekurtz / quadruped_drake

Using Drake to Simulate and Control Quadrupedal Robots
Other
29 stars 8 forks source link

How to replay the simulation that was simulated one ? #2

Closed dvogureckiy99 closed 1 year ago

dvogureckiy99 commented 1 year ago

How open drake visualizer if I installed drake through cmake except this command bazel-bin/tools/drake_visualizer?

dvogureckiy99 commented 1 year ago

I run the visualizer from drake-build by python3 -m pydrake.visualization.meldis. But I have a question: How to replay the simulation that was simulated one ?

dvogureckiy99 commented 1 year ago

For run simulation in cycle you can create while in simulate.py. And if you want create plots you should add this line from matplotlib import pyplot as plt to the simulate.py.

vincekurtz commented 1 year ago

To replay previous simulations I've always just used a screen recording. I think there are better ways to do that now using Meshcat, but I haven't tried them myself. You can find more info on stack overflow under the drake tag: https://stackoverflow.com/questions/tagged/drake

dvogureckiy99 commented 1 year ago

Thank you, more appropriate reason why I am asking that, this is what the simulation is half hanging and I can't observe the exact movement of the robot.

As I understand, you don't know how to use meshcat ?

vincekurtz commented 1 year ago

I see, meshcat is slow to load the meshes and the playback ends up being laggy. You could try something like this:

At line 146 of simulate.py:

# Set up the Visualizer
meshcat = Meshcat()
vis = MeshcatVisualizer.AddToBuilder(builder, scene_graph, meshcat)
#DrakeVisualizer().AddToBuilder(builder, scene_graph)
#ConnectContactResultsToDrakeVisualizer(builder, plant, scene_graph)

Then around line 185:

# Run the simulation!
vis.StartRecording()
simulator.AdvanceTo(sim_time)
vis.StopRecording()

while True:
    vis.PublishRecording()
    time.sleep(sim_time)

You'll need to import time as well. That will record the simulation and play it back on meshcat in a loop. You won't need to use meldis.

vincekurtz commented 1 year ago

On my machine it looks like meshcat isn't rendering the lower part of the robot's leg correctly, but that should give you a sense of what's going on

dvogureckiy99 commented 1 year ago

On my machine it looks like meshcat isn't rendering the lower part of the robot's leg correctly, but that should give you a sense of what's going on

For me it's the same case, lower parts didn't render correctly. I looked inside mesh folder and saw that there .stl extension just for lower parts.

Thank you for helping me, I will use this project for simulating Solo12 and this project was first one that I was able to launch, and I've tried a lot of libraries.

For the above answer thanks, I'll try it.

dvogureckiy99 commented 1 year ago

I found out that drake works only with .obj files, but I didn't understand yet how to add textures.