PX4 Swarm Controller

The aim of this repository is to provide a scalable multi-drone simulation for easy testing of control laws on fleets of
UAVs. The default controller is based on a leader-follower approach taken from the
paper Distributed leader-follower formation control for
multiple quadrotors with weighted topology (Zhicheng Hou, Isabelle Fantoni).
This project was carried out as part of the Research and Development professional option at Ecole Centrale de Nantes
with my partner Martin Piernas.
Install
ROS2
This package was written using ROS2 Humble under Ubuntu 22.04. If it’s not installed, check
the ROS2 documentation or run
the commands
below.
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update && sudo apt upgrade -y
sudo apt install ros-humble-desktop
sudo apt install ros-dev-tools
Don’t forget to source your installation in the terminal or in your
``` (See example below).
```bash
source /opt/ros/humble/setup.bash
You will also need to have
``` [installed](https://classic.gazebosim.org/tutorials?tut=install_ubuntu).
### PX4 Autopilot
We used the PX4 Autopilot which uses the Micro XRCE-DDS Agent & Client as middleware.
Here are the installation commands to run in your terminal, you can also check
the [PX4 documentation](https://docs.px4.io/main/en/ros/ros2_comm.html):
```bash
cd
git clone https://github.com/PX4/PX4-Autopilot.git --recursive
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
cd PX4-Autopilot/
make px4_sitl
pip install --user -U empy==3.3.4 pyros-genmsg setuptools
git clone https://github.com/eProsima/Micro-XRCE-DDS-Agent.git
cd Micro-XRCE-DDS-Agent
mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig /usr/local/lib/
Install and build the package
- Create a ROS2 workspace (Skip if already done)
cd ros2_ws/src
git clone https://github.com/artastier/PX4_Swarm_Controller.git
mv PX4_Swarm_Controller px4_swarm_controller
- We need to
overwrite
the original
sitl_multiple_run.sh
of PX4 by the new one
mv -i px4_swarm_controller/sitl_multiple_run.sh ~/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_multiple_run.sh
- Move the package containing the messages in the
/src
directory:
mv px4_swarm_controller/custom_msgs/ ~/ros2_ws/src/
- Build the package and the custom messages using
colcon build --packages-select custom_msgs
colcon build --packages-select px4_swarm_controller
- Don’t forget to source your ROS2 workspace in your terminal or in your
bashrc
(See example below).
source ~/ros2_ws/install/local_setup.bash
File truncated at 100 lines see the full file