I want to use LiDAR! I created an environment on an industrial raspberry pi.

There is a need to run LiDAR using the industrial Raspberry Pi. LiDAR measures the distance of an object by a laser beam and is used in self-driving cars, cleaning robots, surveying, etc. The laser beam is focused at 360°C, detects obstacles, and maps them.
The word “sensor” is probably easier to imagine. In a broad sense, it is a form of remote sensing. Radar, by the way, is a radio wave.

For a moment, camera footage seems better, but with video, there is too much information to scrutinize; with LiDAR, you can instantly detect “there’s something there” before you even know the details.

More importantly, there is the advantage of being able to measure distance based on the time (or frequency) it takes for a ray of light to hit an object and return. It is difficult to measure distance with video.
The system allows for 3D scanning by mapping a collection of points in space that are made to be measured by LiDAR.

Supplementary camera images could also be used, and their use could be expanded by working in conjunction with each other.
We are now well into an era where LiDAR and AI can be considered to work together.

You can try it on a Raspberry Pi.

I feel it makes sense to handle LiDAR on an industrial Raspberry Pi. If it is a small scale or partial effort, a single Raspberry Pi is all that is needed.

Even for industrial use, the Raspberry Pi is smaller and lighter than a notebook PC. Each interface has the basics and can be used in conjunction with each other to a certain extent.

This is because the basic OS can be Linux, including the general-purpose Ubuntu, and open-source software for mapping the measured data is also available.
Since the introduction of Pi 5/CM5, the processing speed as a machine has become more practical than ever before.

The price of devices that measure as LiDAR varies widely, but inexpensive ones can be tried at low cost together with an industrial Raspberry Pi.

This time, we installed Ubuntu 24.04 as the OS so that it can handle ROS 2 (Jazzy Jalisco), a well-known middleware in robotics.
ROS 2 is available as a binary package for Ubuntu.
ROS 2 = Robot Operating System V2

The Raspberry Pi Compute Module (hereafter referred to as CM) uses rpiboot in advance to write the OS to eMMC.
We will show you how to install the OS using rpiboot, and even how to install ROS2.

Once the LiDAR device is connected to this environment, mapping data will be available immediately.

Environment to install

In this case, we will use Ubuntu 24.04LTS Desktop edition. Even with the same Ubuntu, there is a risk of not being able to install the server or core version successfully due to lack of modules and drivers. Because of a few hurdles, such as changing the device tree, I used the Desktop version to be safe.
Install to the eMMC area, not to the microSD card.

  • PL-R4″ with ComputeModule 4 eMMC/32GB, RAM/8GB
  • USB Type-C Cable
  • Ubuntu 24.04.2LTS
  • ROS 2 Jazzy Jalisco

Since this is an Ubuntu desktop environment and not the usual Raspberry Pi OS, 4GB of RAM is not enough to run with any degree of comfort. 8GB of RAM model is available.
The version of ROS 2 was just released on May 23, 2025 with a new “kilted” version, but this time we chose the stable “jazzy” version. This time, we chose “jazzy”, which is more stable.

How to install on eMMC

To write to eMMC, use rpiboot and connect to the host machine with a USB Type-C cable.

Unlike the CM series on the market, the “PL-R4” can be easily switched between write-enable and write-disable using a DIP switch.
_ The microHDMI cable and power cable are also not connected, and the product alone is connected to a PC with a single USB Type-C cable. _

Switch to write-enable side

The host machine running Raspberry Pi Imager is not limited to Windows, but can also be macOS or Linux.
Each of them has a different method of installing and running rpiboot, so please prepare rpiboot according to the host machine you will use.

rpiboot.exe (for Windows)

If you want to use Windows 11 as the host device, you can start with the installer.

Download URL:
https://github.com/raspberrypi/usbboot/raw/master/win32/rpiboot_setup.exe

If you run the program, the related drivers and other necessary items will be installed together.
_ Note: Do not close the window that appears during installation. _

After rebooting, Windows will detect the hardware and configure the necessary drivers. It’s that easy.

