-
Notifications
You must be signed in to change notification settings - Fork 4
Building and Installing
The mads-broker machine has the following Ethernet interfaces:
- Intel Internet - Local one (mads-broker.local in MFJA)
- 192.168.1.100 Ip4 (bottom plate on the MFJA Linux machine)
- Realtek internet - Outside (MFJA Network)
Open a terminal and type sudo nano /etc/avahi/avahi-daemon.conf, then scroll down and replace no with yes in the lines starting with publish-hinfo and publish-workstation. This will broadcast on the local network the machine with the hostname mads-broker.local.
Run the following:
sudo apt update
sudo apt upgrade -y
sudo apt install build-essential cmake cmake-curses-gui git gh clang libmosquitto-dev libmosquittopp-dev openssl libcurl4-openssl-dev figlet clang-format libgpiod-devNow:
sudo update-alternatives --alland always pick clang or clang++ when asked. For the remaining choices, keep the default.
Install Visual Studio Code, using Ubuntu App Center
Within VSCode, install a few extensions as gitgraph, CMake, CMake Tools, figlet, clang-format
Follow instructions on Docker website to install Docker, then also follow the post-installation steps.
Test if it works with:
docker run hello-worldIt must work without asking you any password.
The broker shall also provide a Network Time Protocol service (ntp) to the local network. Proceed as follows:
sudo apt install chronyThen edit the file /etc/chrony/chrony.conf and add the following lines at the end of it:
# Serve NTPD on the local network
allow 192.168.1.0/16
Then restart the service:
sudo systemctl restart chrony.serviceSee also here: https://ubuntu.com/server/docs/how-to-serve-the-network-time-protocol-with-chrony.
Use the broker IP (192.168.1.100) as NTP Server address on other devices. On Raspberry, edit the file /etc/systemd/timesyncd.conf and change the [Time] section like this:
[Time]
NTP=192.168.1.100Then restart the service:
sudo systemctl restart systems-timesyncd.serviceRun the following for creating a MongoDB instance. The database files will be created within the db folder in the directory where you issue the command:
docker run --name mads-mongo --restart unless-stopped -v ${PWD}/db:/data/db -p27017:27017 -d mongoYou can check if it is running with docker ps, stop it with docker stop mads-mongo, restart it with docker start mads-mongo.
Install Mongo Compass in Linux from website using Ubuntu: download it from https://www.mongodb.com/try/download/compass, then install it from the terminal:
sudo dpkg -i Downloads/mongo(complete the name pressing tab)Open Compass and connect local database. If it won't work, check that docker ps returns a line with a running MongoDB instance.
To manage the repositories, we use the gh command, which makes it easier to perform some operations (namely cloning and authenticating). First of all, the user needs to authenticate on GitHub. Type the following:
gh auth loginthen follow the instructions.
Now you can clone the two repositories:
mkdir Level && cd Devel
gh repo clone <you_github_account>/MADS
gh repo clone <you_github_account>/mads_pluginsConfigure and compile it:
cd MADS
ccmake —BBuild # pick the proper CMAKE_INSTALL_PREFIX, typ. /usr/local, then type 'c' to configure and `g` to generate files
cmake --build build -j8When you are done with the first compilation, you can enable the options MADS_SKIP_EXTERNALS and FETCHCONTENT_FULLY_DISCONNECTEDin ccmake, to speed-up further compilations.
Then you can install the results:
sudo cmake --build build -t install
madsThe last command shall give you the list of the available MADS commands.
You can test each agent with the corresponding commands, e.g. mads broker launches the broker, mads feedback opens the feedback agent, etc.
To create a service, so that an agent can run automatically on boot, you have to create a service file. The command mads service helps you in doing that. For example, to create a service for the broker, type:
mads service broker broker -dwhere the first broker is going to become the name of the service, the second one is just the command (with possible options as -d).
Have a look at the result (it is just a printout), then repeat the last command with sudo:
sudo mads service broker broker -dNow the Mads-broker.service is available and you can start, stop, check its status with:
sudo systemctl <start|stop|status> mads-broker.serviceTo have it run all the time and automatically (activate service) or to disable that behavior:
sudo systemctl <enable|disable> mads-broker.serviceAs usual:
cd mads_plugins
ccmake -Bbuild # Set the CMAKE_INSTALL_PREFIX to /usr/local
cmake --build build -j8
cmake --build build -t installNow the plugins are installed on /usr/local/lib. This is also the default search path for the source|filter|sink agents.
Check if everything works by opening two terminals. On one terminal run mads feedback to have a trace of network traffic. On the other terminal type:
mads source clock.plugin -p 500 # run clock.plugin within a source agent and set 500 ms as sampling rateNote that to make this a service, the command would be:
sudo mads service clock source clock.plugin -p 500then start and enable it as explained above.
When you configure the raspberry with the hostname <raspi_name> and enable the Avahi broadcasting of hostname, the raspi can be reached as <raspi_name>.local. To connect to it via ssh and log into the <username> account:
ssh <username>@<raspi_name>.local Only specify the username if it is different from the one on your current host.
You can avoid typing the password at each connection by way of secure certificates. First you have to create the certificate for the broker host:
ssh-keygen -t rsaThen copy the certificate on Raspberry:
scp .ssh/id_rsa.pub <username>@<raspi_name>.local:.ssh/id_rsa.broker.pubThen login into the Raspberry:
ssh <username>@mads-pi.local
cat .ssh/id_rsa.broker.pub >> authorized_keysLog out and log in again: the password won't be needed anymore.
The GUI MadsMetadata app can be also be compiled. It needs QT6 libraries:
sudo apt install qt6-base-devThen you have to enable the CMake option MADS_ENABLE_GUI:
cmake -Bbuild -DMADS_ENABLE_GUI=ON
cmake --build build -j8The compiled app will be under build/GUI/MADSMetadata/MadsMetadata.