Software Starter Project 2026-27
Drone Software Starter Project
Section titled “Drone Software Starter Project”This year, we are looking to develop capabilities for the drone to operate autonomously during the URC missions. The aim of the drone software starter project is to familiarize you with the key frameworks and software tools we will use to operate the drone and implement capability for autonomous flight. Once you have installed all necessary software, proceed through the sections of this page to complete the starter project.
ROS2 Introduction
Section titled “ROS2 Introduction”ROS2 is a ‘meta operating system’ for robotics applications. The goal of ROS2 is to provide a set of tools and libraries to simplify the process of developing and running robotics software. Before beginning the starter project, work through the tutorials on the ROS2 website. Do these tutorials in a new directory in ~/ros2_ws/src.
- Do the CLI tools tutorial to understand the basics of ROS2 and how to use it: https://docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools.html. Skim over the ‘Configuring environment’ section, but do the rest thoroughly.
- Do the Publisher & Subscriber tutorials, in the language you are more comfortable in: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html
These are the fundamentals of ROS2. The docs linked have many additional tutorials that cover pretty much anything you would ever do with ROS2, making them a fantastic resource.
Clone and create starter project branch
Section titled “Clone and create starter project branch”Once you have completed the ROS2 tutorials, move onto the starter project. Here we will create a ROS2 node that will control PX4 through MAVROS, moving the drone!
We will do this using starter_project, a ROS2 node that you will create. You will write most of your code in starter-project/src/starter_project_mavros_node.cpp, but integral to this structure is also starter-project/launch/starter_project.launch.py, which launches the controller node, and drone_gs/launch/mavros.launch.py, which launches MAVROS.
Project Structure
Section titled “Project Structure”The data flow is:
PX4 <-> MAVLink <-> MAVROS <-> ROS 2 starter_project_mavros_nodeThe node will receive the drone’s state and pose (position data) from MAVROS, and use them to publish setpoints from a list for the drone to go to. While keeping a drone in the air is complex, PX4 makes sure that the drone can fly and controls the motors, making your job a lot easier.
Checking out the Starter Project Branch
Section titled “Checking out the Starter Project Branch”The starter project is contained in a branch, which is essentially a separate version of our codebase from our main. You can create your own branch to track your progress on the starter project.
After cloning the drone repo, switch to the starter project branch:
git fetchgit checkout starterproject27Now, create a branch for your own starter project:
git checkout -b <your name>/starterproject27- Skim through the code in starter-project/src/starter_project_mavros_node.cpp. Feel free to ask questions if anything looks confusing!
- Complete the position subscription and poseCallback() function
- Complete the updateTargetIfReached function. This function helps the drone cycle through the setpoints
- Feel free to put in your own list of setpoints!
Building and Running
Section titled “Building and Running”Once you are done with the project, you can build it to see if it works! The order given here doesn’t strictly have to be followed, and in some cases building your node first can help you debug. Building this project can seem confusing at first, but as you keep working on it it should get a lot easier! Here is a list of commands in order to run to launch a drone simulator (Gazebo and QGroundControl), MAVROS, and your ROS2 Node.
First, you have to create a simulation drone using PX4 and Gazebo. Open a new terminal and paste in the following commands.
cd ~/ros2_ws/src/mrover_drone/deps/PX4-Autopilotmake px4_sitl gz_x500Open a new Terminal. Then, run the following code to launch QGroundControl, which will give you a top down view of the simulation drone over a satellite image.
cd ~/ros2_wssource /opt/ros/jazzy/setup.zshsource ~/ros2_ws/install/setup.zshcolcon build --symlink-install --packages-select drone_sim --symlink-installros2 launch drone_sim px4_sitl_gz_ros2.launch.pyYour screen should now look like this. If not, ensure you have the proper software installed and ran the right commands.
Open another new Terminal. Then, run the following code to initialize MAVROS, which will allow for PX4 to communicate with your node.
cd ~/ros2_wsunset AMENT_CURRENT_PREFIX AMENT_PREFIX_PATH COLCON_PREFIX_PATHsource /opt/ros/jazzy/setup.zshsource ~/ros2_ws/install/setup.zshcolcon build --symlink-install --packages-select drone_gsros2 launch drone_gs mavros.launch.py \ fcu_url:='udp://:14540@127.0.0.1:14580'You’re almost there! Open another new Terminal. Run the following code to start up your node!
cd ~/ros2_wsunset AMENT_CURRENT_PREFIX AMENT_PREFIX_PATH COLCON_PREFIX_PATHsource /opt/ros/jazzy/setup.zshcolcon build --symlink-install --packages-select starter_project drone_gssource ~/ros2_ws/install/setup.zshros2 run starter_project starter_project_mavros_node --ros-args -p auto_offboard:=true -p auto_arm:=trueNow you should be able to see your drone flying on to the points you set in QGroundControl! Gazebo can also show you a visual of this. In the future, we can also experiment with running this code on our real drone!