(Ⅲ) Crazyflie Drone Swarm Control Notes Part 1
Ⅰ. Motion Capture Software VRPN Configuration
Taking motion capture software version XINGYING 4.2.0.5495 as an example, other versions are similar. Open the motion capture software and connect the cameras. Click View -> Data Broadcast in the menu bar. Under the VRPN stream in Data Broadcast, select meters from the unit dropdown, check Rigid Body for type, and enable VRPN.
.png)
Figure 1 - Open Data Broadcast View
.png)
Figure 2 - VRPN Configuration in Motion Capture
Click View -> Devices in the menu bar to open the device view. First click the stop playback button, and modify the motion capture frame rate to 120 in the Advanced box.
.png)
Figure 3 - Open Device View
.png)
Figure 4 - Modify Motion Capture Frame Rate
Ⅱ. Crazyswarm2 Platform Configuration
Taking ROS version: galactic, Ubuntu version: 20.04 as an example, other versions are similar. Crazyflie firmware version 2024.10 or above. If the version is too low, update it yourself (cfclient usage).
(Ⅰ) Install Dependencies
Open a terminal and use the following commands to install dependencies.
sudo apt-get install libfmt-dev libpcap-dev libpng-dev libusb-1.0-0-dev git
sudo apt install python3-pip
pip3 install rowan
(Ⅱ) Pull Source Code
Use the following commands to pull crazyswarm2 and motion_capture_tracking source code. Pull crazyswarm2 to the home directory (~).
git clone --recurse-submodules https://github.com/IMRCLab/crazyswarm2
cd crazyswarm2/
git clone --recurse-submodules https://github.com/IMRCLab/motion_capture_tracking
colcon build --symlink-install
echo "source ~/crazyswarm2/install/setup.bash" >> ~/.bashrc
(Ⅲ) Configure VRPN in Crazyswarm2
In the motion_capture.yaml file in crazyswarm2 (path: ~/crazyswarm2/crazyflie/config), change type to vrpn, and modify hostname to the IP address on the same network segment as the host running crazyswarm2 and the motion capture software.
.png)
Figure 5 - Configure type and hostname
In the crazyflies.yaml file in crazyswarm2 (path: ~/crazyswarm2/crazyflie/config), change all crazyflie types to cf21_mocap_deck, and modify tracking under the motion_capture field of cf21_mocap_deck to vrpn.
.png)
Figure 6 - Configure crazyflie type and motion_capture
(Ⅳ) Controller Selection
In the crazyflies.yaml configuration file, modify the controller field to 1 to use the PID controller, making crazyflie flight more stable.
.png)
Figure 7 - Select PID Controller
Ⅲ. Basic Operation Flight Demonstration
(Ⅰ) Attach Marker Points to Crazyflie
Attach Marker points to crazyflie (it is recommended to use a deck and Marker points below 8mm). The figure below shows one of the marker placement methods (you can adjust different marker shapes on the deck but cannot block the propellers). When flying multiple crazyflies, you can attach corresponding labels according to their connection addresses to distinguish crazyflies.
.png)
Figure 8 - Crazyflie Marker Placement Physical Image
(Ⅱ) PA Setup and Connection
When using PA on Ubuntu for the first time, USB permissions must be granted (USB permission granting steps).
Plug the PA into the ubuntu host (the host running crazyswarm2).
(Ⅲ) Crazyswarm2 Connection Configuration Description
In the crazyflies.yaml file in crazyswarm2 (path: ~/crazyswarm2/crazyflie/config), add the configuration of crazyflies to be flown under the robots field. Among them, cf231 and cf5 are rigid body names; enable represents enabling this crazyflie (set to false if not used); uri is the connection address of crazyflie; initial_position is the initial position where crazyflie is placed on the site; type selects cf21_mocap_deck (VRPN can only use rigid bodies, not unnamed points).
.png)
Figure 9 - Crazyflie Flight Configuration Description
(Ⅳ) Run Scripts
1 Single Aircraft Takeoff and Landing Script
Turn on 1 crazyflie and place it in the motion capture site with the nose facing the positive x-axis direction. Create a rigid body in the motion capture software with the name nokov1.
.png)
Figure 10 - Create Rigid Body
Add the configuration of this crazyflie in crazyflies.yaml.
.png)
Figure 11 - Add One Crazyflie Configuration
Open a terminal and run the following command to start the service node.
ros2 launch crazyflie launch.py gui:=False rviz:=True
Open another terminal and run the following command to view the position data of crazyflie.
ros2 topic echo /poses
Open another terminal and run the following command to start the takeoff and landing script.
cd ~/crazyswarm2/crazyflie_examples/crazyflie_examples/
python hello_world.py
.png)
Figure 12 - rviz Display
.png)
Figure 13 - Crazyflie Takeoff
2 figure8.py Figure-8 Swarm Script
Turn on 3 crazyflies and place them in the motion capture site with the nose facing the positive x-axis direction. Create rigid bodies in the motion capture software with names nokov1, nokov2, and nokov3 respectively.
.png)
Figure 14 - Create Rigid Bodies
Add the configuration of these crazyflies in crazyflies.yaml.
.png)
Figure 15 - Add Three Crazyflies Configuration
Go to the ~/crazyswarm2/crazyflie_examples/crazyflie_examples folder and modify figure8.py, comment out lines 29~32 (fly to initial position).
.png)
Figure 16 - Comment Out Code for Flying to Set Initial Position
Open a terminal and run the following command to start the service node.
ros2 launch crazyflie launch.py gui:=False rviz:=True
Open another terminal and run the following command to view the position data of crazyflies.
ros2 topic echo /poses
Open another terminal and run the following command to start the figure-8 script.
cd ~/crazyswarm2/crazyflie_examples/crazyflie_examples/
python figure8.py
.png)
Figure 17 - rviz Display
.png)
Figure 18 - Swarm Figure-8