Skip to content

Commit 98a38ed

Browse files
authored
Add MATLAB API documentation to README
Added MATLAB API section with setup and usage instructions.
1 parent cacd7ab commit 98a38ed

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
<p align="center">
22
<img src="media/AutoDRIVE-Logo.png" alt="AutoDRIVE" height="80"/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="media/MathWorks-Logo.png" alt="MathWorks" height="80"/>
33
</p>
4+
5+
# MATLAB API
6+
7+
<p align="justify">
8+
This section describes the MATLAB API for AutoDRIVE, which can be used to develop modular as well as end-to-end autonomous driving algorithms.
9+
</p>
10+
11+
## SETUP
12+
13+
1. Install the Java library:
14+
- Place the [`WebSocket-1.0.0.jar`](lib/target/WebSocket-1.0.0.jar) file on the static Java class path in MATLAB by editing the `javaclasspath.txt` file (create the file if it does not exist). Run the following in MATLAB Command Window:
15+
```MATLAB
16+
edit(fullfile(prefdir,'javaclasspath.txt'))
17+
```
18+
For example, if the location of the `jar` file is `C:\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 a `WebSocket-*` entry. You can refer to [MATLAB's Documentation](https://www.mathworks.com/help/matlab/matlab_external/static-path-of-java-class-path.html) for more information on the static Java class path.
19+
20+
After having done this, **restart MATLAB** and check that the path was read by MATLAB properly by running the `javaclasspath` command. The newly added path should appear at the bottom of the list, before the `DYNAMIC JAVA PATH` entries. Note that seeing the entry here does not mean that MATLAB necessarily found the `jar` file properly. You must make sure that the actual `jar` file is indeed available at this location.
21+
- **[OPTIONAL]** To build the `jar` file yourself, it is recommended to use [Apache Maven](https://maven.apache.org/download.cgi) (tested with version 3.8.1) with [Java Development Kit](https://www.oracle.com/java/technologies/downloads/?er=221886#java8) (tested with version 8u411). Maven will automatically take care of downloading the [`Java-WebSocket`](https://github.com/TooTallNate/Java-WebSocket) library and neatly package everything into a single file (an "uber jar") based on the [`pom.xml`](lib/pom.xml). Once the `mvn` command is on your path, simply `cd` to the `lib` directory and execute the `mvn package` command.
22+
2. Add the `autodrive_matlab_api` directory to MATLAB path by right-clicking on it from MATLAB's file explorer and selecting `Add to Path` &rarr; `Selected Folders and Subfolders`.
23+
24+
## USAGE
25+
26+
1. Execute AutoDRIVE MATLAB API:
27+
```MATLAB
28+
autodrive = example_{vehicle}(4567)
29+
```
30+
Replace `{vehicle}` by one of the available objects:
31+
- `roboracer` for [RoboRacer (formerly F1Tenth)](https://roboracer.ai)
32+
33+
2. Terminate AutoDRIVE MATLAB API:
34+
```MATLAB
35+
autodrive.stop
36+
delete(autodrive)
37+
clear autodrive
38+
```

0 commit comments

Comments
 (0)