The workshop exercises can be run in a dockerized environment with minimal components having to run on the Host.
First of all, install docker, then pull the px4io/px4-dev-ros2-gazebo image.
docker pull px4io/px4-dev-ros2-gazebo:main-jazzyThen clone the PX4-Autopilot repo and checkout the release/1.18 branch.
git clone --recurse-submodules -b release/1.18 https://github.com/PX4/PX4-Autopilot.gitThen create your ROS 2 workspace:
-
Create a ROS 2 workspace
mkdir -p ~/workspaces/px4_roscon26_ws/src cd ~/workspaces/px4_roscon26_ws/src git clone -b develop git@github.com:Dronecode/roscon-25-workshop.git px4-roscon-workshop
-
Clone the dependencies
cd ~/workspaces/px4_roscon26_ws vcs import src < ./src/px4-roscon-workshop/jazzy.repos
Download QGC.
Download Foxglove
The ./docker/docker_run.sh script can be used to start the container with the right mounts and envs.
./docker/docker_run.sh ~/PX4-AutopilotThis will:
-
Mount the
~/PX4-Autopilotdirectory into/PX4-Autopilot. -
Mount the workspace src directory
~/workspaces/px4_roscon26_ws/srcinto/workspace/src -
Forward GUI (software OpenGL). To use hardware acceleration and for adjustments for using WSL2, please refer to Gazebo Container GUI. To instead run headless run the script with the env var
HEADLESS=1.HEADLESS=1 ./docker/docker_run.sh ~/PX4-Autopilot
To use a different docker image, use
IMAGE=<image-name> ./docker/docker_run.sh ~/PX4-AutopilotNow install the workspace dependencies and build the workspace, these commands will need to be run each time the container is created and started.
apt update
rosdep install -y -i --from-paths src --skip-keys OpenCV
source /opt/ros/jazzy/setup.bash
colcon build --symlink-installWith the workspace build, you can now build PX4, these commands will also need to be run each time the container is created and started.
cd /PX4-Autopilot
make px4_sitl_defaultYou can now refer to How to start the simulation to validate the setup.
To locally build the px4io/px4-dev-ros2-gazebo:main-jazzy docker image instead of pulling it from Docker Hub follow these steps:
cd ~/PX4-Autopilot
git submodule deinit --all -f
git fetch
git checkout feat/add_dev_ros2_gazebo_container
bash Tools/packaging/containers/prepare_context.sh
ROS_DISTRO=jazzy docker buildx bake -f Tools/packaging/containers/docker-bake.hcl ros2-gazebo-dev \
--set ros2-gazebo-dev.tags=px4-dev-ros2-gazebo:local --loadNow you can use the px4-dev-ros2-gazebo:local docker image instead of px4io/px4-dev-ros2-gazebo:main-jazzy.
Before proceeding, don't forget to return PX4-Autopilot back to release/1.18 branch
cd ~/PX4-Autopilot
git clean -fxd
git checkout release/1.18
git submodule update --init --recursiveTo run the container you can use:
IMAGE=px4-dev-ros2-gazebo:local ./docker/docker_run.sh ~/PX4-Autopilot