【交通建模】基于模型的自主交通仿真框架附matlab代码

news2024/9/20 5:37:07

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

MOBATSim(基于模型的自主交通仿真框架)是一个基于MATLAB®和Simulink®的框架,允许用户开发自动驾驶算法并评估其安全性和性能。通过运行交通模拟,可以在二维和三维可视化选项的支持下,在车辆级别和交通级别上测量所实现的组件或算法的安全性。安全分析是影响工程中许多不同领域的重要课题。作为对安全最关键的领域之一,汽车行业需要工具和技术来评估单个车辆以及整个交通的安全性。提出了一种新的仿真框架 MOBATSim,其中基于仿真的故障注入用于评估自动驾驶系统在组件、车辆和交通级别上的安全性。仿真框架是在 MATLAB Simulink 中设计的,为各种驾驶场景建模提供了构建块,包括城市环境地图和车辆的路标。它基于用故障注入模型扩展的自主车辆模型。在模拟运行期间可以注入几种类型的故障,并且可以检查输出以验证用户指定的安全标准。MOBATSim 支持完整的故障-错误-故障链分析,能够揭示部件故障与车辆和交通水平故障之间的关系。说明性案例研究显示了对用户定义的驾驶场景中由特定低级传感器故障引起的安全标准违规的分析。

⛄ 部分代码

%% Run this script for the Cuboid World or Unreal Engine 4 Simulation of the 2D MOBATSim simulation

% This script:

% 1- should be run after finishing the main simulation on the 2D plot because the logged data is required for this script.

% 2- has to be run in order to update the trajectories after each driving scenario in the main simulation.

% 3- opens the drivingScenarioDesigner APP to simulate the vehicle trajectories in the Cuboid World or using Unreal Engine 4

%% Load all the road information 

MOBATKent_Scenario = scenario_map_v1(); % Output of a function automatically generated from the drivingScenarioDesigner after designing the roads

%% Load all vehicles and generate Trajectories

step_length = 20; % Sampling of WAYPOINTS and SPEEDS -> if this script takes too long to run, increase this number!

% To define the Ego Vehicle, just put the code of the corresponding vehicle to the first place.

egoVehicle = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V2_translation.Data(1,3) -V2_translation.Data(1,1) 0]);

waypoints = [-V2_translation.Data((1:step_length:end),3) -V2_translation.Data((1:step_length:end),1) V2_translation.Data((1:step_length:end),2)];

speed = V2_speed.Data(1:step_length:end);

egoVehicle = defineTrajectory(egoVehicle, waypoints, speed);

% Add the non-ego actors

car1 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V1_translation.Data(1,3) -V1_translation.Data(1,1) 0]);

waypoints = [-V1_translation.Data((1:step_length:end),3) -V1_translation.Data((1:step_length:end),1) V1_translation.Data((1:step_length:end),2)];

speed = V1_speed.Data(1:step_length:end);

car1 = defineTrajectory(car1, waypoints, speed);

car3 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V3_translation.Data(1,3) -V3_translation.Data(1,1) 0]);

waypoints = [-V3_translation.Data((1:step_length:end),3) -V3_translation.Data((1:step_length:end),1) V3_translation.Data((1:step_length:end),2)];

speed = V3_speed.Data(1:step_length:end);

car3 = defineTrajectory(car3, waypoints, speed);

car4 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V4_translation.Data(1,3) -V4_translation.Data(1,1) 0]);

waypoints = [-V4_translation.Data((1:step_length:end),3) -V4_translation.Data((1:step_length:end),1) V4_translation.Data((1:step_length:end),2)];

speed = V4_speed.Data(1:step_length:end);

car4 = defineTrajectory(car4, waypoints, speed);

car5 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V5_translation.Data(1,3) -V5_translation.Data(1,1) 0]);

waypoints = [-V5_translation.Data((1:step_length:end),3) -V5_translation.Data((1:step_length:end),1) V5_translation.Data((1:step_length:end),2)];

speed = V5_speed.Data(1:step_length:end);

car5 = defineTrajectory(car5, waypoints, speed);

car6 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V6_translation.Data(1,3) -V6_translation.Data(1,1) 0]);

waypoints = [-V6_translation.Data((1:step_length:end),3) -V6_translation.Data((1:step_length:end),1) V6_translation.Data((1:step_length:end),2)];

speed = V6_speed.Data(1:step_length:end);

car6 = defineTrajectory(car6, waypoints, speed);

car7 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V7_translation.Data(1,3) -V7_translation.Data(1,1) 0]);

waypoints = [-V7_translation.Data((1:step_length:end),3) -V7_translation.Data((1:step_length:end),1) V7_translation.Data((1:step_length:end),2)];

speed = V7_speed.Data(1:step_length:end);

car7 = defineTrajectory(car7, waypoints, speed);

car8 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V8_translation.Data(1,3) -V8_translation.Data(1,1) 0]);

