A comprehensive toolbox containing modular APIs and turnkey demos for autonomous driving using AutoDRIVE Ecosystem and MathWorks tool suite.
This section describes the MATLAB API for AutoDRIVE, which can be used to develop modular as well as end-to-end autonomous driving algorithms using textual programming. This API is primarily designed for "software engineers" who prefer a script/function-based workflow.
Note
Please skip this setup if you have already installed the autodrive_simulink_api.
- Install the Java library:
-
Place the
WebSocket-1.0.0.jarfile on the static Java class path in MATLAB by editing thejavaclasspath.txtfile (create the file if it does not exist). Run the following in MATLAB Command Window:edit(fullfile(prefdir,'javaclasspath.txt'))
For example, if the location of the
jarfile isC:\AutoDRIVE-MathWorks\autodrive_matlab_api\lib\target\WebSocket-1.0.0.jar, then open the static class path file with the above command and add the full path to it. Make sure that there are no other lines with aWebSocket-*entry. You can refer to MATLAB's Documentation for more information on the static Java class path.After having done this, restart MATLAB and check that the path was read by MATLAB properly by running the
javaclasspathcommand. The newly added path should appear at the bottom of the list, before theDYNAMIC JAVA PATHentries. Note that seeing the entry here does not mean that MATLAB necessarily found thejarfile properly. You must make sure that the actualjarfile is indeed available at this location. -
[OPTIONAL] To build the
jarfile yourself, it is recommended to use Apache Maven (tested with version 3.8.1) with Java Development Kit (tested with version 8u411). Maven will automatically take care of downloading theJava-WebSocketlibrary and neatly package everything into a single file (an "uber jar") based on thepom.xml. Once themvncommand is on your path, simplycdto thelibdirectory and execute themvn packagecommand.
-
- Add the
autodrive_matlab_apidirectory to MATLAB path by right-clicking on it from MATLAB's file explorer and selectingAdd to Path→Selected Folders and Subfolders.
-
Execute AutoDRIVE MATLAB API:
autodrive = example_{vehicle}(4567)
Replace
{vehicle}by one of the available objects:roboracerfor RoboRacer (formerly F1Tenth)hunterfor AgileX Hunter SEhuskyfor Clearpath Husky A200rzrfor Polaris RZR Pro R 4 Ultimate
-
Terminate AutoDRIVE MATLAB API:
autodrive.stop delete(autodrive) clear autodrive
This section describes the Simulink API for AutoDRIVE, which can be used to develop modular as well as end-to-end autonomous driving algorithms using graphical programming. This API is primarily designed for "system engineers" who prefer an interactive MBD/MBSE toolchain.
Note
Please skip this setup if you have already installed the autodrive_matlab_api.
- Install the Java library:
-
Place the
WebSocket-1.0.0.jarfile on the static Java class path in MATLAB by editing thejavaclasspath.txtfile (create the file if it does not exist). Run the following in MATLAB Command Window:edit(fullfile(prefdir,'javaclasspath.txt'))
For example, if the location of the
jarfile isC:\AutoDRIVE-MathWorks\autodrive_simulink_api\lib\target\WebSocket-1.0.0.jar, then open the static class path file with the above command and add the full path to it. Make sure that there are no other lines with aWebSocket-*entry. You can refer to MATLAB's Documentation for more information on the static Java class path.After having done this, restart MATLAB and check that the path was read by MATLAB properly by running the
javaclasspathcommand. The newly added path should appear at the bottom of the list, before theDYNAMIC JAVA PATHentries. Note that seeing the entry here does not mean that MATLAB necessarily found thejarfile properly. You must make sure that the actualjarfile is indeed available at this location. -
[OPTIONAL] To build the
jarfile yourself, it is recommended to use Apache Maven (tested with version 3.8.1) with Java Development Kit (tested with version 8u411). Maven will automatically take care of downloading theJava-WebSocketlibrary and neatly package everything into a single file (an "uber jar") based on thepom.xml. Once themvncommand is on your path, simplycdto thelibdirectory and execute themvn packagecommand.
-
- Add the
autodrive_simulink_apidirectory to MATLAB path by right-clicking on it from MATLAB's file explorer and selectingAdd to Path→Selected Folders and Subfolders.
Note
If you face issues installing/running the AutoDRIVE Simulink API or examples, check out the Troubleshooting Guide for helpful tips.
Run the vehicle-specific example file:
example_roboracer.slxfor RoboRacer (formerly F1Tenth)example_hunter.slxfor AgileX Hunter SEexample_husky.slxfor Clearpath Husky A200example_rzr.slxfor Polaris RZR Pro R 4 Ultimate
Note
The AutoDRIVE Simulink API, which is implemented as a Level-2 MATLAB S-Function, will automatically take care of creating a WebSocket server instance upon running the Simulink model and will ensure a graceful exit upon termination by stopping the server instance, deleting it, and clearing it from the memory.
This section describes various turnkey demos for modular as well as end-to-end autonomous driving algorithms developed using AutoDRIVE Ecosystem and MathWorks tool suite.
![]() |
autodrive_rzr_aeb_mbd - Platform: RZR Pro R 4 Ultimate - Sensors: Camera + IMU + Encoders - Environment: Handcrafted Dirt Road in Thick Vegetation - Task: Autonomous Emergency Braking (AEB) - Approach: Model-Based Design (MBD) using Simulink |
![]() |
autodrive_rzr_aeb_mbse - Platform: RZR Pro R 4 Ultimate - Sensors: Camera + IMU + Encoders - Environment: Handcrafted Dirt Road in Thick Vegetation - Task: Autonomous Emergency Braking (AEB) - Approach: Model-Based Systems Engineering (MBSE) using System Composer |
![]() |
autodrive_husky_g2g_mbse - Platform: Husky A200 - Sensors: GNSS + IMU - Environment: Procedurally generated uneven terrain - Task: Autonomous Go-to-Goal (G2G) Navigation - Approach: Model-Based Systems Engineering (MBSE) using System Composer |
Taxonomy & Nomenclature:
*_alg: Algorithm Development using MATLAB*_mbd: Model-Based Design (MBD) using Simulink*_mbse: Model-Based Systems Engineering (MBSE) using System Composer




