Skip to content

Latest commit

 

History

History
116 lines (80 loc) · 3.36 KB

setup_docker.md

File metadata and controls

116 lines (80 loc) · 3.36 KB

Dockerized setup

The workshop exercises can be run in a dockerized environment with minimal components having to run on the Host.

Host setup

First of all, install docker, then pull the px4io/px4-dev-ros2-gazebo image.

docker pull px4io/px4-dev-ros2-gazebo:main-jazzy

Then 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.git

Then create your ROS 2 workspace:

  1. 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
  2. Clone the dependencies

    cd ~/workspaces/px4_roscon26_ws
    vcs import src < ./src/px4-roscon-workshop/jazzy.repos

QGroundControl

Download QGC.

Foxglove

Download Foxglove

Running in docker

The ./docker/docker_run.sh script can be used to start the container with the right mounts and envs.

./docker/docker_run.sh ~/PX4-Autopilot

This will:

  • Mount the ~/PX4-Autopilot directory into /PX4-Autopilot.

  • Mount the workspace src directory ~/workspaces/px4_roscon26_ws/src into /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-Autopilot

Now 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-install

With 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_default

You can now refer to How to start the simulation to validate the setup.

Local docker build

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 --load

Now 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 --recursive

To run the container you can use:

IMAGE=px4-dev-ros2-gazebo:local ./docker/docker_run.sh ~/PX4-Autopilot