Example #1
0
    g = lambda args: f(*args)
    return g


fun = gen_init()

import scipy.optimize
result = scipy.optimize.minimize(fun, ini)

if result.fun < 1e-7:
    points = [pDtip, pCD, pOC, pOA, pAB, pBtip]
    points = PointsOutput(points)
    state = numpy.array([ini, result.x])
    ini1 = list(result.x)
    y = points.calc(state)
    y = y.reshape((-1, 6, 2))
    plt.figure()
    for item in y:
        plt.plot(*(item.T))
#    for item,value in zip(system.get_state_variables(),result.x):
#        initialvalues[item]=value

pAcm = pOA + lA / 2 * A.x
pBcm = pAB + lB / 2 * B.x
pCcm = pOC + lC / 2 * C.x
pDcm = pCD + lD / 2 * D.x
pEcm = pBtip - .1 * E.y

pE1 = pEcm + lE / 2 * E.x
vE1 = pE1.time_derivative(N, system)
Example #2
0
# c.linearize(0)
system.add_constraint(c)

#
f, ma = system.getdynamics()
func1 = system.state_space_post_invert(f,
                                       ma,
                                       constants=constants,
                                       variable_functions={my_signal: ft2})
states = pynamics.integration.integrate(func1, ini, t, rtol=tol, atol=tol)

KE = system.get_KE()
PE = system.getPEGravity(0 * N.x) - system.getPESprings()
energy = Output([KE - PE], constant_values=constants)
energy.calc(states, t)
energy.plot_time()

#torque_plot = Output([torque])
#torque_plot.calc(states,t)
#torque_plot.plot_time()

points = [pDtip, pCD, pOC, pOA, pAB, pBtip]
points = PointsOutput(points, constant_values=constants)
y = points.calc(states, t)
y = y.reshape((-1, 6, 2))
plt.figure()
for item in y[::30]:
    plt.plot(*(item.T))

#points.animate(fps = 30, movie_name='parallel_five_bar_jumper.mp4',lw=2)
    g = lambda args: f(*args)
    return g


fun = gen_init()

import scipy.optimize
result = scipy.optimize.minimize(fun, ini)

if result.fun < 1e-7:
    points = [pDtip, pD1D2, pCD, pC1C2, pOC, pOA, pA1A2, pAB, pB1B2, pBtip]
    points_output = PointsOutput(points, constant_values=constants)
    state = numpy.array([ini, result.x])
    ini1 = list(result.x)
    y = points_output.calc(state)
    y = y.reshape((-1, len(points), 2))
    plt.figure()
    for item in y:
        plt.plot(*(item.T))
#    for item,value in zip(system.get_state_variables(),result.x):
#        initialvalues[item]=value

pA1cm = pOA + lA / 4 * A1.x
pB1cm = pAB + lB / 4 * B1.x
pC1cm = pOC + lC / 4 * C1.x
pD1cm = pCD + lD / 4 * D1.x

pA2cm = pA1A2 + lA / 4 * A2.x
pB2cm = pB1B2 + lB / 4 * B2.x
pC2cm = pC1C2 + lC / 4 * C2.x
pD2cm = pD1D2 + lD / 4 * D2.x
Example #4
0
f, ma = system.getdynamics()
func1 = system.state_space_post_invert(f,
                                       ma,
                                       constants=system.constant_values,
                                       variable_functions={my_signal: ft2})
states = pynamics.integration.integrate_odeint(func1,
                                               ini,
                                               t,
                                               rtol=tol,
                                               atol=tol)

KE = system.get_KE()
PE = system.getPEGravity(0 * N.x) - system.getPESprings()
energy = Output([KE - PE, toeforce, heelforce])
energy.calc(states, t)
energy.plot_time()

#torque_plot = Output([torque])
#torque_plot.calc(states,t)
#torque_plot.plot_time()

points = [pDtip, pCD, pOC, pOA, pAB, pBtip, pE1, pE2, pBtip]
points = PointsOutput(points)
y = points.calc(states, t)
y = y.reshape((-1, 9, 2))
plt.figure()
for item in y[::30]:
    plt.plot(*(item.T))

#points.animate(fps = 30, movie_name='parallel_five_bar_jumper_foot.mp4',lw=2)