In order to control the Panda using libfranka, the controller program on the workstation PC must run with real-time priority under a PREEMPT_RT kernel. This section describes the procedure of patching a kernel to support PREEMPT_RT and creating an installation package.
sudo apt install linux-image-6.1.0-1013-oem linux-headers-6.1.0-1013-oem
uname -a
The output should contain the new kernel version(6.1.0-1015-oem), such as:
Linux user 6.1.0-1015-oem #15-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 09:51:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
sudo apt-get install build-essential bc curl ca-certificates gnupg2 libssl-dev lsb-release libelf-dev bison flex dwarves zstd libncurses-dev debhelper
Then you can look for the Real-time patches available at: https://www.kernel.org/pub/linux/kernel/projects/rt/.
And the kernel that matches the patch at: https://www.kernel.org/pub/linux/kernel/
curl -SLO https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.3.1.tar.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/6.3/older/patch-6.3.1-rt13.patch.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.2.tar.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/6.2/older/patch-6.2-rt3.patch.xz
xz -d *.xz
tar xf linux-*.tar
cd linux-*/
patch -p1 < ../patch-*.patch
make menuconfig
This brings up a terminal interface in which you can configure the preemption model.
Navigate with the arrow keys to General Setup > Preemption Model and select Fully Preemptible Kernel (Real-Time).
After that navigate to Cryptographic API > Certificates for signature checking (at the very bottom of the list) > Provide system-wide ring of trusted keys > Additional X.509 keys for default system keyring.
Remove the “debian/canonical-certs.pem” from the prompt and press Ok. Save this configuration to .config and exit the TUI.
And then the same with the option "X.509 certificates to be preloaded".
Set compression to NONE in: "Enable Loadable module support -> Module compression mode" section
In "kernel hacking -> compile-time checks and compiler options -> Debug information -> disable debug information
make -j$(nproc)
make -j$(nproc) bindeb-pkg
sudo dpkg -i ../linux-headers-*.deb ../linux-image-*.deb
uname -a
It should contain the string PREEMPT RT and the version number you chose. Additionally, /sys/kernel/realtime should exist and contain the the number 1.
When you have successfully installed the real-time kernel and try to boot it you might encounter that Linux is not booting at all. This can happen when you have installed Ubuntu alongside with Windows (e.g. Dual Boot). Usually then the UEFI boot loader will have Secure Boot activated, which will not allow the unsigned real-time kernel to load.
The easiest solution is to disable “Secure Boot” in your boot loader. This highly depends on your system, but usually you can enter the boot loader by pressing F2, F3, F12 or DEL key during boot.
After the PREEMPT_RT kernel is installed and running, add a group named realtime and add the user controlling your robot to this group:
sudo addgroup realtime
sudo usermod -a -G realtime $(whoami)
If you want to check
groups $(whoami)
Afterwards, add the following limits to the realtime group in /etc/security/limits.conf:
@realtime soft rtprio 99
@realtime soft priority 99
@realtime soft memlock 102400
@realtime hard rtprio 99
@realtime hard priority 99
@realtime hard memlock 102400
The limits will be applied after you log out and in again.