You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Main.cpp

In the main file, all important parameters are initialized. This includes the IDs of the vehicles the software is supposed to listen to, or the length of a computation period. Most of these parameters can be set in the command line. Also, the timer from the cpm library and the communication class are set up.

In the following, the Middleware waits for all connected HLCs (set using the vehicle IDs) to communicate a ReadySignal, denoting that they have finished their part of the initialization. The ReadySignal messages are sent by the HLCs and have the ID "hlc_" + vehicle_id, where the latter is the ID of the vehicle the HLC is responsible for. After that, the timer is started and the Middleware starts to periodically perform its tasks.

In each step, first the most recent vehicle states and observations are taken from the communication class, put into a DDS message and sent to the HLC(s), together with the current timestamp. These messages function as start signals for the HLCs. Then, the last response times of all connected HLCs are checked. In the real-time case, if they haven't sent any vehicle commands before or if the last message is older than one period, an error is logged to make clear that a period was missed. In the simulated time case, the Middleware waits for all connected HLCs  to send a vehicle command before progressing to the next period.

This behavior is repeated until the Middleware is stopped.

Communication.hpp

This class is responsible for separating all tasks related to the communication, including the initialization of RTI DDS participants, from the main file. Apart from initialization, it:

  • collects the last response times of the HLCs regarding vehicle command messages of all command types (these messages are received an propagated using the typed communication class)
  • can be used to send the vehicle + time information message to the HLC
  • can be used to obtain the most recent vehicle state and observation messages
  • passes SystemTrigger messages sent by the LCC to the HLC
  • includes a function to wait for all ReadySignal messages sent by the connected HLCs (as described above)

TypedCommunication.hpp

The methods and objects to receive and pass through vehicle commands from the HLCs to the vehicles as well as to get the last response times of the HLCs are the same for all command types. This class provides a template to set up this functionality without redundant code and is used in the typed communication class.

  • No labels