waypoints = [-V8_translation.Data((1:step_length:end),3) -V8_translation.Data((1:step_length:end),1) V8_translation.Data((1:step_length:end),2)];

speed = V8_speed.Data(1:step_length:end);

car8 = defineTrajectory(car8, waypoints, speed);

car9 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V9_translation.Data(1,3) -V9_translation.Data(1,1) 0]);

waypoints = [-V9_translation.Data((1:step_length:end),3) -V9_translation.Data((1:step_length:end),1) V9_translation.Data((1:step_length:end),2)];

speed = V9_speed.Data(1:step_length:end);

car9 = defineTrajectory(car9, waypoints, speed);

car10 = vehicle(MOBATKent_Scenario, ...

    'ClassID', 1, ...

    'Position', [-V10_translation.Data(1,3) -V10_translation.Data(1,1) 0]);

waypoints = [-V10_translation.Data((1:step_length:end),3) -V10_translation.Data((1:step_length:end),1) V10_translation.Data((1:step_length:end),2)];

speed = V10_speed.Data(1:step_length:end);

car10 = defineTrajectory(car10, waypoints, speed);

%% Open the scenario in drivingScenarioDesigner (This way it can be also edited or simulated 3D in Unreal Engine)

drivingScenarioDesigner(MOBATKent_Scenario)

%% This function uses try-catch-try structure as a workaround the geometric errors caused by the "trajectory" function

function car = defineTrajectory(car, waypoints, speed)

try

    trajectory(car, waypoints, speed)

catch

    [~,I,~] = unique(waypoints, 'rows','stable');

    waypoints = waypoints(I,:,:);

    speed = speed(I,:,:);

    try

        trajectory(car, waypoints, speed)

    catch

        idx =(speed~=0);

        speed = (speed(idx));

        waypoints = waypoints(idx,:,:);

        try

            trajectory(car, waypoints, speed);

        catch

            % Try to generate waypoints by skipping the first 10 waypoints

            waypoints = waypoints(10:end,:,:);

            speed = speed(10:end);

            try

                trajectory(car, waypoints, speed);

            catch

                % The last try: Sample each waypoint in 5

                I = 1:5:length(waypoints);

                waypoints = waypoints(I,:,:);

                speed = speed(I,:,:);

                

                % If this also doesn't work, then it simply fails, try changing the scenario.

                trajectory(car, waypoints, speed);

            end

        end

    end

end

end

⛄ 运行结果

⛄ 参考文献

​[1] Saraoglu M ,  Morozov A ,  Janschek K . MOBATSim: MOdel-Based Autonomous Traffic Simulation Framework for Fault-Error-Failure Chain Analysis - ScienceDirect[J]. IFAC-PapersOnLine, 2019, 52( 8):239-244.

⛄ Matlab代码关注

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/58587.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【深入浅出Java并发编程指南】「难点 - 核心 - 遗漏」让我们一起探索一下CyclicBarrier的技术原理和源码分析

CyclicBarrier和CountDownLatch CyclicBarrier和CountDownLatch 都位于java.util.concurrent这个包下,其工作原理的核心要点: CyclicBarrier工作原理分析 那么接下来给大家分享分析一下JDK1.8的CyclicBarrier的工作原理。 简单认识CyclicBarrier 何为…

Nginx动静分离、缓存配置、性能调优、集群配置

一. Nginx动静分离 1. 准备 1个web程序:部署在7061端口,启动 【dotnet NginxWeb.dll --urls"http://*:7061" --ip"127.0.0.1" --port7061】 Nginx程序:监听7000端口 2. 目的 比如单独启动部署在7061端口下的web程序&am…

c++ 静态库,动态库的制作和使用

文章目录1.什么是库?2.静态库的制作1.静态库的命名规则2.静态库的制作与使用1.静态库的制作2.静态库的使用3.动态库的制作1.动态库的命名规则2.动态库的制作与使用1.动态库的制作2.动态库的使用3.动态库加载失败的原因4.静态库和动态库的对比1.程序编译成可执行文件…

[附源码]Python计算机毕业设计Django基于Java的失物招领平台

项目运行 环境配置: Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术: django python Vue 等等组成,B/S模式 pychram管理等等。 环境需要 1.运行环境:最好是python3.7.7,…

时序数据库选型

目录一、当前主流的时序数据库二、各库特性1、Influxdb2、Timescale3、Druid4、Kdb5、Graphite6、RRDtool7、OpenTSDB8、TDengine9、DolphinDB三、优缺点对比因为个人用的go,所以调研及对比主要针对适配了go语言的数据库。 一、当前主流的时序数据库 排名参考于h…

基于PHP+MySQL动漫专题网站系统的设计与实现

随着时代的发展,人们兴趣爱好也越来越广泛,动漫是当前年轻人比较钟爱的一个兴趣爱好之一,每年都会有大量的动漫爱好者定期的举办一些交流活动等,但是线下的这种交流方式明显不能满足当前动漫爱好者的需求,为此我开发了…

