如何将圈速模拟器的直线与弯道加速度曲线平滑连接?
圈速模拟器加速度曲线连贯绘制问题
我正在开发一款圈速模拟器,设定车辆仅在直线段进行纵向加速,弯道段无纵向加速。目前已计算出直线段和弯道段的加速度数据,但需要将两者的曲线连接起来,形成连贯的完整图表。
相关代码如下:
import numpy as np import matplotlib.pyplot as plt g = 9.81 # Gravity pa = 1.2 # Air density m = 250 # mass of bike h = 0.69 # centre of mass height ha = 0.69 # height of centre pressure w = 1.5 # wheelbase b = 0.73 # longitudinal distance of centre of mass CdA = 0.2 # drag coefficient PMax = 180000 # max power ux = 1.2 # Longitudinal friction coefficient uy = 1.44 # Lateral friction coefficient T8_Angle = 180 T8_Radius = 80.5352283/2 T8_Length = T8_Radius * (T8_Angle*(np.pi/180)) T8_Velo = np.sqrt(uy*g*T8_Radius) St1Length = 400 dsa1 = 1 vela1 = [T8_Velo] sa1 = [0.] while sa1[-1] < St1Length: Fd = 0.5 * pa * CdA * vela1[-1]**2 Ap = ((PMax / ((m * vela1[-1]) + 1e-9)) - (Fd / m)) / g yw = 0 Aw = (((b * np.sqrt((yw)**2 + g**2)) / h) - ((Fd * ha) / (m * h))) / g Wheelie_Min = np.minimum(Ap, Aw) vela1_new = np.sqrt(vela1[-1]**2 + 2*Wheelie_Min*dsa1*g) vela1.append(vela1_new) sa1_new = sa1[-1] + dsa1 sa1.append(sa1_new) T1_Angle = 90 T1_Length = 315 T1_Radius = T1_Length/(2*np.pi*(T1_Angle/360)) T1_Velo = np.sqrt(uy*g*T1_Radius) dsd1 = 1 veld1 = [T1_Velo] sd1 = [St1Length] while sd1[-1] > 0: Fd = 0.5 * pa * CdA * veld1[-1]**2 yw = 0 Ad = (((g * ux * (np.sqrt(1 - (((yw)/ g)**2) * (1 / uy**2))) + (Fd / m))) * -1) / g As = ((((w-b) * np.sqrt((yw)**2 + g**2)) / h) + ((Fd * ha) / (m *h))) / (g *-1) Deceleration_Max = np.maximum(Ad, As) veld1_new = np.sqrt(veld1[-1]**2 - 2*Deceleration_Max*g*dsd1) veld1.append(veld1_new) sd1_new = sd1[-1] - dsd1 sd1.append(sd1_new) min_vel1 = [] for i in range(len(sa1)): s1 = sa1[i] v1_1 = vela1[i] v2_1 = veld1[-i-1] min_v1 = min(v1_1, v2_1) min_vel1.append(min_v1) time1 = [0] for i in range(1, len(sa1)): time1.append(time1[i-1] + (sa1[i] - sa1[i-1]) / min_vel1[i-1]) acc1 = [0] for i in range(1, len(sa1)): Time_Diff1 = time1[i] - time1[i-1] Velo_Diff1 = min_vel1[i] - min_vel1[i-1] acc1.append(Velo_Diff1/Time_Diff1) St1Last = sa1[-1] St1T1 = St1Last+T1_Length fig, lv = plt.subplots() lv.plot(sa1, acc1, 'b') lv.hlines(0, St1Last, St1T1, 'b') plt.xlabel('Distance (s)') plt.ylabel('Acceleration (m/s)')
当前生成的图表中,直线段的加速度曲线与弯道段的0加速度水平线衔接不自然,存在明显断点,无法形成连贯的完整曲线。
恳请提供技术帮助,解决曲线连贯连接的问题。
内容的提问来源于stack exchange,提问作者Karl Burnett
相关产品推荐
相关产品推荐

