Milk-V Duo controls a drone

Controlling a Drone with Milk-V Duo

Overview

This is a disaster relief drone for illuminating specific areas, based on the domestic RISC-V architecture processor. The main control development board chosen for this project is the Milk-V Duo development board from Shenzhen Quanxin Shine Technology Co., Ltd.

The project has the following requirements:

  • Maintain a stable altitude for at least 10 seconds (allowing for some jitter).

  • Be capable of illuminating a certain area on the ground from above (for illustration purposes).

Hardware Selection

Designing your own drone flight control system can be time-consuming. It’s recommended to choose mature flight control solutions available in the market. This approach can reduce costs and ensure reliability. Consider the following factors when selecting a drone:

  • Drone Type and Scale: Different drone types and scales require different flight controllers. For example, small multirotors typically use simpler flight controllers like CC3D or Naze32, while medium to large multirotors require more complex ones like Ardupilot or Pixhawk.

  • Performance Requirements: If you need simple remote control flight, you can use small flight controllers like KK2 or Naze32. For advanced functions like autonomous navigation and obstacle avoidance, you’ll need a more powerful flight controller, such as Ardupilot or Pixhawk.

  • Operating Environment: Consider environmental factors like weather conditions, temperature, and altitude. Some professional flight controllers like Pixhawk have better interference resistance and adaptability for use in harsh conditions.

Considering these factors, it’s recommended to use the Pixhawk as your flight controller. For instance, the classic Pixhawk 2.4.8 version:

Pixhawk 2.4.8 is a fully open-source flight controller hardware that comes with various sensors and interfaces, including accelerometers, gyroscopes, magnetometers, barometers, GPS, serial ports, CAN bus, and more. It supports various configurations and applications, such as multirotors, fixed-wing aircraft, and ground vehicles.

Once you’ve chosen your flight controller hardware, you can select a quadcopter kit based on a Pixhawk flight controller, but we won’t delve into that here.

Note: While Pixhawk is open-source firmware, its primary advantage lies in flight control. To design applications and optimize flight scenarios, pairing it with the Milk-V Duo development board, which is based on the Linux system, makes it easier to achieve certain functionalities. For example, you can connect the Duo to a network via Wi-Fi and interact with the drone more effectively from a ground station PC or other devices connected to the same network to monitor the drone’s status or control it.

To control Pixhawk using Duo, you can connect Duo to Pixhawk’s TELEM 2 via a UART port. You can use a USB to TTL adapter or Duo’s native UART port based on your setup:

Software Support

The most mature communication protocol to use in conjunction with Pixhawk hardware is the MAVLink protocol.

MAVLink (Micro Air Vehicle Link) is a lightweight, heterogeneous communication protocol used for data and command transmission between drones, robots, and ground stations. The MAVLink protocol was initially developed by the Pixhawk team and has become one of the most popular communication protocols in the drone industry.

Here are some key features of the MAVLink protocol:

  1. Lightweight: MAVLink uses a compact binary data format, making it suitable for transmitting data and commands in bandwidth-limited network environments.

  2. Extensibility: MAVLink employs an XML-based message definition language, making it easy to add new message types and parameters to adapt to different applications.

  3. Heterogeneous: MAVLink supports various physical layers and transport protocols, such as serial ports, CAN bus, UDP, TCP, and more, allowing communication between different hardware and software platforms.

  4. Open Source and Free: The MAVLink protocol is completely open source, allowing anyone to use, modify, distribute it freely, and receive support from the open-source community.

The MAVLink protocol defines various message types, including status, control, sensor data, telemetry, commands, and more. It can transmit drone status information, sensor data, control commands, telemetry data, and more. The MAVLink protocol also provides common commands and messages, such as heartbeat, status, position, attitude, battery level, heading, and more, making it easy to control and monitor drones.

MAVLink protocol support exists in various programming languages, including C, Python, Java, Swift, and more. Considering the limited memory of the Duo (64MB), it’s recommended to use the C version of the MAVLink code for development.

Software Development Guidelines

The C version of the MAVLink protocol reference code can be found here: Official reference C/C++ library for the v2 protocol

You’ll need to compile the MAVLink code in the above repository into a library that can run on the RISC-V architecture of the Duo. You can achieve this in two ways:

  1. In the Duo’s duo-buildroot-sdk repository, you can create a new package and

compile the MAVLink library in a Buildroot environment. This method is suitable for users familiar with Buildroot.

  1. You can refer to the Duo’s duo-examples repository, write a Makefile based on the MAVLink code, and generate the MAVLink library. This method is suitable for users who are familiar with Makefiles.

Next, you’ll need to write an application that uses the MAVLink library to communicate with the Pixhawk flight controller to control the drone according to your desired functionality.

To see examples of MAVLink protocol Uart interface calls, you can refer to this code: Simple MAVLink to UART interface example for Unix systems

References