Unverified Commit 388b6370 authored by Carlos Mastalli's avatar Carlos Mastalli Committed by GitHub
Browse files

Merge pull request #1044 from cmastalli/topic/display-cartpole-in-python-script

Display cartpole in python script
parents b57e27d7 79e8a5b4
Pipeline #17530 passed with stage
in 74 minutes and 49 seconds
# Display the solution
import numpy as np
from IPython.display import HTML
from cartpole_utils import animateCartpole
import crocoddyl
......@@ -79,4 +77,5 @@ ddp = crocoddyl.SolverDDP(problem)
ddp.solve([], [], 300)
# Display animation
animateCartpole(ddp.xs, show=True)
\ No newline at end of file
......@@ -5,7 +5,7 @@ from matplotlib import animation
from matplotlib import pyplot as plt
def animateCartpole(xs, sleep=50):
def animateCartpole(xs, sleep=50, show=False):
print("processing the animation ... ")
cart_size = 1.
pole_length = 5.
......@@ -35,4 +35,6 @@ def animateCartpole(xs, sleep=50):
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=len(xs), interval=sleep, blit=True)
print("... processing done")
if show:
return anim
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment