Skip to content

Commit

Permalink
dev: Add ROS 2 deployment to Pi tutorial
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <25047695+Ryanf55@users.noreply.github.com>
  • Loading branch information
Ryanf55 committed Jan 13, 2025
1 parent 695b8d7 commit 356ed15
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev/source/docs/ros.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ ROS 2
ROS 2 over Ethernet <ros2-over-ethernet>
ROS 2 waypoint goal interface <ros2-waypoint-goal-interface>
Cartographer SLAM with ROS 2 in SITL <ros2-cartographer-slam>
ROS 2 on Raspberry Pi <ros2-pi>


Conclusion
Expand Down
81 changes: 81 additions & 0 deletions dev/source/docs/ros2_pi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
.. _ros2-pi:

=====================
ROS 2 on Raspberry Pi
=====================

Purpose
=============

Learn how to install the ROS onto a companion computer and run a sample ROS 2 application that communicated with ArduPilot over Micro XRCE DDS.
For this demonstation, a Raspberry Pi Zero 2W will be used, however other Linux computers are also capable.

Required Hardware
=================

* `Raspberry Pi Zero 2W <https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/>`__
* A Linux computer to flash an SD card and configure the Pi

Initial Configuration
=====================

For the first section, we will follow `Ubuntu's tutorial <https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#1-overview>`__ , with specifics noted below.

Use ``rpi-imager``.

When selecting the operating system, we will install Ubuntu 22 Server.
Find it in "Other general-purpose OS -> Ubuntu -> Ubuntu Server 22.04.5 LTS (64-bit) which is supported
by `ROS 2 humble <https://www.ros.org/reps/rep-2000.html#humble-hawksbill-may-2022-may-2027>`__.
When prompted to do "OS Customisation", select that.
* In "General", Configure wireless LAN
* In "Services", enable SSH
* Save and flash the image onto the device

Install the SD card, let it boot for 2 minutes, then either through a HDMI display and keyboard, or by plugging the Pi's SD card back into your computer, edit the file:
``/etc/avahi/avahi-daemon.conf`` and change the line that has ``publish-workstation`` to ``publish-workstation=yes``.

Now, put the SD card back into the Pi, boot it up with the USB, and you can now connect.


.. code-block:: bash
# Find the address of the PI
avahi-resolve -n ubuntu.local
# SSH into it (the first time)
ssh ubuntu@ubuntu.local
Once you SSH, create your username and password, and test you can still login, it's time to set up ROS 2.
We'll install all the packages before it's wired into the drone.

ROS 2 Install
=============

When using Ubuntu 22.04, it's easiest to install ROS 2 through binaries.
https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debs.html

First off, if you can't use ``apt update`` due to "Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 912 (unattended-upgr)",
try removing unattended upgrades

.. code-block:: bash
sudo systemctl stop unattended-upgrades
sudo apt-get purge unattended-upgrades
When installing ROS 2, install ``ros-humble-ros-base`` and ``ros-dev-tools``.

Serial Connection
=================

Now, wire a serial connection to your flight controller. Ensure your power supply is capable of powering the Pi Zero 2W.
The simplest solution is to wire an open telemetry port.

.. warning::

Do not abuse the power supply for the flight controller.
For robust applications, it is recommended to power non-flight-critical devices,
such as a Raspberry Pi, with a separate 5V power supply.
Although many flight controller power supplies may support the power draw of
a Raspberry Pi Zero 2W, a problem on the PI can bring down the entire vehicle.

.. figure:: ../images/PiZero2WTelem.png
:target: ../_images/PiZero2WTelem.png
Binary file added dev/source/images/PiZero2WTelem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 356ed15

Please sign in to comment.