(Ⅳ) Crazyflie Drone Swarm Control Notes Part 2
Ⅰ. Motion Capture Software SDK 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. In the network card address dropdown, select an address on the same network segment as ubuntu. Here, select 192.168.5.141. Under the SDK stream, select multicast mode and enable SDK.
.png)
Figure 1 - Open Data Broadcast View
.png)
Figure 2 - Enable SDK
Ⅱ. Crazyswarm2 Platform Configuration
(Ⅰ) Place SDK in Specified Directory
Place the nokov_sdk folder in the deps directory of libmotioncapture (path: ~/crazyswarm2/motion_capture_tracking/motion_capture_tracking/deps/libmotioncapture/deps).
.png)
Figure 3 - Place SDK in Specified Directory
(Ⅱ) Compile motion_capture_tracking Source Code
Modify "set(LIBMOTIONCAPTURE_ENABLE_NOKOV OFF)" in the CMakeLists.txt file of motion_capture_tracking to "set(LIBMOTIONCAPTURE_ENABLE_NOKOV ON)" to enable SDK.
.png)
Figure 4 - motion_capture_tracking Enable SDK
Then modify "option(LIBMOTIONCAPTURE_ENABLE_NOKOV "Enable Nokov" OFF)" in the CMakeLists.txt file of libmotioncapture (path: ~/crazyswarm2/motion_capture_tracking/motion_capture_tracking/deps/libmotioncapture) to "option(LIBMOTIONCAPTURE_ENABLE_NOKOV "Enable Nokov" ON)"
.png)
Figure 5 - libmotioncapture Enable SDK
Use the following commands to recompile the motion_capture_tracking source code (the previous document pulled the motion_capture_tracking source code to the crazyswarm2 directory)
cd ~/crazyswarm2/
colcon build --symlink-install
source ~/.bashrc
(Ⅲ) Configure SDK in Crazyswarm2
In the motion_capture.yaml file in crazyswarm2 (path: ~/crazyswarm2/crazyflie/config), change type to nokov, and modify hostname to the network card address selected in Section Ⅰ: 192.168.5.141.
.png)
Figure 6 - Configure type and hostname
Ⅲ. Basic Operation Flight Demonstration
(Ⅰ) Single Aircraft Takeoff and Landing Control
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 7 - Create Rigid Body
Add the configuration of this crazyflie in crazyflies.yaml.
.png)
Figure 8 - 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 9 - rviz Display
.png)
Figure 10 - Crazyflie Takeoff
(Ⅱ) Swarm Figure-8 Control
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 11 - Create Rigid Bodies
Add the configuration of these crazyflies in crazyflies.yaml.
.png)
Figure 12 - 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 13 - 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 14 - rviz Display
.png)
Figure 15 - Swarm Figure-8