Skip to main content

(Ⅳ) 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.

图 1-打开数据广播视图

Figure 1 - Open Data Broadcast View

图 2-启用SDK

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).

图 3-将sdk放置在指定目录

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.

图 4-motion_capture_tracking启用SDK

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)"

图 5-libmotioncapture启动sdk

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.

图 6-配置type和hostname

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.

图 7-建立刚体

Figure 7 - Create Rigid Body

Add the configuration of this crazyflie in crazyflies.yaml.

图 8-添加一架crazyflie配置

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
图 9-rviz显示

Figure 9 - rviz Display

图 10-crazyflie起飞

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.

图 11-建立刚体

Figure 11 - Create Rigid Bodies

Add the configuration of these crazyflies in crazyflies.yaml.

图 12-添加三架crazyflie配置

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).

图 13-注释掉飞向设定初始位置代码

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
图 14-rviz显示

Figure 14 - rviz Display

图 15-集群绕八字

Figure 15 - Swarm Figure-8