gm = GM(dt=0.01, eta=0.001, eta_d=1.0, eta_a=0.01, eta_nu=0.002)
sim = Sim("demo_" + type, type, stime)
plotter = Plotter(sim, stime, type)

delta_action = np.zeros(2)

frame = 0
for t in range(stime):

    # move box with scheduling based on type
    # and conpute collision
    collision, curr_angle_limit = sim.move_box(t)

    # update process
    gp.effective_object_position[0] = curr_angle_limit
    gp.update(delta_action)

    # update model
    delta_action = gm.update(gp.s_t[0], gp.s_p[0], gp.cpg[0])

    # update data
    plotter.update(t, gm, gp, curr_angle_limit, collision)

    # plot
    if t % int(stime / 200) == 0 or t == stime - 1:

        print(frame)
        frame += 1
        sim.update(gp.x[0], gm.mu[0])
        plotter.draw()
예제 #2
0
        delta_action = gm.update(sens[t])

        if t == stime//4 and type == "normal":
            genModPlot.plot_first(t)
        if t == box_time and type == "normal":
            genProcPlot.plot_second(t)

        if len(sens[:t+1]) >= 2:
            dd = np.sum(2*(sens[t-1:t+1] > 0)-1)
            if dd == 0 and sens[t-1] > 0:
                peaks += 1
                if peaks

                 == peaks_max+1:
                    box_time = t + stime//6
        if t % 1200 == 0 or t == stime - 1:
            if t > box_time:
                sim.set_box([0, 1.48])
            sim.update(0.3*np.pi*sens[t],
                       0.3*np.pi*sens_model[t])
            prederr.update([0.3*np.pi*sens[t], 0.3*np.pi*sens_model[t]], t)
            genProcPlot.update([0.3*np.pi*sens[t],
                                0.3*np.pi*ampl[t],
                                t > box_time,
                                0], t)
            genModPlot.update([0.3*np.pi*sens_model[t],
                               0.3*np.pi*ampl_model[t],
                               t > box_time,
                               sigma_s[t]*3 if type != "normal" else 0], t)