Setup of the Crazyflie 2.x Environment
First clone the following GitHub repository, which provides sort of a cyber-physical representation of the Crazyflie 2.x drone.
Therefore, execute the following command in the terminal:
$ mkdir -p ~/uniagent_ws/ && cd ~/uniagent_ws/
$ git clone https://github.com/UniAgent-CyberPhysicalAssets/cps.asset.crazyflie
This resource is a prerequisite for all subsequent steps in this tutorial, including:
- Controlling and monitoring Crazyflies via RESTful web endpoints, WebSockets and in 3D
- Using the Gazebo/Webots simulation environment for Crazyflie drones
- Launching the cfclient tool to configure Crazyflie hardware
- And more ...
System Hardware Requirements
Platform
- The setup described in this tutorial does not work for arm64 platforms since not for all ROS2 packages, an arm64 binary is available.
- For example, the package
ros-humble-gazebo-no-physicsis required, which has however no arm64 binary (see here: http://packages.ros.org/ros2/ubuntu/dists/jammy/main/binary-arm64/Packages).
Enable GPU-accelerated Containers
(Optional but Recommended)
- Install the NVIDIA Container Toolkit
Convention
Terminal commands are prefixed with either $ or :#.
The former means that the command is executed in the host system (your computer).
The latter means that the command is executed in the Docker container.
Consider the lsusb command.
This should be executed inside the Docker container:
user@host: # lsusb
:# lsusb
This should be executed in the host system:
$ lsusb
If nothing is prefixed, this indicates output from the previous command.
USB Setup
Note: To control not only a virtual Crazyflie drone but also a real one, you need to make some USB devices such as the Crazyradio available in the Docker containers.
(ONLY for Linux) First, set the standard Crazyflie USB permissions: https://www.bitcraze.io/documentation/repository/crazyflie-lib-python/master/installation/usb_permissions/
You will need to find out your major device number in order to access the USB devices within the Docker containers.
For background on why this setup is necessary, especially when avoiding the use of --privileged, see also here and here.
There are three options:
- Option A) Use the
lsusbcommand to get a list of all USB devices connected to your system. Each line in thelsusboutput represents a USB device with a Bus number and Device number.
$ lsusb
[...]
Bus 001 Device 009: ID 1915:7777 Nordic Semiconductor ASA Bitcraze Crazyradio (PA) dongle
[...]
- Option B) Use
udevadmto get detailed information about the device, which includes the associated/deventry. Below replace001with the Bus number and009with the Device number from thelsusboutput. Specifically, use the output ofDEVNAME.
$ sudo udevadm info --query=all --name=/dev/bus/usb/001/009
[...]
U: usb
T: usb_device
D: c 189:262
N: bus/usb/001/009
[...]
- Option C) Get device major number via
ls -lausing information fromDEVNAME
$ ls -la /dev/bus/usb/001/009
crw-rw-r-- 1 root plugdev 189, 8 Aug 8 22:38 /dev/bus/usb/001/009
In the rest of this example:
- The major device number is in this example "189".
(!) With this information, note down the following Docker parameter for later: (!)
--device-cgroup-rule='c 189:* rmw' -v /run/udev:/run/udev:ro -v /dev:/dev
You need to probably adjust the major device number or the path if you have a different device or operating system.
In the following pages, you have to add this rule when starting the Docker container.
Note: Instead, you can also use the universal but insecure option:
--privileged -v /dev/bus/usb:/dev/bus/usb.