示例#1
0
x0 = np.zeros((4, ))
x0[1] = 0.1
tf = 3.0

start = time.time()
engine.simulate(tf, x0)
end = time.time()
print("Simulation time: %03.0fms" % ((end - start) * 1.0e3))

# ############################# Extract the results #####################################

log_data, log_constants = engine.get_log()
print('%i log points' % log_data['Global.Time'].shape)
print(log_constants)
trajectory_data_log = extract_state_from_simulation_log(log_data, model)

# Save the log in CSV
engine.write_log("/tmp/log.csv", False)

# ############################ Display the results ######################################

# Plot some data using standard tools only
plt.figure()
plt.plot(log_data['Global.Time'], log_data['HighLevelController.energy'])
plt.title('Double pendulum energy')
plt.grid()
plt.show()

# Display the simulation trajectory and the reference
play_trajectories([trajectory_data_log], speed_ratio=0.5)
示例#2
0
tf = 3.0

start = time.time()
engine.simulate(tf, x0)
end = time.time()
print("Simulation time: %03.0fms" % ((end - start) * 1.0e3))

# ############################# Extract the results #####################################

log_data, log_constants = engine.get_log()
print('%i log points' % log_data['Global.Time'].shape)
print(log_constants)
trajectory_data_log = extract_viewer_data_from_log(log_data, robot)

# Save the log in CSV
engine.write_log(os.path.join(tempfile.gettempdir(), "log.csv"), False)

# ############################ Display the results ######################################

# Plot some data using standard tools only
plt.figure()
plt.plot(log_data['Global.Time'], log_data['HighLevelController.energy'])
plt.title('Double pendulum energy')
plt.grid()
plt.show()

# Display the simulation trajectory and the reference
play_trajectories([trajectory_data_log],
                  replay_speed=0.5,
                  camera_xyzrpy=[0.0, 7.0, 0.0, np.pi / 2, 0.0, np.pi])
示例#3
0
            log_data['HighLevelController.vcomReferenceY'],
            label="VCOM Ref Y")
    ax.plot(log_data['Global.Time'],
            log_data['HighLevelController.vcomTargetY'],
            label="VCOM Y (Targets)")
    ax.plot(log_data['Global.Time'],
            log_data['HighLevelController.vcomY'] / omega,
            label="VCOM/omega Y")
    ax.plot(log_data['Global.Time'],
            log_data['HighLevelController.vcomTargetY'] / omega,
            label="VCOM/omega Y (Targets)")
    ax.plot(log_data['Global.Time'],
            log_data['HighLevelController.dcmY'],
            label="DCM Y")
    ax.plot(log_data['Global.Time'],
            log_data['HighLevelController.dcmReferenceY'],
            label="DCM Ref Y")
    ax.plot(log_data['Global.Time'],
            log_data['HighLevelController.dcmTargetY'],
            label="DCM Y (Targets)")
    ax.plot(log_data['Global.Time'],
            log_data['HighLevelController.comTargetY'] +
            log_data['HighLevelController.vcomTargetY'] / omega,
            label="DCM Y (Mixed)")
    leg = interactive_legend(fig)
    plt.show()

if args.show:
    # Display the simulation trajectory and the reference
    play_trajectories([trajectory_data_log], replay_speed=0.5)