To start rpiboot, go to “Raspberry Pi – Mass Storage Gadget – 64-bit” in the Start menu.
After executing, wait a moment and the eMMC will appear as a USB mass storage device.
It will now appear as a serial port gadget, just like when you connect a USB hard disk.

After booting rpiboot, the OS installation to eMMC can be written to the Raspberry Pi Imager as usual.
If you choose the write destination as a recognized disk area, it is no different than usual.

[Official] How to install and connect rpiboot Linux macOS Windows
: https://www.raspberrypi.com/documentation/computers/compute-module.html#set-up-the-host-device

apt install (for Linux)

It can also be done on another Raspberry Pi as a host device.
Since the apt package is available, all you need is the familiar apt command for Raspberry Pi.

sudo apt install rpiboot

Startup is from commandsudo rpiboot

After starting rpiboot, wait a little here as well as in Windows, and the eMMC will appear as a USB mass storage device.
Simply specify the write destination in the Raspberry Pi Imager.

At this time, specify the /dev directory, such as /dev/sdaor /dev/sdb, but be sure to check it just in case.
lsblkRun the command and look for a device with a storage capacity that matches the capacity of the eMMC. It is very difficult to make a mistake.

Once recognized, the Ubuntu installation is the same as for Windows.

Connect with rpiboot (macOS)

For macOS, the application is not provided, so you will have to build it from source.
If you execute the following steps in the terminal, the device will be recognized as a USB mass storage device and mounted in the same way.

git clone --recurse-submodules --shallow-submodules --depth=1 https://github.com/raspberrypi/usbboot
cd usbboot
brew install libusb
brew install pkg-config
make INSTALL_PREFIX=/usr/local
sudo ./rpiboot -d mass-storage-gadget64

If successful, the terminal displays the following and the prompt returns

# 成功したターミナルの表示
Loading: mass-storage-gadget64/bootfiles.bin
Using mass-storage-gadget64/bootfiles.bin
Waiting for BCM2835/6/7/2711/2712...

Sending bootcode.bin
Successful read 4 bytes 
Waiting for BCM2835/6/7/2711/2712...

Second stage boot server
File read: mcb.bin
File read: memsys00.bin
File read: memsys01.bin
File read: memsys02.bin
File read: memsys03.bin
File read: bootmain
Loading: mass-storage-gadget64/config.txt
File read: config.txt
Loading: mass-storage-gadget64/boot.img
File read: boot.img
Second stage boot server done

From this state, simply select the disk area recognized by the Raspberry Pi Imager as the write destination.

Mass Storage Gadget Mode

Unlike before, this Mass Storage Gadget – 64-bit completes writes in about a quarter of the traditional write speed. It is much easier.

The CM4 can only be connected via a USB 2.0 connection, so it took about 12 minutes, although it is still a slow process. (Ubuntu OS write)
It was less cumbersome since the previous rpiboot took less than an hour.

Install and activate ssh

Once Ubuntu has been successfully booted, ssh should be enabled. Skip this if you don’t need it.
Unlike the Raspberry Pi OS, ssh is not installed initially.

Install with apt from command

sudo apt update
sudo apt install ssh

Even if I start the ssh service, it does not start automatically after power off. This is because it is still disabled.
Enable it.

sudo systemctl enable ssh

Likewise, check for errors in status commands.

sudo systemctl status ssh

I think you have already started, but if not, START

sudo systemctl start ssh

Preliminary Setup – Installation of ROS 2

Installing ROS on “PL-R4” Ubuntu 24.04 can be done with the apt command, but some work is required before and after.

Enable repository universe

sudo add-apt-repository universe

Add ROS 2 GPG key (signature verification key)

sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

Add ROS 2 source repository

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

Now upgrade the new repository as well.

sudo apt update && sudo apt upgrade

We had to install pip first.

sudo apt install python3-pip

Installation of development tools is optional, but useful.

sudo apt update && sudo apt install ros-dev-tools

Installation of ROS 2

Finally, it is time to install ROS 2 itself. It will take about 10 minutes.

sudo apt install ros-jazzy-desktop

There were some packages missing, so we will install additional packages.

sudo apt install ~nros-jazzy-rqt*

