Raspberry Setup - ahiver/docs GitHub Wiki

Hardware

  • Arducam OV7251
  • Raspberry Compute Module 4
  • Raspberry CM Carrier Nano A
  • 32 Gb SD card

Setup

Use Raspberry Pi Imager to prepare bootable sd card with Ubuntu

Ubuntu 20.04.5 LTS (64-bit)

Switch off unattended updates

sudo systemctl stop unattended-upgrades
sudo systemctl disable unattended-upgrades
sudo apt-get purge unattended-upgrades

Update/Upgrade packages

sudo apt update
sudo apt upgrade
sudo apt autoremove
sudo reboot

Install project dependencies and some utils using scripts

cd ~
mkdir bees
cd bees
git clone https://github.com/ahiver/scripts.git
cd scripts
yes | ./robot_install_ubuntu.bash

It includes:

  • ROS noetic core
  • Mavros
  • Open VINS
  • ov7251 camera support
  • mavproxy
  • utils: ifconfig, iwconfig, ip, inxi, uvcdynctrl
  • services to start evertything on load

For CM4

  • copy precompiled vins_ws, ceres_ws, mavlink_router
  • install all necessary dependencies manually

cd scripts

add source <path to robot.env.bash> to ~/.bashrc

Configure eth0 and wifi access point

Enable eth0

sudo apt install net-tools

sudo ifconfig eth0 up

Ask for ip from server using dhcp

dhclient eth0 -v

Update netplan configuration (wlan0 - builtin, wlan0 - external wifi module)

sudo apt-get install network-manager
cd /etc/netplan`
sudo nano 50-cloud-init.yaml`
network:
    version: 2
    wifis:
        renderer: NetworkManager
        wlan0:
            access-points:
                3irko:
                    mode: ap
            dhcp4: true
            addresses: [192.168.11.1/24]
            optional: true
    ethernets:
        renderer: networkd
        eth0:
            dhcp4: true


Generate config for NetworkManager

sudo netplan generate

Apply netplan configuration

sudo netplan apply

Enable link to FCU through GPIO

FC.R3 <-> PIN 08: GPIO14(TXD0, UART) PIN 24 GPIO8 yellow

FC.T3 <-> PIN 10: GPIO15 (RXD0, UART) PIN 21 GPIO9 green

G <-> PIN 14 black

Ardupilot:

SERIAL3_PROTOCOL = 2 (MavLink 2) SERIAL3_BAUD = 921

sudo nano /boot/firmware/config.txt

enable gpio uart

enable_uart=1

disable bluetooth, it conflicts with uart on raspberry

dtoverlay=disable-bt

Reboot Raspberry Pi device.

sudo reboot Ensure that Bluetooth devices are not available.

hcitool dev

Use uart4

dtoverlay=uart4

Screenshot 2023-08-06 10:55:05

Set IMU stream reate to 300 HZ

rosrun mavros mavsys rate --stream-id 1 300

Enable camera device overlay

sudo nano /boot/firmware/config.txt

dtoverlay=ov7251

in case of compute module and Waveshare nano board

  • setup video core i2c bus
sudo apt-get install p7zip-full -y
wget https://files.waveshare.com/upload/4/41/CM4_dt_blob.7z
7z x CM4_dt_blob.7z -O./CM4_dt_blob
sudo chmod 777 -R CM4_dt_blob
cd CM4_dt_blob/
sudo dtc -I dts -O dtb -o /boot/firmware/dt-blob.bin dt-blob-disp1-double_cam.dts
  • replace ov7251 overlay
sudo wget https://gist.githubusercontent.com/okalachev/b75e22a82e2bcca82b451967be9f8c06/raw/d76ed8fb6943cc44fc93d92e2e819e73456bd351/ov7251cam0-overlay.dts
sudo dtc -I dts -O dtb -o /boot/firmware/overlays/ov7251.dtbo ov7251cam0-overlay.dts
  • edit /boot/firmware/usercfg.txt
dtoverlay=ov7251,cam0

setup external compute module wifi antenna (if used)

dtparam=ant2

Update hosts

sudo nano /etc/hosts

127.0.0.1 firefly