Close
0%
0%

RPLIDAR C1 with Raspberry PI 4 and ROS2

Create an independent ROS2 Node with the new laser scanner RPLIDAR C1 to be used in a WiFi network

Similar projects worth following
I needed a robot with a Laser Scanner and a Single Board Computer as platform for autonomous Obstacle Avoidance and SLAM. The scan has also to be viewed by RVIZ2 running on another computer.

OVERVIEW

Using the following architecture I want to test if it is possible to have a laser scanner (RPLIDAR C1) working on a hardware (Raspberry PI 4 - 1GB) that can be placed on a moving robot to:

  • get around autonomously
  • avoid obstacles
  • map the environment

TARGET ARCHITECTURE

The first goal is to get the following architecture working.

Host:

  • HW: 
    • Raspberry PI 4 - 1 Gigabyte
    • RPLIDAR C1
  • OS: Ubuntu 22.04 (Jammy) 64 bits
  • Platform: ROS2 (Robot Operating System) - Humble version - 64 bits
  • App: ROS2 Node publishing the RPLIDAR C1 laser scan on topic /scan

Client:

  • HW: Intel I9 12th gen - 64 bits
  • OS: Ubuntu 22.04 (Jammy) 64 bits
  • Platform: ROS2 (Robot Operating System) - Humble Version - 64 bits
  • App: ROS2 Node publishing the RPLIDAR C1 laser scan on topic /scan

Constraints: 

  • ROS2 because it is the evolution of ROS, which is a bit outdated 
  • 64 bits because ROS2 needs it
  • ROS2 Humble distribution because my Ubuntu Client is 22.04 Jammy. ROS2 Humble distribution:
    • is the most recent based on Ubuntu 22.04 Jammy
    • has Long Term Support: up to November '27
  • RPLIDAR C1 because is the cheapest Laser Scan I've found

INSTALL UBUNTU 22.04 (Jammy) 64 BITS OS

Using the Raspberry PI imager, I installed this OS image in a 64GByte SD card.

In half an hour I got the OS working and WiFi connected

INSTALL ROS2 HUMBLE

I followed these instructions ROS2 Humble - Ubuntu Install Debs to install ROS2 both in Host and Client

TESTING ROS2 HUMBLE

The testing suggested in the instructions ROS2 Humble - Ubuntu Install Debs (talker / listener) worked fine if executed on the same machine (e.g. talker on Host and Listener on Host), but failed when "talker" was in the Host and "listener" on the Client or viceversa.

NETWORKING

ENABLE MULTICAST

To let ROS2 Nodes (running on different machines on the same network) to communicate you need  to Test Multicast

Then:

  • Enable Multicast on the network interfaces but also on the WiFi Router.  In my fiber optic modem and WiFi Router SAGEMCOM F5684 I have this setting:

Note: at the moment I'm not able to have Multicast working between an Ethernet interface and a WiFi interface but it works fine among WiFi interfaces. I'll investigate it in the future.

ENVIRONMENT SETTINGS

1)

ROS_LOCALHOST_ONLY=0

 must be 0 or not present.

2) ROS_DOMAIN_ID must be the same number (e.g. 12) on all the machines or not be present (it defaults to 0)

NO JOY?

If after the previous settings things doesn't work all the same, because of Multicast, you can use a sub optimal solution enabling eProsima Fast DDS using  

RMW_IMPLEMENTATION=rmw_fastrtps_cpp

 as documented in eProsima Fast DDS

Please note that you don't need to install it as in the document, because it is already installed by default with ROS2 Humble.

INSTALL RPLIDAR C1 PACKAGE FOR ROS2

This is the repository for the RPLIDAR C1 package on ROS2. SLAMTEC ROS2

Just to be sure everything was OK, I installed and tested it on the Client without any problem.

On the contrary, as you can read in the log, I wasn't able to build the package on the Host because of lack of memory (1 GB only on my Raspberry PI 4). In this case you need RPLIDAR_C1_for_Raspberry_PI_4

HARDWARE

Connect the RPLIDAR C1 cable to the Raspberry PI 4

Just for information, we are using pins GPIO14 (green cable) and GPIO15 (yellow cable) which Ubuntu for Raspberry calls Serial0

SERIAL PORT RASPBERRY PI 4 - UBUNTU 22.04 SETTINGS

In /boot/firmware/config.txt check that the uart is enabled

# Enable the serial pins
enable_uart=1

 In /boot/firmware/cmdline.txt, remove console=serial0,115200, as we are going to use Serial0. it should appear like the following:

dwc_otg.lpm_enable=0 console=tty1 root=LABEL=writable rootfstype=ext4 rootwait fixrtc quiet splash cfg80211.ieee80211_regdom=I

As a final step, set your robot user to belong to the dialout group 

...
Read more »

  • Install RPLIDAR C1 Software

    Guido08/27/2024 at 17:21 0 comments

    The Github repository is Slamtec RPLIDAR ros2.

    I followed "How to Install" both in the Client "Intel I9 with Ubuntu 22.04" and in the Host "Raspberry PI 4 - 1 Gigabyte" with Ubuntu 22.04".

    On the Client everything went well and after 20 minutes I was able to view the real time laser scan on rviz2

    On the contrary I was't so lucky on the Host, where I got stuck at the step:

    cd ~/ros2_ws/
    source /opt/ros/humble/setup.bash
    colcon build --symlink-install

     The "colcon build --simlink-install" lasted for more than 4 hours (against about 30 seconds on the Client) and then crashed, for an evident lack of memory.

    After some research and thanks to ChatGPT suggestions, I realized I had the following options:

    1. cross compile in my Ubuntu 22.04 amd64 (which I called Client) to target Ubuntu 22.04 arm64v8
    2. buy a Raspberry PI 4 - 4 GB
    3. build the RPLIDAR package in a docker container based on Ubuntu 22.04 Jammy arm64v8.

    I considered 2. as a defeat while 1.isn't supported in ros2 - humble

    Read the third option in Details.

  • Install and test ROS2 on Host and Client

    Guido08/27/2024 at 15:09 0 comments

    Installing ROS2 Humble (see the Details) on both Host (Raspberry PI 4 with Ubuntu 22.04 OS arm64) and Client (Intel I9 with Ubuntu 22.04 OS amd64) was easy, but the problems arose during testing.

    Test using "talker" and "listener" as described here  ROS2 Humble - Ubuntu Install Debs went fine on the same machine but failed on different machines (e.g. talker on Client and listener on Host or viceversa). 

    After some struggling (1 full day of "change" and "test") I realized that Multicast was enabled on both the machines on all their interfaces but it didn't work. 

    The confirmation that Multicast didn't work on my network came from: 

    ros2 multicast receive

     on a machine and

    ros2 multicast send

     on the other one as "receive". In fact the receiver received ... nothing!

    Reading a lot on the Web I realized that many WiFi routers need a setting, whose name not always is Multicast (it would be too easy) but uPnP. 

    Fortunately my router had this setting and, after enabling it, all the tests worked fine.

  • Install Ubuntu 22.04 (Jammy) on a Raspberry PI 4 - 1 GB

    Guido08/27/2024 at 13:56 0 comments

    I know that 1 Gigabyte is not that much, especially if the ROS2 Nodes increase in number, but I want to try all the same.

    Anyway, preparing a 64 MB SD card using the app Raspberry Imager was pretty easy and in half an hour I got my headless OS (without desktop) perfectly working and WiFi connected.

View all 3 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates