User Tools

Site Tools


eeros_architecture:hal:start

This is an old revision of the document!


Hardware Abstraction Layer

The HAL provides an interface between the robot control system (consisting of control system, safety system, and sequencer) and the hardware of the robot. Any signal from a hardware input or output must pass through the HAL.

Configuration of the HAL

The inputs and outputs of the system are given by a specific hardware setup. This can vary widely among different systems. To account for many possible hardware settings we use a configuration file. This file describes the current hardware together with the necessary library to access them, see Configuration File. The configuration given in the file can be loaded as follows:

  HAL& hal = HAL::instance();
  hal.readConfigFromFile(std::string file);

Most probably you want to pass the configuration file name via parameters to main with:

  HAL& hal = HAL::instance();
  hal.readConfigFromFile(&argc, argv);

This call causes the following actions:

  • the configuration file will be parsed
  • the necessary hardware libraries will be loaded
  • for each channel an appropriate object is created with the id given in the configuration file
  • these objects will be registered in the HAL manager

Using HAL Objects

Hal objects are all the input and output channels given in the configuration above. You can use these objects either from the safety system or the control system.

Inputs and Outputs of the Safety System

The safety system can check for each of its safety levels whether the level of certain channels meet given criterias. Such channels are called critical inputs and outputs and have to be defined as such, see Critical Inputs and Outputs. If the criterias are not met you can choose what action has to be taken, see Input / Output Actions.
The safety system will get a handle to tha HAL object with:

  eeros::hal::Input<bool>* emergency = hal.getLogicInput("emergency");

Here, you get a reference to an digital input representing the emergency button. Please make sure that the id (“emergency”) is the same as given in the configuration file.

Inputs and Outputs of the Control System

The control system can read from or write to the hardware solely through its Peripheral Input or Peripheral Output block. When you declare one of these blocks you have to give an id as parameter to its constructor.

  eeros::control::PeripheralInput<double> enc("q0");
  eeros::control::PeripheralOutput<double> controlVoltage("dac0");

Please make sure that the ids (“q0”, “dac0”) are the same as given in the configuration file.

Exclusive Access

Whenever you request an input or output from the HAL manager you will get exclusive access to this channel. This could be the safety system or the control system but not both. There might be a case where an input is a critical input to the safety system and at the same time serves as an input to to control system. In this case you can request the input with

  eeros::control::PeripheralInput<double> enc("q0", false);

Please keep in mind that whenever the safety system or the control system read from this input, the actual hardware is read for any access, which might take some time. It is possible to change the access privilege by releasing a channel and requesting it again, e.g.

  eeros::control::PeripheralInput<double> enc("q0", false);
  HAL& hal = HAL::instance();
  hal.releaseInput("q0");
  eeros::control::PeripheralInput<double> enc("q0");

The latter example is a very uncommon case and might be useful for testing purposes.

eeros_architecture/hal/start.1493538733.txt.gz · Last modified: 2017/04/30 09:52 (external edit)