Companion Computer (Falcon) - norlab-ulaval/Norlab_wiki GitHub Wiki

Introduction

Falcon is equipped with a Jetson Orin Nano that handles high-level autonomy and ROS2. This page will describe how the computer was configured and why.

Remote Access

The Jetson can be accessed using one of two ways:

  1. On the Doodle Labs mesh, it can be accessed at 192.168.6.100.
  2. If the radio is not meshed, a Wi-Fi access point named norlab-falcon should be available at the same IP.

In both cases, there is no DHCP. You need to set your IP manually to anything in the 192.168.6.X subnet.

The network setup was made through nm-connection-editor with the following settings:


To ensure that there is no collision or interference between the radio and the access point, we made sure that they could not both run at the same time. Hence, a systemd service called hotspot_fallback.service is constantly checking if the Doodle Labs radio is meshed (by pinging the base station IP) and enabling / disabling the hotspot accordingly. Here is the detailed bash script and service file:

#!/bin/bash
# service file: /etc/systemd/system/hotspot_fallback.service

RADIO_IP="192.168.0.10"       # IP of the Doodle Base Station
HOTSPOT_CONNECTION="Hotspot"  # The name of your hotspot connection profile
WIFI_INTERFACE="wlP1p1s0"

HOTSPOT_STATUS=$(nmcli -t -f ACTIVE,NAME con show --active | grep -w "$HOTSPOT_CONNECTION")
echo $HOTSPOT_STATUS

ping -c 4 "$RADIO_IP" > /dev/null 2>&1

if [ $? -ne 0 ]; then
    echo "Doodle radio not reachable, enabling hotspot..."
    if [ -z "$HOTSPOT_STATUS" ]; then
        # If hotspot is not active, bring it up
        nmcli con up "$HOTSPOT_CONNECTION"
    else
        echo "Hotspot is already active."
    fi
else
    echo "Doodle radio reachable, disabling hotspot..."
    if [ -n "$HOTSPOT_STATUS" ]; then
        # If hotspot is active, bring it down
        nmcli con down "$HOTSPOT_CONNECTION"
    else
        echo "Hotspot is already down."
    fi
fi
[Unit]
Description=Radio Fallback Service to enable WiFi Hotspot
After=network.target

[Service]
ExecStart=/home/robot/ros2_ws/src/norlab_robot/scripts/startup/hotspot_fallback.sh
Restart=always
RestartSec=15s
User=root

[Install]
WantedBy=multi-user.target

ROS2 Integration

The ROS2 configuration was made following the norlab_robot standard to be easily reproduced in case something happens to the Jetson.

The first requirement was to connect the flight controller (PX4) to ROS2 to read sensors and send commands to the drone. To achieve this, three options were considered:

  1. (Best) Zenoh Pico running natively on PX4, direct UART link to Jetson. Unfortunately, Zenoh will only be available in PX4 v1.17...
  2. (Recommended): Use uXRCE-DDS middleware and bridge to DDS (FastRTPS). Unfortunately, FastRTPS is not compatible with Zenoh for our systems...
  3. (Okay): Use MAVROS to create a bridge between ROS2 and MAVLink messages.

Given the circumstances, we chose to use MAVROS as a bridge between the flight controller and the companion computer, and it turned out to be pretty smooth. We followed the Installation instructions and the README for initial configuration. It can be installed with:

sudo apt install ros-humble-mavros ros-humble-mavros-extras

We adapted the provided PX4 launch file as well as the provided configuration file to connect to our flight controller and enable the required plugins. The relevant parameters are shown below:

/**:
  mavros_node:
    ros__parameters:
      fcu_url: /dev/ttyTHS1:921600
      gcs_url: udp://[email protected]:14550;udp://[email protected]:14550

/**:
  mavros:
    ros__parameters:      
      fcu_protocol: "v2.0"
      plugin_allowlist:
        - 'command'
        - 'imu'
        - 'sys_status'
        - 'sys_time'
        - 'setpoint_attitude'
        - 'setpoint_position'
        - 'global_position'
        - 'local_position'
        - 'gps_rtk'

MAVROS is forwarding MAVLink messages to QGroundControl, a.k.a. the Ground Control Station (GCS). The gcs_url setting defines who can connect to this. Hence, with the above configuration, the GCS needs to set its IP address to either 192.168.6.100 or 192.168.0.100. It is possible to add more hosts to the configuration, but we have not found a way yet to make it work for anyone on the network.

Note: It would still be interesting to lookout for a native Zenoh connection in the future PX4 release.

Raspberry Pi Camera HQ

This camera connects directly to the Jetson through a CSI connector, which makes it a very low-latency option with a decent sensor. Initially, the Jetson would not detect the camera. The CSI connector needed to be configured through jetson-io, using this command:

sudo /opt/nvidia/jetson-io/jetson-io.py

Then, select Configure Jetson 24pin CSI Connector > Configure for compatible hardware > Camera IMX477 Dual. Then, save and reboot to configure pins. To test if the camera is detected, run:

ls /dev | grep video

You should see at least one device, most likely video0.

When the camera is detected, you can test if the image is read properly with:

nvgstcapture-1.0

Once this worked, we needed a way to capture images in ROS2, which is fairly easy, but also stream the images to QGroundControl to help hte pilot. To achieve this, a custom ROS2 driver, using OpenCV and gstreamer, was written to achieve really efficient image reading and streaming at the same time. This package could be adapted to another camera in the future.

RTK GNSS

For precise positioning, we need a fixed GNSS receiver (called base), that can send corrections to the drone's receiver in real-time. Our base antenna is an Emlid Reach RS3, which can output corrections in multiple ways. For our scenario, we chose to output corrections with Local NTRIP, similar to how it's done for DJI drones. The full pipeline looks like this:

It can be seen that the NTRIP message navigates up to the Jetson, where it is converted to MAVLink GPS_RTCM_DATA messages. This is done using the ROS2 package ntrip_client that connects to the NTRIP server, converts the corrections to RTCM format and publishes to the /mavros/gps_rtk/send_rtcm topic, which is handled by MAVROS and sent to the flight controller.