Matrix OS,core, and HAL

I am trying to understand why these three ‘layers’ exist. Are these layers mutually exclusive as to the functions they allow? It seems the OS layer is for making ‘apps’ - things that a human interacts with at ‘human’ speeds - on an intermittent basis. but which layer is best for a continuously functioning application - like a sound sensing function? Or which layer is best for a function that needs to be robust and can work despite intermittent power outages - restarting itself when necessary.

In my relative new experience with my creator device. i have the following understanding, of this 3 layers:

HAL:
Lowest level of communication with the device, using drivers to handle the communication over SPI. There is one official implementation of a cpp driver, i also wrote my own python implementation for it.

Pros:

  • lowest performance impact
  • call sensors quickly in a row (e.g. useful for developing a drone using the gyro, or driving the everloop very fast)

Cons:

  • you have to write a lot of stuff on your own
  • deal with firmware changes, if you write your own driver
  • only covers the device components
  • needs to be adapted to new devices

Core
The core is an implementation abstracting the HAL with protobuf using zmq. So there is a service running, waiting for events on a zmq. The events can be send by all languages where protobuf is available for. The matrix core also supports devices/functions which are not matrix device specific. e.g. face recognition using a camera and so on.

Pros:

  • abstract way of communication with the device, use different hardware the same way
  • stable - device firmware changes are abstracted
  • more features (e.g. face recognition / wakeword detection service)

Cons:

  • in cases where your applications needs to communicate fast with the hardware the interface is generating a quite high load on your device (communication overhead)
  • more software dependencies

OS (Open System):
Builds a Appstore-like environment around the CORE. You can develop your apps on your local computer, deploy it the the online appstore and then install/start them on your registerd devices. You can also install apps from other developers to your device. (like a smartphone appstore). Its only a deployment infrastructure for CORE Apps, but it also supports online dashboard functionality, so your apps do not need to implement that by their own.

Pros:

  • publishing your projects to the community
  • handle different Creator / Voices-devices in a standard way (field management)
  • even more stuff and features

Cons:

  • currently only nodejs is supported
  • more dependencies
  • same cons as the CORE

Back to you question:

  • If you scenario wants to monitor e.g. the temperate every minute --> CORE / OS.
  • If you want to write high performance stuff (copter/drone) --> HAL
  • Power outage - i don’t know if Matrix-OS is restarting running applications, after a reboot, so CORE Application might be the better choice.
  • Other programming language then nodejs --> CORE
  • continuously functioning --> HAL, CORE, OS
3 Likes

@loom thank you

so i reviewed installation instructions and Matrix core runs as a service. If I install core can I also install Matrix OS as well as the tooling for HAL? will they interfere? The dox state that core can be disabled with
sudo pkill -9 malos

When would I want to do that?

no - you can install all of them at the same time.
as far as i know:

core is installed by:

sudo apt install matrixio-malos
+ some extra services, if you need them, like wakeword, zigbee, zwave:
apt search matrixio-malos-
+ visual stuff using:
apt search malos-eye

OS:

needs to be installed and run manually cloned from github e.g. in a screen or tmux session

HAL:

only needs the matrixio-creator-init package installed
and spi enabled in raspi-config
+ libmatrixio-creator-hal-dev when you need the cpp driver devel files

the sudo pkill -9 malos is eventually used, when you want to kill the core service, having installed the malos / core manually from github.

installed as package you can stop or even disable it in systemd by:

sudo systemctl stop matrixio-malos.service
sudo systemctl disable matrixio-malos.service

you maybe want to disable the core / malos services if you have installed them and don’t need them. it is generating a constant cpu load of about 6% on your raspberry pi 3 while querying the qs, so not realy much of a performance impact on your RPi

1 Like

Great answer @loom, just wanted to add that in generally we recommend to not using malos service and HAL apps (c++ apps using HAL) at the same time because some data loss may occur. We have detected this mostly with the microphone data. If you have Core and a HAL app running you will get some noise in the mics.

Yoel