Then, complete the initial setup.

ROS 2 initialization

Set up a source list such as python.yaml or base.yaml.

sudo rosdep init 
rosdep update

Reference: https://github.com/ros/rosdistro/blob/master/rosdep/base.yaml

Then, the source command ( source /opt/ros/jazzy/setup.bash) is available in the official documentation. This is an environment setting.
It is hard to hit this every time, so register it at ~/.bashrc.

cd 
echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc
source ~/.bashrc

Working directory (workspace) settings

Next, prepare a working directory.
Since ROS is built using colcon, this is where colcon build is run. It can be run in a virtual environment to resolve package dependencies.
Here we have named the workspace directory “ros2_ws”.

cd 
mkdir -p ros2_ws/src 
cd ros2_ws 
colcon build

Then, register setup.bash to be called in this workspace every time you open a new terminal.

echo "source $HOME/ros_ws/install/setup.bash" >> ~/.bashrc

This eliminates the need to run the source command each time you start the terminal.

It is OK if the workspace has the following directory structure

./ros2_ws
├── build
├── install
├── log
│   ├── build_2025-05-25_16-19-14
│   ├── latest -> latest_build
│   └── latest_build -> build_2025-05-25_16-19-14
└── src

Checking environment variables

If you encounter any errors, it may be related to environment variables, so it is a good idea to check them with the following commands.

printenv | grep -i ROS

It will appear like this.

ROS_VERSION=2
ROS_PYTHON_VERSION=3
GZ_CONFIG_PATH=/opt/ros/jazzy/opt/sdformat_vendor/share/gz
AMENT_PREFIX_PATH=/opt/ros/jazzy
CMAKE_PREFIX_PATH=/opt/ros/jazzy/opt/sdformat_vendor:/opt/ros/jazzy/opt/gz_math_vendor:/opt/ros/jazzy/opt/gz_utils_vendor:/opt/ros/jazzy/opt/gz_tools_vendor:/opt/ros/jazzy/opt/gz_cmake_vendor
ROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET
PYTHONPATH=/opt/ros/jazzy/lib/python3.12/site-packages
LD_LIBRARY_PATH=/opt/ros/jazzy/opt/sdformat_vendor/lib:/opt/ros/jazzy/opt/rviz_ogre_vendor/lib:/opt/ros/jazzy/lib/aarch64-linux-gnu:/opt/ros/jazzy/opt/gz_math_vendor/lib:/opt/ros/jazzy/opt/gz_utils_vendor/lib:/opt/ros/jazzy/opt/gz_tools_vendor/lib:/opt/ros/jazzy/opt/gz_cmake_vendor/lib:/opt/ros/jazzy/lib
PATH=/opt/ros/jazzy/opt/gz_tools_vendor/bin:/opt/ros/jazzy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ROS_DISTRO=jazzy
OLDPWD=/home/raspida/ros2_ws

Install it.

This time it was how to install ROS 2 middleware that can handle LiDAR and its environment, Ubuntu 24.04, into the CM4 environment (PL-R4).
It was a bit labor intensive and complicated because of the use of rpiboot for OS installation and the need for pre-work and post-configuration for ROS 2 installation.
If you encounter an error during installation, we assume that the error is due to something missing.

We did not encounter any errors in this procedure.
Due to the addition of the repository, I get an error in the Ubuntu 24.04 Schedule & Update settings if the Subscribed to is not All updates or recommends updates.
The default (standard) is All updates, so it does not matter if you have not changed anything.

An environment for handling LiDAR devices can also be built with the Compute Module of the industrial Raspberry Pi.
Depending on the LiDAR device, there will still be some configuration that needs to be done after this.

This time it was how to install Ubuntu on the eMMC of “PL-R4” and build the ROS 2 environment.

Reference: https://docs.ros.org/en/rolling/index.html


Article contributed by Raspida

Raspberry Pi information site that even non-engineers can enjoy using raspida.com a Raspberry Pi information site that even non-engineers can enjoy and handle. He also contributes technical blog articles to the PiLink site on the Raspberry Pi for industrial use.