The Hardware Abstraction Layer provides an interface between the robot control system and the hardware of the robot. As we do not have any real output we will use a simulator, see Simulator. The system in this example uses inputs and outputs.
In the EEROS library you will find a directory with examples. For this example see HalTest1.cpp.
Open a shell in the build directory of your EEROS library and run
$ ./halTest1 -c HalTest1Config.json
This examples creates a small control system with a couple of peripheral input and output blocks as shown below.
The dashed lines denote the feedback of the signals by the simulator.
The main sequence alters the values on digital and analog outputs periodically. A separate periodic task logs the digital and analog inputs.
invertedand we get the logical inversion of digital output 0. The value of digital input 0 changes every 5 seconds.
A peripheral output block delivers a signal to external hardware. Its signal value can be accessed with a get method, see line 46 in the comment in the example code in HalTest1.cpp.
Alternatively the signal in the HAL could be accessed by getting an reference to the corresponding output block with
auto digOut = hal.getLogicOutput("dOut0", false); // line 42
The signal value can then be logged with block with
log.info() << digOut->get(); // line 47
You have to make sure to access the output with non-exclusive rights, because the control system already has a handle to it, see line 28 in
halTest1.hpp. Likewise, the control system must access the same output in the same fashion.