Connect Create® 3 to Raspberry Pi® 4 and set up ROS 2 Galactic
Before you start
Attention
These directions are written for someone with experience with embedded Linux and basic embedded computers.
It is highly recommended to read through the following documents before beginning:
- How to install Ubuntu Server on your Raspberry Pi1 - official Canonical documentation
- Installing ROS 2 on Ubuntu Linux1 - official Open Robotics documentation
Step-by-step
- Download Ubuntu® Server 20.04 64-bit1 and write onto a microSD card.
- In the system-boot partition, edit usercfg.txt and add
dtoverlay=dwc2,dr_mode=peripheral
. For convenience, here's a copy of this file. - In the system-boot partition, edit cmdline.txt to add
modules-load=dwc2,g_ether
afterrootwait
. For convenience, here's a copy of this file. -
In the system-boot partition, edit network-config to optionally add information about your Wi-Fi connection, and also add the following under
ethernets
usb0: dhcp4: false optional: true addresses: [192.168.186.3/24]
For convenience, here's a copy of this file. Be sure to remove the
.txt
extension. Note that the robot uses the default IP address of 192.168.186.2 on its usb0 interface. Please note also that after initial boot, editingnetwork-config
in the boot partition will not do anything; instead, the file to edit can be found at/etc/netplan/50-cloud-init.yaml
. -
If you would like your Raspberry Pi® 43 to communicate with the Create® 3 over its USB-C®2 port (and not just to power it), be sure that the USB/BLE toggle on the robot's adapter board is set to the USB position.
-
Insert the microSD card into the Raspberry Pi® 43, and then use a USB-C®2 to USB-C®2 cable to connect the Raspberry Pi® 43 to the Create® 3. A photo of this connection can be found here. The first boot may take a few minutes. (It may help to have a monitor and keyboard set up in case of any trouble on the first boot.)
-
Log in with the default username and password (ubuntu/ubuntu), change your password, and then change your locale to be one that uses UTF-8. For example, in the US, type
sudo apt update sudo apt install locales sudo locale-gen en_US en_US.UTF-8 sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 export LANG=en_US.UTF-8
-
Recommended: follow the procedure to Setup NTP on this compute board so the Create 3 can sync its clock.
-
Optional: Run
timedatectl
and see ifSystem clock synchronized:
saysyes
. If not, you may want setup NTP on your raspi so the clock stays accurate. To do so, specify some NTP servers for time syncronization. Edit/etc/systemd/timesyncd.conf
(sudo nano /etc/systemd/timesyncd.conf
) to have the below contents, then runsystemctl restart systemd-timesyncd.service
to load the new NTP server configuration.[Time] NTP=ntp.ubuntu.com FallbackNTP=0.us.pool.ntp.org 1.us.pool.ntp.org
-
Then, execute the following blocks of commands to install ROS 24:
sudo apt update && sudo apt install -y curl gnupg2 lsb-release build-essential git cmake
then
sudo curl -ksSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null sudo apt update && sudo apt install -y ros-galactic-ros-base python3-colcon-common-extensions python3-rosdep ros-galactic-rmw-fastrtps-cpp ros-galactic-rmw-cyclonedds-cpp ros-galactic-irobot-create-msgs
finally
echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc echo "export _colcon_cd_root=/opt/ros/galactic/" >> ~/.bashrc echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> ~/.bashrc echo "source /opt/ros/galactic/setup.bash" >> ~/.bashrc
-
At this point, we recommend setting your default RMW. The RMW you set here has to match the RMW on your robot, which can be found from its Application Configuration page. More detail on RMW can be found here. Right now, the Create® 3 robot supports
rmw_cyclonedds_cpp
andrmw_fastrtps_cpp
. The default for Galactic isrmw_cyclonedds_cpp
. Depending on your robot's RMW implementation, type one of the following:echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc
or
echo "export RMW_IMPLEMENTATION=rmw_fastrtps_cpp" >> ~/.bashrc
-
Log out and log back in. Once you do, test things out with a
ros2 topic list
. A full Create® 3 API description can be found here.Attention
If you are using CycloneDDS (Galactic default), your Raspberry Pi® may be running with multiple network interfaces (usb0 to talk to robot and wlan0 to talk to laptop). You will need to export a path on the Raspberry Pi® to an xml config file that registers those interfaces in the CYCLONEDDS_URI. See CycloneDDS Multiple Network Interfaces.