Shared or common functionality for the communication via DDS is bundled in the cpm library (cpm_lib). This library is written in C++ and is used by the vehicle. The HLC, on the other hand, is supposed to be more or less independent from the implementation language of the library. Programmers of the HLC programs should also not be troubled with its implementation details. Thus, it was decided to create a Middleware which performs most of the communication tasks that otherwise would have to be implemented in some form in the HLC.

The Middleware coordinates the communication with the DDS domain of the vehicle, LCC and further participants with the HLC. It is responsible for sending timed pre-aggregated vehicle information to the HLC which can be interpreted as a start signal for starting the computation using this data, and it sends the commands generated by the HLC as a reaction to this start signal to the vehicles. Any timing task is performed by the Middleware, so period and offset for the interaction with the HLC are set here (and can be set when starting the application using command line parameters).  The HLC is informed about the current time, in case that is necessary for its own computations.

The application also manages further internal timing according to the current simulated and real time, propagating the LLC's start and stop signals and waiting for the HLC to finish its computation in the simulated case. It is also responsible for logging communication or timing errors regarding the HLC.

The HLC only needs to integrate and configure a reader and a writer to listen to the vehicle and send commands. Thus, as long as the programming language is supported by RTI DDS, the programmer does not need to know the implementation details of the communication.

Command Line Parameters

Parameter Usage Example

./middleware --vehicle_ids=1,7,8 --node_id=middleware --wait_for_start=true --dds_domain=1 --simulated_time=false

Important parameters

Other parameters

Scripts

Different scripts have already been written to test and deploy the middleware together with all necessary libraries and a matlab program on the local or other machines. These scripts can be found in ./Middleware/remote and ./Middleware/local.

Bash Scripts for Deployment on Other Machines

Basic usage

Editing the HLC Script

Currently, the content of the Matlab folder is uploaded to the HLCs. Any Matlab script contained in this folder can be used as a HLC script. To call a hlc script, simply change the last line of matlab_start.bash

/home/controller/Documents/Matlab/bin/matlab -nodisplay -nosplash -logfile matlab.log -nodesktop -r "cd '/home/controller/Documents/Remote/Matlab/'; dummy_line_speedCurvature(${vehicleID})"

to

/home/controller/Documents/Matlab/bin/matlab -nodisplay -nosplash -logfile matlab.log -nodesktop -r "cd '/home/controller/Documents/Remote/Matlab/'; name_of_your_script(${vehicleID})"

Debugging

If the middleware or HLC script for some reason do not work - that is, if the vehicle does not do anything up to 60 seconds after the scripts were started - possible error messages do not appear in the console window where bash deploy.bash ... was called.

You can use

sshpass -p password ssh controller@ip_address

(replace password and ip_address) to remotely access the HLC. Then, type ls. Your should see two files (and some other files): middleware.txt and matlab.log. Using cat, you can print the content of these files in the console. They contain the output of the consoles that were started remotely on the HLC to start the Middleware and the Matlab script and may contain error messages that can help you with debugging e.g. your script.

TODO: More info here?

Communication between HLC and Middleware

TODO: Mention IDL type / what it does / what the middleware expects, refer to Matlab tutorial