TixiaoShan / LIO-SAM

LIO-SAM: Tightly-coupled Lidar Inertial Odometry via Smoothing and Mapping
BSD 3-Clause "New" or "Revised" License
3.49k stars 1.27k forks source link

Latency problem with ROS2 algorithm #437

Open lukasj-imar opened 1 year ago

lukasj-imar commented 1 year ago

Hi everybody,

while testing ROS2-LIO-SAM on different machines, I encountered a problem related to the native high latency of the OS (Ubuntu 22.04 TLS, kernel: 5.19.0-45-generic).

As a result of the latency problem, LIO-SAM worked on one machine only with decreased replay rate of my own rosbags. On an other system (with much more powerfull hardware), I had no chance to run LIO-SAM at any speed. It seems that point clouds won't be processed fast enough, so no LiDAR-odometry solution can be calculated with the consequence that imuPreintegration drifts away after a few seconds.

I fixed this problem by reducing the latency of the whole system. Therefor, I changed der generic kernel to a lowlatency-kernel and disabled switching-ability to high latency c-states by setting a kernel boot parameter to ``ìdle=halt```.

Now, ROS2-LIO-SAM seems to work pretty well and stable on all of my machines. If you have issues with respect to performance, check out this fix and give me a feedback.

chivas1000 commented 1 year ago

Hi I might be ran into same issue as you. My LIOSAM on ROS1 runs fine, but on the same setup, the ROS2 branch runs like: https://github.com/TixiaoShan/LIO-SAM/issues/346 Also, I've debugged the code and I've seen although ros2 topic delay of the pointcloud topic are at around 10hz. but in the Lidarpointcloud handler(the pointcloud callback function), the process of pointcloud are real quick(0.xms), but pointcloud come in slow, it runs(the frequency that the handler invoked) around 7-9hz, sometimes 6hz.

Would you mind tell me how to switch generic kernel to a lowlatency-kernel and disabled switching-ability to high latency c-states by setting a kernel boot parameter to ``ìdle=halt```? Or any I could refer?

Much appreciated!

lukasj-imar commented 11 months ago

Hi @chivas1000,

sorry for my late response. Here are the steps you need to follow:

  1. In /etc/default/grub edit the following parmeter to: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi=ht idle=halt intel_idle.max_cstate=0"
  2. To start the ROS-System with RT-PRIO, edit in /etc/security/limits.conf the last entries, according to your user name
    #<domain>      <type>  <item>         <value>
    #

* soft core 0

root hard core 100000

* hard rss 10000

lukas - rtprio 98 lukas - nice -19 lukas - memlock -1

  1. sudo update-grub