Installation
Crazyswarm2 runs on Ubuntu Linux in one of the following configurations:
| Ubuntu | Python | ROS 2 |
| 22.04 | 3.10 | Humble |
| 24.04 | 3.12 | Jazzy |
Warning
The Windows Subsystem for Linux (WSL) is experimentally supported but you’ll have to use usbipd-win. This program will link the crazyradio directly with WS, but beware of bugs. Check out their WSL connect guide.
Warning
Avoid using a virtual machine if possible: they add additional latency and might cause issues with the visualization tools.
First Installation
If needed, install ROS 2 using the instructions at https://docs.ros.org/en/jazzy/Installation.html.
Install dependencies
Binary Installation
bash
pip3 install rowan
>
> Source Installation
>
> ```bash
sudo apt install libboost-program-options-dev libusb-1.0-0-dev
pip3 install rowanThen install the motion capture ROS 2 package (replace with your version of ROS, namely humble or jazzy):
bash
sudo apt-get install ros--motion-capture-tracking
>
> If you are planning to use the CFlib backend, do:
>
> ```bash
pip3 install cflib transforms3d
sudo apt-get install ros-<DISTRO>-tf-transformationsIf you are planning to use the CFlib2 backend, do:
bash
pip3 install cflib2
3. Set up your ROS 2 workspace
> Binary Installation
>
> Then install the crazyswarm2 stack (replace <DISTRO> with your version of ROS, namely humble or jazzy):
>
> ```bash
sudo apt-get install ros-<DISTRO>-crazyflie*To prepare your workspace, see “Custom ROS Package” section below.
Source Installation
Clone the Crazyswarm2 repository
bash
mkdir -p ros2_ws/src cd ros2_ws/src git clone https://github.com/IMRCLab/crazyswarm2 --recursive
>
> Now build the ROS 2 workspace
>
> ```bash
cd ../
source /opt/ros/DISTRO/setup.bash
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=ReleaseNote
symlink-install allows you to edit Python and config files without running colcon build every time.
Note
If you install it for the first time, you will see a lot of warnings at first. As long as the build of the package finish, you can ignore this for now.
Warning
If you get build errors from missing pip, your machine are probably missing some additional packages that were missed in the initial ROS installation (see this issue.) Please pip install then the following and try again:
bash
pip3 install catkin_pkg lark-parser empy==3.3.4 colcon-common-extensions
4. Set up Crazyradio
For the Crazyradio, you need to setup usb rules in order to communicate with the Crazyflie. Find the instructions for that here [in Bitcraze’s USB permission guide for Linux](https://www.bitcraze.io/documentation/repository/crazyflie-lib-python/master/installation/usb_permissions/).
You will also need to update the Crazyradio firmware to the latest development branch to be able to use all features.
> - For Crazyradio PA (1), [follow these instructions](https://www.bitcraze.io/documentation/repository/crazyradio-firmware/master/building/building_flashing/).
> - For Crazyradio 2, follow [these instructions to flash](https://www.bitcraze.io/documentation/repository/crazyradio2-firmware/main/building-and-flashing/flash//) the [latest release](https://github.com/bitcraze/crazyradio2-firmware/releases) (we tested version 5.1).
5. Update the Crazyflies
If this is the first time handling Crazyflies it is always good to start with [Bitcraze’s getting started guide](https://www.bitcraze.io/documentation/tutorials/getting-started-with-crazyflie-2-x/).
You can update each Crazyflie firmware to the latest release via [these instructions of the Bitcraze Crazyflie client](https://www.bitcraze.io/documentation/repository/crazyflie-clients-python/master/userguides/userguide_client/#firmware-upgrade) .
While you are at it, make sure that each Crazyflie have an unique radio address which you can change in [the client via these instructions](https://www.bitcraze.io/documentation/repository/crazyflie-clients-python/master/userguides/userguide_client/#firmware-configuration) .
6. Set up software-in-the-loop simulation (optional)
> This currently requires cloning the Crazyflie firmware of the latest tested release (2025.02) and building the Python bindings manually. In a separate folder (not part of your ROS 2 workspace!),
>
> ```bash
git clone --branch 2025.02 --single-branch --recursive https://github.com/bitcraze/crazyflie-firmware.gitFirst build the python binding from the source code of the Crazyflie firmware. Afterwards, make sure that the bindings can be found in the python path:
bash
make cf2_defconfig make bindings_python export PYTHONPATH=/crazyflie-firmware/build:$PYTHONPATH
>
> If you are working from an older version of the crazyflie-firmware (before tag 2023.02), then you will need to point to main folder of the repo by removing the ‘/build’ part.
## Updating
You can update your local copy using the following commands:
> Binary Installation
>
> ```bash
sudo apt update
sudo apt upgradeSource Installation
bash
cd ros2_ws/src/crazyswarm2 git pull git submodule sync git submodule update --init --recursive cd ../../ source /opt/ros/DISTRO/setup.bash colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
## Custom ROS Package
In order to use Crazyswarm, it is best practice to use a custom ROS package that contains all necessary config files as well as your user scripts / ROS nodes.
1. Create a new package
> ```bash
mkdir -p ros2_ws/src
cd ros2_ws/src
ros2 pkg create --build-type ament_python --license MIT --node-name hello_world crazyflie_testReplace hello_world.py with https://github.com/IMRCLab/crazyswarm2/blob/main/crazyflie_examples/crazyflie_examples/hello_world.py
Add crazyflie_py to package.xml
Copy config files crazyflies.yaml and motion_capture.yaml from https://github.com/IMRCLab/crazyswarm2/tree/main/crazyflie/config into the config folder
Add launch/launch.py with the following content
python
import os
from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource
package_name = 'crazyflie_test'
def generate_launch_description():
crazyflies_yaml_path = os.path.join(
get_package_share_directory(package_name),
'config',
'crazyflies.yaml')
motion_capture_yaml_path = os.path.join(
get_package_share_directory(package_name),
'config',
'motion_capture.yaml')
return LaunchDescription(
[
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
os.path.join(
get_package_share_directory('crazyflie'), 'launch'
),
'/launch.py',
]
),
launch_arguments={
'crazyflies_yaml_file': crazyflies_yaml_path,
'motion_capture_yaml_file': motion_capture_yaml_path,
}.items(),
),
]
)6. In setup.py, include the following lines as part of the data\_files array:
> ```python
(os.path.join('share', package_name, 'launch'), glob('launch/*')),
(os.path.join('share', package_name, 'config'), glob('config/*'))