def main(run_simulations=True, parallel=False): """Main function that runs all the exercises.""" save = save_plots() pylog.info('Running network') run_network(plot=not save) pylog.info('Running simulation exercises') arguments = [] arguments = (['example', '8b', '8c', '8d1', '8d2', '8e', '8f'] if run_simulations else []) if parallel: pool = Pool(processes=4) pool.map(exercise_all, [[arg] for arg in arguments]) else: exercise_all(arguments=arguments) pylog.info('Plotting simulation results') plot_results(plot=not save)
def main(): """Main function that runs all the exercises.""" pylog.info('Running network') save = save_plots() run_network(plot=not save)
plt.figure("Positions") plot_positions(times, link_data) plt.figure("Trajectory") plot_trajectory(link_data) # Plot energy plot_energy(listamplitude, listphaselag, energymat) #plt.figure('efficiency') plot_efficiency(listamplitude, listphaselag, matefficiency) #Plot vitesse #plt.figure('Vitesse') plot_vitesse(listamplitude, listphaselag, vitessemat) plot_spine_angle(times, joints_data) # Show plots if plot: plt.show() else: save_figures() if __name__ == '__main__': main(36, np.linspace(0.0, 0.4, 6), np.linspace(0., 0.4, 6), plot=not save_plots())
# Load data # 8b #efficient_index = exercise_8b_plot_gridsearch() #plot_efficient_behaviour(efficient_index) # 8c #efficient_index = exercise_8c_plot_gridsearch() #plot_efficient_behaviour_8c(efficient_index) # 8d #plot_phase_angle_trajectory('exercise_8d',1) #plot_phase_angle_trajectory('exercise_8d',2) # 8f #plot_8f1() #plot_8f2() # 8g #plot_8g() # Show plots if plot: plt.show() else: save_figures() if __name__ == '__main__': main(plot=not save_plots())
with open('./logs/example/simulation_1.pickle', 'rb') as param_file: parameters = pickle.load(param_file) print(filename) times = data.times timestep = times[1] - times[0] # Or parameters.timestep osc_phases = np.asarray(data.state.phases_all()) osc_amplitudes = np.asarray(data.state.amplitudes_all()) links_positions = np.asarray(data.sensors.gps.urdf_positions()) head_positions = np.asarray(links_positions[:, 0, :]) tail_positions = np.asarray(links_positions[:, 10, :]) joints_positions = np.asarray( data.sensors.proprioception.positions_all()) joints_velocities = np.asarray( data.sensors.proprioception.velocities_all()) joints_torques = np.asarray( data.sensors.proprioception.motor_torques()) plt.figure("Exercise 8d2 - salamandra moves backwards") plt.title("Exercise 8d2 - salamandra moves backwards") plot_trajectory(head_positions) # Show plots if plot: plt.show() else: save_figures() if __name__ == '__main__': main_2(plot=not save_plots())