Zen of Python(python之禅)

在python中导入import this就会显式: 以下是中文英文翻译: Beautiful is better than ugly. 优美比丑陋好 Explicit is better than implicit. 清晰比晦涩好 Simple is better than complex. 简单比复杂好 Complex is better than complicated. 复杂比错…

【全干工程师必学】一文搞懂Vue2.0

一文搞懂Vue2.0一、前端工程化二、WebPack是什么基本使用实现奇偶行变色1.初始化包管理工具2.安装jquery3.在项目中安装webpack4.在项目中配置webpack5.运行代码mode 的可选值developmentproductionwebpack.config.js 文件的作用webpack 中的默认约定自定义打包的入口与出口web…

uni-app开发常用操作速查记录

记录一下uni-app中常用的使用方法或是操作步骤,方便后期速查使用. 1.设置对象属性 2.组件中数据变化监听方法 3.微信开发者工具中全局搜索与局部搜索 4.Page对象与Componet对象组成 5.tabbar页面切换方法 6.组件中自定义函数的参数传递 7.m…

Android Jetpack Compose的基本介绍

目录一、引言:Android Jetpack1.Jetpack是什么?2. 常用的Jetpack库二、Compose的基本概念1.什么是Jetpack Compose2.Compose的编程思想三、 Compose简单的案例: 一个倒计时效果1.构建一个Compose项目2.声明一个倒计时的UI3.利用线程使其动起来4.实现效果…

快速了解Docker

目录 1.简介 2.Docker的安装及环境配置 2.1.查看是否是root用户 2.2.查看当前内核版本 2.3.更新yum源 2.4.安装Docker所需要的工具包 2.5.设置yum源 2.6.下载安装Docker 2.7.启动Docker并且设置开机自启动 2.8.测试是否安装成功 3.Docker阿里云镜像仓库配置 4.Docker常…

C++ vector

目录 1.vector的介绍及使用 1.1 vector的介绍 1.2 vector的使用 1.2.1 vector的定义 1.2.2 vector iterator 的使用 1.2.3 vector 空间增长问题 1.2.3 vector 增删查改 1.2.4 vector 迭代器失效问题。(重点) 1.2.5 vector 在OJ中的使用 2.vec…

【Linux】Linux的常见指令详解(上)

目录 前言 ls pwd cd mkdir touch rm man tree nano cp mv cat echo more/less 前言 🧁Linux作为相较于windows的另一种操作系统,同时基于其开源的优越性,使得其在各各企业的使用率极高。因此学好Linux操作系统对我们来说是…

Mongoose应用和文件文件的上传和下载

一、Express框架访问MongoDB数据库 1、目的: ​ (1)mongoose模块的使用 ​ (2)学会代码的封装:dao层、service层、接口层 ​ (3)MVC设计思想:M(Model)、V(View)、C(C…

[附源码]Python计算机毕业设计Django基于SpringBoot的演唱会购票系统论文2022

项目运行 环境配置: Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术: django python Vue 等等组成,B/S模式 pychram管理等等。 环境需要 1.运行环境:最好是python3.7.7,我…

c#与mysql连接和操作教程(增、删、改、查)

一、mysql的连接(使用的是vs2019) 1. 在一个项目中选择 工具 > NgtGet包管理器 > 管理解决方案的NuGet程序包 2. 搜索MySql.Data,然后下载,并在右边选着对应的项目进行安装(ps:每个项目要连接数据库…

【身份证识别】基于BP神经网络实现身份证识别附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。 🍎个人主页:Matlab科研工作室 🍊个人信条:格物致知。 更多Matlab仿真内容点击👇 智能优化算法 …

代码随想录刷题|LeetCode 300.最长递增子序列 674. 最长连续递增序列 718. 最长重复子数组

目录 300.最长递增子序列 思路 1、dp[i]的定义 2、递推公式 3、dp数组初始化 4、确定遍历顺序 5、推导dp数组 最长递增子序列 674. 最长连续递增序列 思路 最长连续递增序列 动态规划 贪心算法 718. 最长重复子数组 思路 1、确定dp数组的含义 2、确定递推公式 3、dp数组初始化…

docker 命令

目录 Docker 环境信息命令 docker info docker version 系统日志信息常用命令 docker events docker logs docker history 容器的生命周期管理命令 docker create docker run 常用选项 系统 网络 健康检查 命名空间选项 cgroup资源限制选项 CPU CPUset devi…

李宏毅《DLHLP》学习笔记7 - Voice Conversion 1

视频链接:https://www.youtube.com/watch?vJj6blc8UijY&listPLJV_el3uVTsO07RpBYFsXg-bN5Lu0nhdG&index9&ab_channelHung-yiLee 课件链接:https://speech.ee.ntu.edu.tw/~tlkagk/courses/DLHLP20/Voice%20Conversion%20(v3).pdf 1. 语音转…