Secure Autonomous and Cyber-Physical Systems

Instructor: Prof. Sibin Mohan, Oregon State University

CS/ECE 599 | Winter 2022 Term | MW 2:00 - 3:50 PM PT | BAT 150

MP II-A: PX4 Autopilot & uORB Middleware


Announcement Date Feb. 12, 2022
Submission Date Feb. 18, 2022
Submission Time 11:59PM PT
Total Points 8


There are multiple flight firmwares with different architecture/design principles but understanding one of them helps with understanding others. In this MP, we look into PX4 autopilot, an open-source autopilot firmware. The following objectives are designed to help you familiarize with flight controller firmware:


The usage of drones is gaining popularity: from agricultural usage to a more safety critical usage such as firefighting and search and rescue. Therefore, MP2 will focus on a auto-pilot flight controller. There are two popular opensource auto-pilot flight controller: PX4 and Ardupilot. Despite the archetectual difference between the two, they both rely on the usage of a middleware to exchange messages between their components. In this MP, we will be using PX4 and its Software-In-The-Loop (SITL) flight controller simulation with Gazebo physics simulation.
  1. PX4 is a popular opensource autopilot that controls multicopters, fixed-wing aircrafts, rovers and submarines. Archetecture of PX4 from PX4 Documentation As shown in the diagram, PX4 is composed of modules and the modules communicate using the uORB middleware.
  2. uORB middware is a publish-subscribe middleware where a module can publish certain message topics and other modules can subscribe to the topic to get the message.
  3. PX4 provides Software-In-The-Loop(SITL) simulation platform where PX4 controls a simulated vehicle in the host machine. Archetecture of PX4 SITL from PX4 Documentation
  4. By default, SITL provides simplistic physics simulation. However, it supports Gazebo for more complex simulation.
  5. PX4 also provides Hardware-In-The-Loop where the environment is simulated in the host machine but the flight controller runs in the flgiht hardware.

Setting up PX4

We prepared a VM image which has the PX4 setup. The setup has the following system requirement: To setup, download the image from here. The username and password for the VM image is student

Running the PX4-SITL

Running the simulator
  1. Download the VM image here.
  2. In side the VM, change the directory to the PX4: cd /home/student/Desktop/MP2/PX4-Autopilot/
  3. To compile and start the simulation run: make px4_sitl gazebo px4_running
  4. In PX4 command prompt, start the mp2 module mp2 start module_running
  5. In another terminal, change the directory to MP2 base directory: cd /home/student/Desktop/MP2/PX4-Autopilot/
  6. If the run is successful, you should see the following: gazebo_running
  7. In another terminal, change the directory to the MP2 base directory and run the offboard control: python3 offboard_control_running

MP II-A Instructions

  1. Mavlink and Offboard Control
  2. uORB: Understanding the middleware

Submission Instructions