Skip to content

Configuration file

Guillem Castro edited this page Apr 27, 2019 · 1 revision

An rt-data application may be configured using configuration files. They allow to change some behaviours of the application without having to re-compile it.

The configuration file represents an AST. Each node contains a value (or configuration parameter) and can have multiple child nodes. The default implementation uses JSON files.

Structure

As previously said, a configuration file represents an abstract syntax tree (AST). All nodes in the tree contain either a value (leaf node), that we call a configuration parameter, or a variable number of child nodes (tree node).

The root node is the node representing the whole configuration. The child tree nodes of the root node are called sections. Sections are groups of configurations that are used to configure one single part of the system. Some sections are,

  • Sensors
  • I/O
  • Serialization
  • ...

The root node might also have some child leaf nodes for system-wide configuration parameters.

Except for the root node, all nodes are identified by a text identifier. It must be unique among siblings, but not among unrelated nodes.

Allowed types for the configuration parameters

You can see the allowed data types in the configuration file for the parameters, and the corresponding C++ type, is shown in the following table,

Type C++ type
text std::string
integer int64_t
unsigned integer uint64_t
real double
array std::vector

Specification

The specification for the configuration file is given as a JSON. All strings surrounded by <> are meant to be replaced, and is followed by the expected type for the parameter.

{ // Root node //
    "sensors": { // Section //
        "<sensor name>::text": { // Tree node //
            "name": "<sensor name>::text", // Leaf node //
            "topic": "<topic>::text",
            "sampling_rate": <sampling_rate>::real,
            ...other sensor-specific configuration...
        }
    }
}

Sensors

The sensors section has as childs the configuration of all the sensors in the system. Every sensor configuration must contain, at least, the following parameters,

  • name: A text identifier for the sensor. Must be unique.
  • topic: The topic where the sensor will publish its data to.
  • sampling rate: The rate in nanoseconds at which the framework will sample the sensor.

Clone this wiki locally