当前位置: 首页> 财经> 访谈 > 网络技术服务_优秀网络广告案例分析_百度seo公司哪家强一点_seo搜索引擎优化试题

网络技术服务_优秀网络广告案例分析_百度seo公司哪家强一点_seo搜索引擎优化试题

时间:2025/7/10 0:06:31来源:https://blog.csdn.net/qq_45191106/article/details/144514037 浏览次数:1次
网络技术服务_优秀网络广告案例分析_百度seo公司哪家强一点_seo搜索引擎优化试题
import os
import shutil
from kinematic_bicycle_model import Vehicle, VehicleInfo, draw_vehicle
from pure_pursuit_controller import pure_pursuit_steer_control
from Path_generator import Path
import numpy as np
import matplotlib.pyplot as plt
import imageio.v2 as imageio# 设置最大运行时间MAX_SIMULATION_TIME = 200.0# 程序最大运行时间200*dt# 程序入口
def main():# 设置车辆参数VehicleInfo.L = 3.0  # 车辆长度VehicleInfo.W = 1.5  # 车辆宽度VehicleInfo.LF = 2.0  # 前轮距离VehicleInfo.LB = 2.0  # 后轮距离VehicleInfo.MAX_STEER = np.pi / 10  # 最大转向角VehicleInfo.TR = 0.5  # 车身半径VehicleInfo.TW = 0.3  # 车轮半径VehicleInfo.WD = 2.0  # 车身宽度VehicleInfo.LENGTH = 4.0  # 车辆长度# 设置车辆初始状态vehicle1 = Vehicle(x=5.0,y=60.0,yaw=0.0,v=2.0,dt=0.1,l=VehicleInfo.L)vehicle2 = Vehicle(x=5.0,y=60.0,yaw=0.0,v=2.0,dt=0.1,l=VehicleInfo.L)  # 车辆2 # 设置路径参数path = Path()path.is_reverse = False  # 路径是否为逆时针方向path.design_reference_line()  # 设计路径# 显示路径plt.plot(path.ref_line[:, 0], path.ref_line[:, 1], '-.k', linewidth=1.0)plt.plot(path.ref_line[0, 0], path.ref_line[0, 1], 'og', label="start")plt.plot(path.ref_line[-1, 0], path.ref_line[-1, 1], 'or', label="end")plt.legend()plt.axis("equal")plt.grid(True)plt.show()# 设置跟踪轨迹rx, ry, rv, ref_yaw, ref_s, ref_kappa = Path().get_ref_line_info()# 记录参考路径信息ref_path = np.column_stack((rx, ry, rv, ref_yaw, ref_s, ref_kappa))# 显示参考路径plt.plot(rx, ry, '-.k', linewidth=1.0)plt.plot(rx[0], ry[0], 'og', label="start")plt.plot(rx[-1], ry[-1], 'or', label="end")plt.legend()plt.axis("equal")plt.grid(True)plt.show()#绘制车辆道路 三车道 居中显示 带有虚拟车道 车道宽度为2.0 车道间距为1.0# 车道1:左侧车道 起点为(0,0) 终点为(0,10)# 车道2:右侧车道 起点为(0,0) 终点为(0,10)# 车道3:虚拟车道 起点为(0,10) 终点为(0,12)# 车道1plt.plot([0, 0], [0, 10], 'k', linewidth=2.0)plt.plot([0, 0], [0, 10], 'k--', linewidth=1.0)# 车道2plt.plot([0, 0], [0, 10], 'k', linewidth=2.0)plt.plot([0, 0], [0, 10], 'k--', linewidth=1.0)#车道3plt.plot([0, 0], [10, 12], 'k', linewidth=2.0)plt.plot([0, 0], [10, 12], 'k--', linewidth=1.0)plt.axis("equal")plt.grid(True)plt.show()
#控制车辆速度# 设置车辆速度vehicle1.v = 2.0  # 车辆1速度vehicle2.v = 2.0  # 车辆2速度# 设置车辆转向角vehicle1.steer = 0.0  # 车辆1转向角vehicle2.steer = 0.0  # 车辆2转向角             # 记录车辆轨迹trajectory_x1 = []trajectory_y1 = []trajectory_x2 = []trajectory_y2 = []lat_err1 = []  # 记录横向误差lat_err2 = []  # 记录横向误差# 开始仿真time = 0.0# 初始时间target_ind1 = 0target_ind2 = 0# 记录车辆轨迹trajectory_x1 = []trajectory_y1 = []trajectory_x2 = []trajectory_y2 = []lat_err1 = []  # 记录横向误差lat_err2 = []  # 记录横向误差i = 0image_list = []  # 存储图片plt.figure(1, dpi=100)  # 创建一个图形窗口plt.ion()  # 开启交互模式plt.show()  # 显示图形窗口#显示初始状态plt.plot(ref_path[:, 0], ref_path[:, 1], '-.k', linewidth=1.0)draw_vehicle(vehicle1.x, vehicle1.y, vehicle1.yaw, vehicle1.steer, plt, color='blue')draw_vehicle(vehicle2.x, vehicle2.y, vehicle2.yaw, vehicle2.steer, plt, color='green')plt.plot(trajectory_x1, trajectory_y1, "-b", label="RWPP-trajectory")plt.plot(trajectory_x2, trajectory_y2, "-g", label="FWPP-trajectory")plt.plot(ref_path[target_ind1, 0], ref_path[target_ind1, 1], "b-o", label="RWPP-target")plt.plot(ref_path[target_ind2, 0], ref_path[target_ind2, 1], "g-o", label="FWPP-target")plt.xlim(min(vehicle1.x, vehicle2.x, ref_path[target_ind1, 0], ref_path[target_ind2, 0]) - 3,max(vehicle1.x, vehicle2.x, ref_path[target_ind1, 0], ref_path[target_ind2, 0]) + 3)plt.ylim(min(vehicle1.y, vehicle2.y, ref_path[target_ind1, 1], ref_path[target_ind2, 1]) - 3,max(vehicle1.y, vehicle2.y, ref_path[target_ind1, 1], ref_path[target_ind2, 1]) + 3)plt.legend()plt.grid(True)plt.pause(0.001)#显示时间信息plt.subplot(3, 1, 1)plt.title("Time: 0.0s")plt.subplot(3, 1, 2)plt.title("Time: 0.0s")plt.subplot(3, 1, 3)plt.title("Time: 0.0s")plt.pause(0.001)plt.savefig("temp.png")image_list.append(imageio.imread("temp.png"))#显示进度条print("Simulation start...")print("Progress: 0.0%")i = 0   #将车辆状态信息记录到列表trajectory_x1.append(vehicle1.x)trajectory_y1.append(vehicle1.y)trajectory_x2.append(vehicle2.x)trajectory_y2.append(vehicle2.y)lat_err1.append(0.0)lat_err2.append(0.0)#图片转换.mp4格式#imageio.mimsave('display.mp4', image_list, fps=10)old_index1 = Noneold_index2 = Nonelast_idx = ref_path.shape[0] - 1# 跟踪轨迹的最后一个点的索引while MAX_SIMULATION_TIME >= time and (last_idx > target_ind1 or last_idx > target_ind2):time += vehicle1.dt  # 累加一次时间周期if last_idx > target_ind1:delta_f1, target_ind1, e_y1 = pure_pursuit_steer_control(vehicle1, ref_path, old_index1, False)old_index1 = target_ind1# 横向误差lat_err1.append(e_y1)# 更新车辆状态vehicle1.update(0.0, delta_f1, np.pi/10)  # 由于假设纵向匀速运动,所以加速度a=0.0trajectory_x1.append(vehicle1.x)trajectory_y1.append(vehicle1.y)if last_idx > target_ind2:delta_f2, target_ind2, e_y2 = pure_pursuit_steer_control(vehicle2, ref_path, old_index2, True)old_index2 = target_ind2lat_err2.append(e_y2)vehicle2.update(0.0, delta_f2, np.pi / 10)  # 由于假设纵向匀速运动,所以加速度a=0.0trajectory_x2.append(vehicle2.x)trajectory_y2.append(vehicle2.y)# 显示动图plt.subplots_adjust(hspace=0.5, wspace=0.5)  # 调整垂直和水平间距plt.subplot(3, 1, 1)plt.cla()plt.plot(ref_path[:, 0], ref_path[:, 1], '-.k', linewidth=1.0)draw_vehicle(vehicle1.x, vehicle1.y, vehicle1.yaw, vehicle1.steer, plt, color='blue')#车辆1带有ego-car字体plt.text(vehicle1.x, vehicle1.y, "ego-car", color='blue', fontsize=10)#车辆2带有VTU-car字体plt.text(vehicle2.x, vehicle2.y, "VTU-car", color='green', fontsize=10)draw_vehicle(vehicle2.x, vehicle2.y, vehicle2.yaw, vehicle2.steer, plt, color='green')#显示车辆速度plt.text(vehicle1.x, vehicle1.y - 1.5, "v: %.2f m/s" % vehicle1.v, color='blue', fontsize=10)plt.text(vehicle2.x, vehicle2.y - 1.5, "v: %.2f m/s" % vehicle2.v, color='green', fontsize=10)plt.title("Time: %.2fs" % time)plt.axis("equal")plt.grid(True)plt.plot(trajectory_x1, trajectory_y1, "-b", label="RWPP-trajectory")plt.plot(trajectory_x2, trajectory_y2, "-g", label="FWPP-trajectory")plt.plot(ref_path[target_ind1, 0], ref_path[target_ind1, 1], "b-o", label="RWPP-target")plt.plot(ref_path[target_ind2, 0], ref_path[target_ind2, 1], "g-o", label="FWPP-target")plt.xlim(min(vehicle1.x, vehicle2.x, ref_path[target_ind1, 0], ref_path[target_ind2, 0]) - 3,max(vehicle1.x, vehicle2.x, ref_path[target_ind1, 0], ref_path[target_ind2, 0]) + 3)plt.ylim(min(vehicle1.y, vehicle2.y, ref_path[target_ind1, 1], ref_path[target_ind2, 1]) - 3,max(vehicle1.y, vehicle2.y, ref_path[target_ind1, 1], ref_path[target_ind2, 1]) + 3)plt.legend()plt.grid(True)plt.subplot(3, 1, 2)plt.cla()plt.plot(ref_path[:, 0], ref_path[:, 1], '-.k', linewidth=1.0)plt.plot(trajectory_x1, trajectory_y1, 'b', label="RWPP-trajectory")plt.plot(trajectory_x2, trajectory_y2, 'g', label="FWPP-trajectory")plt.title("actual tracking effect")plt.xlim(min(trajectory_x1[-1], trajectory_x2[-1]) - 1, max(trajectory_x1[-1], trajectory_x2[-1]) + 1)plt.ylim(min(trajectory_y1[-1], trajectory_y2[-1]) - 0.5, max(trajectory_y1[-1], trajectory_y2[-1]) + 0.5)plt.legend()plt.grid(True)plt.subplot(3, 1, 3)plt.cla()plt.plot(lat_err1, 'b', label="RWPP")plt.plot(lat_err2, 'g', label="FWPP")plt.title("lateral error")plt.legend()plt.xlim((len(trajectory_x1) + len(trajectory_x2)) / 2 - 35, (len(trajectory_x1) + len(trajectory_x2)) / 2 + 35)plt.ylim(min(lat_err1[-1], lat_err2[-1]) - 0.1, max(lat_err1[-1], lat_err2[-1]) + 0.1)plt.grid(True)plt.pause(0.001)plt.savefig("temp.png")i += 1if (i % 5) == 0:image_list.append(imageio.imread("temp.png"))imageio.mimsave("display.gif", image_list, duration=0.1)plt.figure(2)plt.subplots_adjust(hspace=0.5, wspace=0.5)  # 调整垂直和水平间距plt.subplot(2, 1, 1)plt.plot(ref_path[:, 0], ref_path[:, 1], '-.k', linewidth=1.0)plt.plot(trajectory_x1, trajectory_y1, 'b', label="RWPP-trajectory")plt.plot(trajectory_x2, trajectory_y2, 'g', label="FWPP-trajectory")plt.title("actual tracking effect")plt.legend()plt.grid(True)plt.subplot(2, 1, 2)plt.plot(lat_err1, 'b', label="Rear Wheel Pure Pursuit")plt.plot(lat_err2, 'g', label="Front Wheel Pure Pursuit")plt.title("lateral error")plt.legend()plt.grid(True)plt.show()#保存图片plt.savefig("final_result.png")plt.close()print("Result saved in final_result.png")print("Result saved in display.gif")        print("Simulation finished!")#打包结果图片保存到output文件夹shutil.move("final_result.png", "output/final_result.png")shutil.move("display.gif", "output/display.gif")    print("Result saved in output folder")print("Done!")#将output文件夹中的图片打包成视频os.system("ffmpeg -r 10 -i output/display%d.png -vcodec mpeg4 -y output/display.mp4")print("Video saved in output folder")   # 删除临时图片for i in range(len(image_list)):os.remove("output/display%d.png" % i)print("Temp images deleted")        # 关闭图形窗口plt.close()  # 关闭图形窗口if __name__ == '__main__':main()             

关键字:网络技术服务_优秀网络广告案例分析_百度seo公司哪家强一点_seo搜索引擎优化试题

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: