In [1]:
# import everything
# note: we assume that we are running in "pylab" mode (e.g.: "from pylab import *")
import models.VPP_anyleg as vpp
reload(vpp)
import models.VppAnalyze as vpa
In [3]:
# define initial conditions
IC0 = [0, 1.085, 0, 1.15, 0, -.05]
P0 = vpp.P0(13000, 69. * pi / 180.)
# define a struct-like object
class mystruct(object):
pass
steps = []
IC = IC0[:]
t0 = 0
for n in range(6):
# compute kinematic results
s = mystruct()
s.t, s.y, (s.x_foot1, s.x_foot2, s.t_td, s.t_to), s.Forces = vpp.VPP_step(IC, P0, with_forces=True)
s.x_foot2 = P0['x_foot1'] # store "old" foot position
s.t += t0
s.t_td += t0
s.t_to += t0
t0 = s.t[-1]
s.P = P0
steps.append(s)
IC = s.y[-1, :]
P0['x_foot1'] = s.x_foot1
In [4]:
#quick sanity check of simulation results
figure()
plot(hstack([s.y[:,0] for s in steps]), hstack([s.y[:,1] for s in steps]))
Out[4]:
In [5]:
# store data in workspace
import mutils.io as mio
mio.msave("../data/vpp_sim.dat", steps)
In [7]:
# sample visualization
#initialize the plotting frame
import mutils.plotting as mplt
reload(mplt)
fig2 = mplt.mfig('a5', 'my figure')
# TODO: continue here. Edit mutils/plotting.py -> plain entry
fig2.set_layout(mplt.layouts['plain']) # plain format: suitable for videos
# erase ticks
ax = fig2.axes[0]
ax.set_frame_on(False)
ax.set_xticks([])
ax.set_yticks([])
#plot simulation result (1 step)
s = steps[0]
ax.plot(s.t, s.Forces[:, 1], 'r')
ax.plot(s.t, s.Forces[:, 3], 'b')
draw()
In [ ]: