This repo offers a VS Code workspace template for developers working with PX4 and ROS 2. There are many automated tasks that you can make use of:
- Setup environment: Setup the development environment by installing all required programs
- Update ROS2 dependencies: Update/install packages using
vcstool
(see src/ros2.repos) androsdep
- Build (...): Build packages using
colcon
- Clean (...): Clean the workspace
- Purge: Remove
build
,install
andlog
- New ament_cmake/ament_python package: Create a new ROS2 package
- Export worlds: Export custom worlds to become available for simulation
- Run (...): Application shortcuts
The repository is inspired by the VS Code ROS 2 workspace template and tries to integrate common PX4 workflows to facilitate the troublesome development process of real-time ROS2 applications.
Use this template and create your workspace/repository by either pressing the button Use this template in the top right corner on GitHub or simply downloading the zip file. You should only clone this repo if you plan to make contributions.
Required OS is Ubuntu 22.04 (Jammy Jellyfish). There are a few tweaks you should apply to your Ubuntu system, to provide a stable development and simulation environment:
- Make sure your swap file is big enough if you have little amount of RAM. If too small, and the system memory on your machine is not able to handle the
colcon build
process, your system is likely to crash on big build loads. Follow this tutorial to increase the swap file. Usually, 16 GB of system memory should suffice. - Install the graphics driver of your external graphics card, if you have one. Gazebo simulation will put heavy load on you CPU, if the system is not able to utilize a graphics card. For example for nvidia graphics cards refer to here.
To automatically install all programs for developing with PX4 and ROS2, run setup.sh
. The default install location is ~/Desktop
. If either the PX4 workspace, QGroundControl or Groot2 have already been cloned/downloaded to a different location than the default one, the respective variables in env.sh need to be updated for the terminal environment and the automation tasks in VS Code to work properly. The setup script will only install the components that have not been found.
This workspace template is strongly connected with the AutoAPMS ROS 2 package and offers the recommended development setup. Please visit the Development Guide for learning more.
After installing the required ROS 2 packages, they need to be built. Building the workspace works with colcon build
(see this tutorial) but it is highly recommended to have a look at the provided VS Code tasks (under Terminal->Run Task...).