ROS2์ ros2_control์์ control_manager๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ, preempt_rt ์ปค๋ (soft realtime)์ ์ฌ์ฉํ ๊ฒ์ ๊ถ์ฅํ๊ณ ์๋ค. ์ปค๋ ๋น๋๋ ๋งค๋ฒ ํ๊ณ ์๊ธด ํ๋ฐ, ์ผ๋จ์ ๋ฐฉ๋ฒ์ ์ ๋ฆฌํด๋๋ฉด ๋์ค์๋ ์ฐพ๊ธฐ ์ฌ์ธ๋ฏ ํ์ฌ ์ ๋ฆฌํจ. ์ปค๋ ๋ฒ์ ์ ๊ทธ๋ฅ rt ํจ์น๊ฐ ์กด์ฌํ๋ ๊ฐ์ฅ ์ต์ ๋ฒ์ ์ ์ฌ์ฉํ๋ฉด ๋ ๋ฏ.
ํ์ํ ํจํค์ง ์ค์น
$ sudo apt install build-essential libncurses-dev flex bison libssl-dev debhelper libelf-dev gawk
๋ค์์ผ๋ก ์ปค๋ ์์ค ๋ฐ RT ํจ์น ํ์ผ์ ๋ฐ์์ด.
$ wget https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.16.1.tar.gz
$ wget https://www.kernel.org/pub/linux/kernel/projects/rt/6.16/patch-6.16-rt3.patch.xz
์์ถ์ ํ๊ณ , ํจ์น ์ ์ฉ
$ tar zxf linux-6.16.1.tar.gz
$ xz -d patch-6.16-rt3.patch.xz
$ cd linux-6.16.1
$ patch -p1 < ../patch-6.16-rt3.patch
๊ธฐ์กด config ํ์ผ ๊ฐ์ ธ์ค๊ธฐ
$ cp /boot/config-`uname -r` .config
์ปค๋ ์ค์ ํ๊ธฐ
$ make menuconfig
์ปค๋ ์ค์
General setup --->
Preemption Model (Scheduler controlled preemption model) --->
(X) Scheduler controlled preemption model
[*] Fully Preemptible Kernel (Real-Time)
Timers subsystem --->
Timer tick handling (Full dynticks system (tickless)) --->
(X) Full dynticks system (tickless)
[*] High Resolution Timer Support
Processor type and features --->
Timer frequency (1000 HZ) --->
(X) 1000 HZ
Power management and ACPI options --->
CPU Frequency scaling --->
Default CPUFreq governor (performance) --->
(X) performance
์ ์ฅํ๊ณ ๋์์,
$ scripts/config --disable SYSTEM_TRUSTED_KEYS
$ scripts/config --set-str CONFIG_SYSTEM_TRUSTED_KEYS ""
$ scripts/config --disable SYSTEM_REVOCATION_KEYS
$ scripts/config --set-str CONFIG_SYSTEM_REVOCATION_KEYS ""
$ scripts/config --disable CONFIG_DEBUG_INFO_BTF
$ scripts/config --disable GDB_SCRIPTS
$ scripts/config --disable DEBUG_INFO
$ scripts/config --disable DEBUG_INFO_SPLIT
$ scripts/config --disable DEBUG_INFO_REDUCED
$ scripts/config --disable DEBUG_INFO_COMPRESSED
$ scripts/config --set-val DEBUG_INFO_NONE y
$ scripts/config --set-val DEBUG_INFO_DWARF5 n
$ scripts/config --disable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
๋น๋ ์์ (-j
๋ค์ ์ซ์๋ ์ปดํ์ผ์ ์ฌ์ฉ๋ ์ฝ์ด์ ์๋ก, ๊ฐ์์ CPU ๊ฐฏ์์ ๋ฐ๋ผ ์กฐ์ ํด์ ์ฌ์ฉ)
$ make -j12 bindeb-pkg
๋๋ต 25~30๋ถ ์ ๋ ๊ฑธ๋ฆฌ๋ ๋ฏ.
์ปค๋ ์ค์น
$ cd ..
$ sudo dpkg -i linux-headers-6.16.1-rt3_6.16.1-5_amd64.deb linux-libc-dev_6.16.1-5_amd64.deb linux-image-6.16.1-rt3_6.16.1-5_amd64.deb
์ค์น๊ฐ ์๋ฃ๋๋ฉด, ์ฌ๋ถํ ํด์ uname -a ๋ก ์ปค๋ ๋ฒ์ ํ์ธ.
$ uname -a
Linux byeongkyu-workpc 6.16.1-rt3 #5 SMP PREEMPT_RT Wed Aug 20 15:05:48 KST 2025 x86_64 x86_64 x86_64 GNU/Linux
์ฃผ์์ฌํญ!! preempt_rt ์ปค๋์ ๊ฒฝ์ฐ nvidia ๊ทธ๋ํฝ ๋๋ผ์ด๋ฒ๊ฐ ๊ธฐ๋ณธ์ ์ผ๋ก ์ง์ํ์ง ์์.
ํด๊ฒฐ๋ฐฉ๋ฒ (์๋ฌ๋ ์ดํ์)
$ export IGNORE_PREEMPT_RT_PRESENCE=1
$ sudo -E dkms install nvidia/580.65.06 -k 6.16.1-rt3
$ sudo dpkg -i linux-headers-6.16.1-rt3_6.16.1-5_amd64.deb linux-libc-dev_6.16.1-5_amd64.deb linux-image-6.16.1-rt3_6.16.1-5_amd64.deb
์ฌ๋ถํ ์ดํ cyclictest๋ก ์ฑ๋ฅ ์ธก์

๋์ถฉ stress๊ฐ ์๋ ๊ฒฝ์ฐ, ์ต๋ latency๊ฐ 154us ์ ๋๋ก ๋์ค๋๋ฏ.
์ฌ์ฉ์ ๊ณ์ ์ realtime ๊ทธ๋ฃน์ ์ถ๊ฐํด์ sudo ๋ช ๋ น์์ด ์คํํ ์ ์๋๋ก ๋ฑ๋ก
$ sudo addgroup realtime
$ sudo usermod -a -G realtime $(whoami)
์ถ๊ฐ ์ค์
$ sudo vi /etc/security/limits.conf
@realtime soft rtprio 99
@realtime soft priority 99
@realtime soft memlock unlimited
@realtime hard rtprio 99
@realtime hard priority 99
@realtime hard memlock unlimited
๋!
2 responses