This example shows how to distribute Automated Parking Valet application among various nodes in a ROS network in Simulink®. This example extends the Automated Parking Valet (Automated Driving Toolbox) example in the Automated Driving Toolbox™. Using the Simulink model in the Automated Parking Valet in Simulink example, tune the planner, controller and vehicle dynamics parameters before partitioning the model into ROS nodes.
A typical autonomous vehicle application has the following workflow.
This example concentrates on simulating the Planning, Control and the Vehicle components. For Localization, this example uses pre-recorded map localization data. The Planning component are further divided into Behavior planner and Path Planner components. This results in a ROS network comprised of four ROS nodes:
Vehicle Sim. The following figure shows the relationships between each ROS node in the network and the topics used in each.
Observe the division of the components into four separate Simulink models. Each Simulink model represents a ROS node.
1. Open the the vehicle model.
Vehicle model subsytem contains a Bicycle Model block,
Vehicle Body 3DOF, to simulate the vehicle controller effects and sends the vehicle information over ROS network through ROS Publish blocks in the
1. Open the behavioral planner model.
2. This model reads the current vehicle pose, velocity, and direction from ROS network, and sends the next goal. It checks if the vehicle has reached the goal pose of the segment using
Goal Checker model run when a new message is available on either
4. The model sends the status if the vehicle has reached the parking goal using the
/reachgoal topic, which uses a
std_msgs/Bool message. All the models stop simulation when this message is
1. Open the path planner model.
2. This model plans a feasible path through the environment map using a
pathPlannerRRT object, which implements the optimal rapidly exploring random tree (RRT*) algorithm and sends the plan to the controller over the ROS network.
Path Planner subsystem runs when a new message is available on
1. Open the vehicle controller model.
2. This model calculates and sends the steering and velocity commands over ROS network.
3. Controller subsystem runs when a new message is available on the
Verify that the behavior of the model remains the same after partitioning the system into four ROS nodes.
rosinit in MATLAB® Command Window to initialize the global node and ROS master
Initializing ROS master on http://ah-agadkari:56533/. Initializing global node /matlab_global_node_83566 with NodeURI http://ah-agadkari:56537/
2. Load the pre-recorded localization map data in MATLAB base workspace using the
exampleHelperROSValetLoadLocalizationData helper function.
3. Open all the models and start simulation using
exampleHelperROSValetStartSimulation helper function. 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.
Visualization subsystem in the vehicle model generates the results for this example.
isualizePath block is responsible for creating and updating the plot of the vehicle paths shown previously. The vehicle speed and steering commands are displayed in a scope.
Generate ROS applications for
Controller nodes, and simulate the
Vehicle node in MATLAB and compare the results with simulation. Refer to Generate a Standalone ROS Node from Simulink® example for guidance on generating ROS nodes.
Path planner and
Controller ROS nodes.
2. Open the vehicle model.
3. From the Simulation tab, click Run 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 using
Shutting down global node /matlab_global_node_83566 with NodeURI http://ah-agadkari:56537/ Shutting down ROS master on http://ah-agadkari:56533/.