import math as m import matplotlib.pyplot as plt import matplotlib.animation as…
- User
import math as m import matplotlib.pyplot as plt import matplotlib.animation as animation import random as rnd import numpy as np import statistics as stat import scipy.interpolate as interpol from scipy.optimize import fsolve from fuzzylogic.classes import Domain, Rule from fuzzylogic.functions import triangular
def fuzz(phi, v0): # Объявление области функций # Курсовой угол fi = Domain("Angle", 0, 11.4, res=0.001) # Скорость оператора V0 = Domain("Operator_speed", 0, 1.52, res=0.001) # Скорость мгновенной РТК Vp = Domain("Speed_module", 0, 1.51, res=0.001)
# Курсовой угол (плавный) fi.smooth = triangular(0, 4.22) # Курсовой угол (средний) fi.medium = triangular(4, 6.75) # Курсовой угол (крутой) fi.steep = triangular(6.3, 11.4) # Скорость оператора (полшага) V0.half_step = triangular(0, 0.6) # Скорость оператора (шаг) V0.step = triangular(0.57, 1) # Скорость оператора (1,5 шага) V0.step_and_half = triangular(0.9, 1.52) # Модуль мгновенной скорости РТК (короткий) Vp.short = triangular(0, 0.58) # Модуль мгновенной скорости РТК (средний) Vp.medium = triangular(0.52, 1) # Модуль мгновенной скорости РТК (длинный) Vp.long = triangular(0.9, 1.51) # Запись правил R1 = Rule({(fi.smooth, V0.half_step): Vp.short}) R2 = Rule({(fi.smooth, V0.step): Vp.medium}) R3 = Rule({(fi.smooth, V0.step_and_half): Vp.long}) R4 = Rule({(fi.medium, V0.half_step): Vp.medium}) R5 = Rule({(fi.medium, V0.step): Vp.medium}) R6 = Rule({(fi.medium, V0.step_and_half): Vp.long}) R7 = Rule({(fi.steep, V0.half_step): Vp.medium}) R8 = Rule({(fi.steep, V0.step): Vp.medium}) R9 = Rule({(fi.steep, V0.step_and_half): Vp.long}) # Объединение правил rules = R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9 # Входные данные values = {fi: phi, V0: v0} # Вывод результата return rules(values)def pereshet(x, y, angle, y_r): # Вычисляем синус и косинус угла поворота sin_a = m.sin(angle) cos_a = m.cos(angle) x_2=y_rcos_a y_2=y_rsin_a # Поворачиваем координаты x_new = (x-x_2) * cos_a + (y-y_2) * sin_a y_new = -(x-x_2) * sin_a + (y-y_2) * cos_a # Возвращаем повернутые и смещенные координаты return (x_new, y_new)
def tochki_operator_and_rtk(i): if i<dottes+1: message_1 = f'Расстояние: {rast[i]}; Отклонение: {otklon[i]:.2f}' ax1.set_title(message_1) message_2 = f'Скорость оператора: {velocity_operator[i]:.2f};\n Скорость РТК: {velocity_rtk[i]:.2f}' ax2.set_title(message_2) ax1.scatter(x_oper_n[i], y_oper_n[i],marker = 'o', color = 'blue') ax1.scatter(x_rtk[i], y_rtk[i], marker = 'o', color = 'red') ax2.scatter(t_time[i], m_shag_sum[i],marker = 'o', color = 'blue') ax2.scatter(t_time[i], m_rtk_sum[i], marker = 'o', color = 'red') fig.tight_layout() else: ani.event_source.stop() ax1.plot(x_oper_n, y_oper_n, color='blue', linestyle='-', label = 'Оператор') ax1.plot(x_rtk, y_rtk, color = 'red', linestyle = '-', label = 'РТК') ax2.plot(t_time, m_shag_sum, color='blue', linestyle='-', label = 'Оператор') ax2.plot(t_time, m_rtk_sum, color = 'red', linestyle = '-', label = 'РТК') ax1.legend() ax2.legend() message_1 = f'Среднее расстояние: {rast_mean:.2f}; Среднее отклонение: {otklon_mean:.2f}' ax1.set_title(message_1) message_2 = f'Средняя скорость оператора: {vel_op_mean:.2f};\n Средняя скорость РТК: {vel_rtk_mean:.2f}' ax2.set_title(message_2)
- Assistant
- User
добавь в мой код реализацию синусойда движения оператора и ртк
- Assistant
- User
v0_1 = m.sqrt((x[i-1]2) + r_12 - 2*x[i-1]*r_1 * m.cos(phi_1)) эта строчка точно правильная?
- Assistant
- User
File "D:\DedMoroz\proect5\dviz_vD.py", line 194, in m_shag_sum, m_rtk_sum = puti(m_shag, m_rtk, dottes) File "D:\DedMoroz\proect5\dviz_vD.py", line 186, in puti m_shag_sum.append(m_shag_sum[i-1]+shag[i])
- Assistant