The official instruction to set up the TurtleBot3 SBC takes a very long time to complete for many reasons:
- You have to
sudo apt upgrade
and thensudo apt install
a ton of packages. - It is inefficient to build the
turtlebot3
packages on the Raspberry Pi. The instruction might not even work for you even: In our case (Raspberry Pi 3B+),colcon
hangs after about 3 minutes and only passes it after we add the swap file (so we probably did not have sufficient RAM). - It is bad if you have to reflash the OS or have multiple SD cards and redo everything over and over again due to small mistakes here and there.
So we prebuild ROS2 humble
basic packages and turtlebot3
packages so that we can simply download, unpack, run a couple of commands on the Raspberry Pi and you are ready to launch the robot.
Assumptions: Burn Ubuntu 22.04 image (the instruction is for Ubuntu 20.04 but it works for 22.04 as well) which should come with Python 3.10 (i.e. it must match the Python version on our build machine).
To use the prebuilt ROS2 on your Raspberry Pi, SSH to the Pi and
-
First, temporarily give yourself the write permission to
/usr/local
withsudo chmod ugo+w /usr/local
It is unfortunate that paths are hard-coded in the build process so we cannot use a path that is local at the user's home unless everyone agrees to use the same user name.
-
Create a Python virtual environment at
/usr/local/ros2pythonenv
and install the required packagespython3.10 -m venv /usr/local/ros2pythonenv source /usr/local/ros2pythonenv/bin/activate pip3 install packaging pyyaml lark==1.1.1
If you need to run
ros2 topic
, you will neednumpy
andnetifaces
which requiressudo apt install gcc python3-dev
. We don't need that to launch the robot. -
Download our prebuilt archive, extract with
tar xJf
and move the content to/usr/local
.The archive is created using our script
build_tb3_rpi.sh
on a Debian 11 virtual machine on macOS. -
Setup udev rules to access the OpenCR via USB
sudo cp /usr/local/ros2/share/turtlebot3_bringup/script/99-turtlebot3-cdc.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules sudo udevadm trigger
Restart the device after this so that it can take effect.
Note: You still need to setup OpenCR and your PC (if needed, see our other repo for easy ROS2 setup on a Mac).
One should put the commands in step 1 and 2 in your ~/.bashrc
so we can go to step 3 in subsequent launch.
-
Activate python environment and source the ROS2 setup:
source /usr/local/ros2pythonenv/bin/activate source /usr/local/ros2/setup.bash
-
Setup the required environment variables
export ROS_DOMAIN_ID=30 export LDS_MODEL=LDS-01 export TURTLEBOT3_MODEL=waffle_pi export RMW_IMPLEMENTATION=rmw_fastrtps_cpp export LD_LIBRARY_PATH=/usr/local/ros2deps/lib:/usr/local/ros2deps/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH
-
Bring up the TurtleBot with
ros2 launch turtlebot3_bringup robot.launch.py
and if you want to stream the camera, do
ros2 run camera_ros camera_node