x_data = [] xd_data = [] yd_data = [] y_data = [] c_data = [] sum_x = 0.0 sum_y = 0.0 sum_x_data = [] sum_y_data = [] lamx_data = [] lamy_data = [] time_log = [] ST = int(sl.simulation_time(simulate_time, sampling_time)) fl = open('3dof_simulation_link_data.csv', 'w') fm = open('3dof_simulation_motor_data.csv', 'w') fp = open('3dof_simulation_position_data.csv', 'w') fc = open('Parameter_data.txt', 'w') fc.write('[Parameters]\n') fc.write( 'Xd = {}, Yd ={}\n'.format(Xd[0], Xd[1]) + 'k1 = [{},{}, {}, {}],'.format(k[0][0], k[1][0], k[2][0], k[3][0]) + 'k2 = [{}, {}, {}, {}]\n'.format(k[0][1], k[1][1], k[2][1], k[3][1])) for i in range(len(gain)): fc.write('Gain{} = [kp={}, kv={}, ki={}]\n'.format( i, gain[i][0], gain[i][1], gain[i][2]))
qd1, qd2 = radians(30), radians(45) # 目標角度 dot_qd1, dot_qd2 = 0.0, 0.0 count_time = 10 # シミュレート時間 sampling_time = 0.0001 # サンプリングタイム time_log = [] deg1 = [] deg2 = [] dot_deg1 = [] dot_deg2 = [] ddot_deg1 = [] ddot_deg2 = [] link2_log = [] ST = int(sl.simulation_time(count_time, sampling_time)) f = open('2dof_simulation.csv', 'w') Parameters = [ 'Time[s]', 'q1', 'q2', 'qd1', 'qd2', 'dot_q1', 'dot_q2', 'ddot_q1', 'ddot_q2' ] f.write('Time[s], q1, q2, qd1, qd2, dot_q1, dot_q2, ddot_q1, ddot_q2\n') row_data = [] for i in range(ST): time = i * sampling_time q1, q2, dot_q1, dot_q2 = sl.EulerMethod(q1, q2, dot_q1, dot_q2, ddot_q1, ddot_q2,