This package intends to provide examples on how to use OROCOS along with ROS2
This README contains an installation procedure, for Ubuntu 20.04 only, to set up OROCOS 2.9, ROS 2 Foxy, and our example package
This step is optional for this repository, but required if you need hard real-time capabilities.
WARNING: You need to have at least 32GB free on your disk.
mkdir ~/rt_kernel
cd ~/rt_kernel
Dependencies:
sudo apt install build-essential bc curl ca-certificates fakeroot gnupg2 libssl-dev lsb-release libelf-dev bison flex
Choose the closest kernel version from https://www.kernel.org/pub/linux/kernel/projects/rt/ by running: uname -r
. For example if your kernel version is "5.8.0-48-generic", you should choose "5.6.19-rt12".
curl -SLO https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.6.19.tar.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.6.19.tar.sign
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/5.6/older/patch-5.6.19-rt12.patch.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/5.6/older/patch-5.6.19-rt12.patch.sign
xz -d linux-5.6.19.tar.xz
xz -d patch-5.6.19-rt12.patch.xz
Find RSA key IDs:
gpg2 --verify linux-5.6.19.tar.sign
gpg2 --verify patch-5.6.19-rt12.patch.sign
Download public keys (Replace <...> by the corresponding key IDs):
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys <linux-5.6.19.tar.sign RSA key ID>
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys <patch-5.6.19-rt12.patch.sign>
Verify files:
gpg2 --verify linux-5.6.19.tar.sign #Should display something like: Good signature from "Greg Kroah-Hartman <gregkh@linuxfoundation.org>"
gpg2 --verify patch-5.6.19-rt12.patch.sign #Should display something like: Good signature from "Sebastian Andrzej Siewior"
tar xf linux-5.6.19.tar
cd linux-5.6.19
patch -p1 < ../patch-5.6.19-rt12.patch
make oldconfig
When asked for the Preemption Model, choose the Fully Preemptible Kernel. You can pick the other options at their default values (Just press enter).
Replace <parallel-workers>
by the number of threads available on your computer.
fakeroot sudo make -j<parallel-workers> deb-pkg
If you get the following errors while running:
- With parallel-workers:
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
- Without parallel-workers:
make[4]: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'. Stop.
Edit the config file (gedit ~/rt_kernel/linux-5.6.19/.config
) and comment (with #
) the following lines:
- CONFIG_MODULE_SIG_KEY
- CONFIG_SYSTEM_TRUSTED_KEYS
sudo dpkg -i ../linux-headers-5.6.19-rt12_*.deb ../linux-image-5.6.19-rt12_*.deb
Restart your system and look for the newly installed kernel in the Grub boot menu. You might need to go into the Ubuntu advanced boot option to find the RT kernel ("Ubuntu, with Linux 5.6.19-rt12").
After a successful boot, you can check that you're using the new RT kernel with: uname -a
. It should contain "PREEMPT_RT".
If you get the following error: error: boot/vmlinuz-5.6.19-rt12 has invalid signature
.
You can either disable Secure Boot in your UEFI menu or, if you want to keep Secure Boot enabled, sign your kernel with this procedure: https://askubuntu.com/a/1182830. If you're trying to sign the kernel, you might want to only use 2 integer for countryName = <YOURcountrycode>
in Step 1 and replace [KERNEL-VERSION]-surface-linux-surface
in the tutorial by 5.6.19-rt12
.
sudo addgroup realtime
sudo usermod -a -G realtime $(whoami)
Add the following to "/etc/security/limits.conf" (sudo gedit /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.
locale # check for UTF-8
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale # verify settings
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo apt update
sudo apt install ros-foxy-desktop
sudo apt install python3-colcon-common-extensions
sudo apt install -y python3-argcomplete
Source automatically ROS2:
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
Source automatically Colcon_cd:
echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
echo "export _colcon_cd_root=~/ros2_install" >> ~/.bashrc
Use a ROS_DOMAIN_ID. Replace <your_domain_id> by an integer between 0-232.
echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc
sudo apt-get install liblua5.1-0-dev
sudo apt install -y git ros-foxy-ament-cmake-clang-format omniorb omniidl omniorb-idl omniorb-nameserver libomniorb4-dev
mkdir -p ~/orocos_ws/src # any directory you prefer, but change below acoordingly
cd ~/orocos_ws/src
git clone https://github.com/orocos/rtt_ros2_integration.git
git clone https://github.com/orocos/rtt_ros2_common_interfaces.git
git clone --recurse-submodules --branch=ros2 https://github.com/orocos-toolchain/orocos_toolchain.git
Start building the orocos_toolchain package, you can ignore the "stderr output":
cd ~/orocos_ws
colcon build \
--packages-select orocos_toolchain \
--parallel-workers <parallel-workers> \
--install-base ~/orocos/${ROS_DISTRO} \
--merge-install \
--cmake-args \
\ -DBUILD_TESTING=OFF \
\ -DCMAKE_BUILD_TYPE=Release \
\ -DENABLE_CORBA=ON \
\ -DCORBA_IMPLEMENTATION=OMNIORB \
\ -DOROCOS_INSTALL_INTO_PREFIX_ROOT=ON
Build the Orocos-toolchain with ROS2 integration, you might want to run the following twice. You should only get an "stderr output" for the orocos_toolchain package:
colcon build \
--parallel-workers <parallel-workers> \
--install-base ~/orocos/${ROS_DISTRO} \
--merge-install \
--cmake-args \
\ -DBUILD_TESTING=OFF \
\ -DCMAKE_BUILD_TYPE=Release \
\ -DENABLE_CORBA=ON \
\ -DCORBA_IMPLEMENTATION=OMNIORB \
\ -DOROCOS_INSTALL_INTO_PREFIX_ROOT=ON
If you also want to install the tests packages:
sudo apt install ros-foxy-test-msgs
And run the previous colcon build command with -DBUILD_TESTING=ON
option.
source /opt/ros/foxy/setup.bash
source ~/orocos/foxy/local_setup.bash
deployer
import("rtt_ros2")
The import command should return true
.
Source automatically Orocos:
echo "source ~/orocos/foxy/local_setup.bash" >> ~/.bashrc
OrocoRos2 shows a basic use of the ROS2 publisher/suscriber and services capabilities in Orocos.
mkdir -p ~/dev_ws/src
cd ~/dev_ws/src
git clone https://github.com/AntoineHX/orocoros2_msgs.git
git clone https://github.com/AntoineHX/rtt_ros2_orocoros2_msgs
git clone https://github.com/AntoineHX/orocoros2.git
cd ~/dev_ws
colcon build
- On Terminal #1, Start pong components:
source /opt/ros/foxy/setup.bash
source ~/orocos/foxy/local_setup.bash
source ~/dev_ws/install/local_setup.bash
cd ~/dev_ws/src/orocoros2/launch
deployer PingPong.ops
You should get a usable Orocos deployer after the pong components are started. Terminal #1 will also display the messages printed by the pong components.
NOTE: To close the deployer, use <Ctrl + D>
- On Terminal #2, Start match (replace
<Player>
by 1 or 2, to choose the first player to hit the ball):
source /opt/ros/foxy/setup.bash
source ~/orocos/foxy/local_setup.bash
source ~/dev_ws/install/local_setup.bash
ros2 service call /PingPong/start_match orocoros2_msgs/srv/PlayerService "{player: <Player>}"
- On Terminal #2, you can also tune hit chances of each player (replace
<hit_chance>
by a double between [0.0,1.0]):
ros2 param set /PingPong/Main_node Player1_hit_chance <hit_chance>
ros2 param set /PingPong/Main_node Player1_hit_chance <hit_chance>
- On Terminal #2, you can get the current scores published by the referee:
ros2 topic echo /PingPong/score_port
NOTE: To stop the previous command, use <Ctrl + C>
- Another simple example: https://gitlab.com/AntoineHX/orocos_examples
- OROCOS+ROS courses: https://atlas-itn.eu/training/network-training-activities/nta-3-best-integration-practices-and-robotic-middleware/
Contributions from Antoine Harlé (harle@isir.upmc.fr), Jimmy Da Silva (jimmy.dasilva@isir.upmc.fr), Kenan Niu (kenan.niu@kuleuven.be), Sergio Portoles Diez (sergio.portoles.diez@intermodalics.eu).
The current installation procedure and code is adapted from:
- libfranka real-time setup: https://frankaemika.github.io/docs/installation_linux.html#setting-up-the-real-time-kernel
- ROS2 documentation: https://docs.ros.org/en/foxy/Installation.html
- OROCOS+ROS examples: https://gitlab.com/dustingooding/orocos_examples/-/tree/feature/ros2