eldelto / project-ikaros

The journey of building a custom flight controller.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table of Contents

  1. Project Ikaros
    1. Goals
    2. Milestones
    3. Getting Started
      1. Prerequisites
      2. Compilation
      3. Useful Make Targets
    4. Hardware
      1. uC
      2. Accelerometer
      3. Barometer
    5. Software Components
      1. Flight Controller
      2. Tower

Project Ikaros

Goals

The main goal of the project is to get familiar with various hardware concepts while trying to build some sort of self-stabilizing aerial vehicle (e.g. drone, plane, etc.).

Milestones

  • Choose hardware (main uC, accelerometer, barometer, motors, props)
  • Choose software stack (uC, base station, persistence)
  • Display fake sensor data
  • Display live sensor data
  • Controll two motors to properly balance a see-saw
  • Get reliable sensor readings under motor vibrations
  • Persist sensor data and display historical data
  • TBD

Getting Started

A quick guide to get the project up and running.

Prerequisites

The following software packages need to be installed to successfully compile the project:

  • NodeJS >= v18
  • Go >= 1.19
  • Make (should come preinstalled on most UNIX systems)

All previously mentioned packaged are usually available via the inbuilt package manager of the OS. The Raspberry Pi Pico SDK on the other hand needs some special setup that is described in the next section.

  1. Pico SDK & picotool

    The Raspberry Pi Foundation provides a rather extensive set of libraries that provide ready to use functions for most common features of the platform and abstracts the concrete hardware of the used RP2040 board (e.g. Pico vs. Pico W) so it will work with all of them with minimal changes. This project makes use of the Pico SDK and therefore an initial setup is required.

    1. Clone the pico-sdk & picotool repositories into a folder named pico into your work directory that sits on the same level as this project's root directory:

      mkdir pico
      cd pico
      git clone git@github.com:raspberrypi/pico-sdk.git
      git clone git@github.com:raspberrypi/picotool.git
      

      This should result in the following hierarchy:

      <work-dir>
      - project-ikarus
      - pico
        - pico-sdk
        - picotool
      
    2. Install all required dependencies for pico-sdk & picotool. The following commands only apply to macOS using brew:

      brew install gcc-arm-embedded libusb cmake
      
    3. Build the pico-sdk project:

      cd pico-sdk
      git submodule update --init
      
    4. Build the picotool project:

      cd pico-tool
      mkdir build
      cd build
      export PICO_SDK_PATH=../../pico-sdk
      cmake ..
      make
      

      Also make sure to add the picotool executable to your path.

    5. To enable hands off flashing of your Raspberry Pi Pico you need to flash it once manually with any program thas has stdio_usb support enabled. After that all subsequent updates can be applied with make flash-pico.

Compilation

To download all dependencies and initialize the project run make init. This will download Go dependencies, required npm packages and some additional tools. Running make in the project root will compile all subprojects and output their binaries to bin/.

Useful Make Targets

A short reference on the most used make targets:

Target Description
make init Download dependencies and tools
make Compile all subprojects
make run Runs the tower backend
make test Runs tests for all subprojects
make flash-pico Flashes software changes to the Raspberry Pi Pico
make clean Deletes bin/*

Hardware

Some thoughts on different hardware options that could be used.

uC

Possible microcontrollers to execute the control loop on.

  1. Raspberry Pi RP2040

    The RP2040 is an ARM Cortex MO+ based processor with two cores and plenty of other features.

    The documentation is pretty great and it ships with a dedicated C/C++ SDK including a CLI tool to upload new firmware which makes integration with the existing project quite easy. It also has a whopping 16 PWM channels and 8 PIO state machines which are a quite unique feature and for sure interesting to play around. There are different breakout boards available (even one with WIFI which could be interesting). Price wise those breakout boards are also a lot cheaper than for example competing Adafruit projects. Costing only around 5 € (or 8 € with WIFI).

Accelerometer

Possible accelerometer sensors.

  1. Invensense MPU-6050

    The MPU-6050 is a 6-axis gyro/accelerometer combi chip that also features a basic temperature sensor. It can be addressed via SPI or I2C.

    Invensense states that this chip is already obsolete and shouldn't be used for new projects but it still looks like a good choice, is widely available and pretty cheap (breakout boards go for under 10 €). A big plus is the built in digital motion processor (DMP) which basically is a small chip that can calculate motion fusion algorithms on the sensor itself, freeing up resources on the main uC.

Barometer

TBD

Software Components

  • Flight Controller (uC)
  • Tower (GUI app)

Flight Controller

The flight controller is the main data source of the system and submits all available events to the message broker for live monitoring and after the fact data analysis.

The implementation will initially be done in C but later on I want to give Forth a try.

  1. Features

    • Sends sensor data via serial port to the base station
    • Runs a simple PID loop to control a single actuator
    • Sends sensor data via WIFI to the Message Broker directly
    • Controls multiple actuators

Tower

Tower is a native GUI application to display graph data sent from the flight controller and in return send some controlling data back to arm/disarm and tune the PID controllers.

For the actual GUI drawing raylib and raylibgui are used. The graphs are drawn by a custom implementation.

About

The journey of building a custom flight controller.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C 89.4%Language:CMake 7.1%Language:Makefile 3.5%