Main Content

自动停车代客with ROS in Simulink

Distribute an automated parking valet application among various nodes in a ROS network in Simulink®. This example extends the自动停车代客(自动驾驶工具箱)自动驾驶Toolbox™中的示例。在Simulink示金宝app例中使用Simulink模型,在将模型分配到ROS节点之前,在Simulink示例中使用Simulink示例中调整计划器,控制器和车辆动力学参数。

Prerequisite:自动停车代客(自动驾驶工具箱),,,,从Simulink®生成独立的ROS节点金宝app

Introduction

典型的自动驾驶汽车应用程序具有以下工作流程。

This example concentrates on simulating the规划,,,,控制车辆组件。为了Localization,,,,this example uses pre-recorded map localization data. The规划component are further divided intoBehavior plannerandPath Planner组件。这导致ROS网络由四个ROS节点组成:行为计划者,,,,Path Planner,,,,控制lerand车辆模拟。这following figure shows the relationships between each ROS node in the network and the topics used in each.

探索Simulink R金宝appOS节点和连接性

Observe the division of the components into four separate Simulink models. Each Simulink model represents a ROS node that sends and receives messages on different topics.

车辆模拟节点

1.打开车辆型号。

open_system(“ rosvaletvehiclesexample”);

2.这订阅子系统包含ROS订阅blocks that read input data from the控制ler节点。

3.车辆型号子系统包含a自行车模型(自动驾驶工具箱)堵塞,车辆Body 3DOF,模拟车辆控制器的效果并通过ROS通过ROS网络发送车辆信息Publishblocks in thePublishsubsystem.

行为计划者节点

1.打开行为规划师模型。

open_system('Rosvaletbehavioralplannerexample');

2.该模型从ROS网络读取当前的车辆姿势,速度和方向,并发送下一个目标。它检查车辆是否使用示例HelperrosvaletGoalChecker

3.行为计划者and目标检查器model runs when a new message is available on either/电流or/currentvel

4. The model sends the status if the vehicle has reached the parking goal using the/达成目标topic, which uses astd_msgs/bool信息。所有模型在此消息时停止模拟true

路径计划器节点

1.打开路径计划器模型。

open_system('RosvaletPathplanerexample');

2.该模型计划使用环境图的可行途径pathPlannerRRT(自动驾驶工具箱)object, which implements the最佳快速探索随机树(RRT*)算法并通过ROS网络将计划发送到控制器。

3.Path Planner当有新消息可用时,子系统运行/plannerConfigor/NextGoaltopics.

控制器节点

1.打开车辆控制器型号。

open_system(“ RosvaletControllereXample”);

2.这个模型计算并发送转向一个d velocity commands over the ROS network.

3.当前有新消息可用时,控制器子系统在/velprofile话题。

Simulate the ROS nodes to verify partitioning

验证将系统分配为四个ROS节点后,模型的行为保持相同。

1. Runrosinitin MATLAB® Command Window to initialize the global node and ROS master

rosinit
Launching ROS Core... ..........Done in 10.4244 seconds.在http://192.168.88.1:56949上初始化ROS Master。初始化全局节点/matlab_global_node_90052 with nodeuri http://ah-avijayar:57028/

2.使用该预先录制的本地化映射数据在MATLAB基本工作区中加载examplehelperrosvaletLoadLocalizationData助手功能。

examplehelperrosvaletLoadLocalizationData;

3.打开仿真模型。

open_system('rosvaletsimulationexample.slx');

在左停车选择区,您也可以选择一个位置。默认停车位是第一排的第六名。

4.在“仿真”选项卡中,单击fromSIMULATEsection或运行sim('rosvaletsimulationexample.slx')in MATLAB Command Window. A figure opens and shows how the vehicle tracks the reference path. The blue line represents the reference path while the red line is the actual path traveled by the vehicle. Simulation for all the models stop when the vehicle reaches the final parking spot.

sim('rosvaletsimulationexample.slx');

仿真结果

可视化车辆模型中的子系统生成了此示例的结果。

open_system('ROSValetVehicleExample/Vehicle model/Visualization');

visualizePath块负责创建和更新前面显示的车辆路径的图。车辆速度和转向命令显示在范围中。

open_system("ROSValetVehicleExample/Vehicle model/Visualization/Commands"

Deploy ROS Nodes

Generate ROS applications forBehavioral planner,,,,路径策划者,,,,控制ler节点,并模拟车辆MATLAB中的节点并将结果与​​模拟进行比较。有关生成ROS笔记的更多信息,请参见从Simulink®生成独立的ROS节点金宝app

1.部署Behavioral planner,,,,路径策划者and控制lerROS节点。

2.Open the vehicle model.

open_system(“ rosvaletvehiclesexample”);

3. From theSimulation选项卡,单击to start the simulation.

4. Observe the vehicle movement on the plot and compare the results from simulation run.

5. Shut down the ROS network usingRosshutdown

Rosshutdown
Shutting down global node /matlab_global_node_90052 with NodeURI http://ah-avijayar:57028/ Shutting down ROS master on http://192.168.88.1:56949.