Skip to main content

(Ⅵ) Crazyflie and PX4 Heterogeneous Swarm Control

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

图 1-打开数据广播视图

Figure 1 - Open Data Broadcast View

图 2-动捕中vrpn配置

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 30 in the Advanced box.

图 3-打开设备视图

Figure 3 - Open Device View

图 4-修改动捕帧率

Figure 4 - Modify Motion Capture Frame Rate

Ⅱ. FlightMaster Platform Configuration

Requires ROS version: galactic, Ubuntu version: 20.04. Crazyflie firmware version 2024.10 or above. If the version is too low, update it yourself (cfclient installation and usage tutorial).

(Ⅰ) Configure VRPN in FlightMaster2

In the motion_capture.yaml file in FlightMaster2 (path: ~/FlightMaster2/flightmaster/config), change type to vrpn, and modify hostname to the IP address on the same network segment as the host running FlightMaster2 and the motion capture software.

图 5-配置type和hostname

Figure 5 - Configure type and hostname

In the flightmasters.yaml file in FlightMaster2 (path: ~/FlightMaster2/flightmaster/config), set the enabled field of motion_capture of the robot_types to be used to false.

图 6-设置vrpn方式

Figure 6 - Set VRPN Method

(Ⅱ) FlightMaster2 Connection Configuration Description

In the flightmasters.yaml file in FlightMaster2 (path: ~/FlightMaster2/flightmaster/config), under the robots field, the crazyflie configuration is consistent with that in crazyswarm2. The difference between PX4 drone configuration and crazyflie lies in uri and type. The PX4 drone uses the mavlink protocol, and there are multiple ways to connect addresses (mavlink connection address format). This experiment uses the udp connection method. Select type p200.

图 7-crazyflie与px4配置说明

Figure 7 - Crazyflie and PX4 Configuration Description

Ⅲ. Basic Operation Flight Demonstration

(Ⅰ) Create Rigid Bodies

Place one px4 drone and one crazyflie on the site with the nose facing the positive x-axis direction. Create rigid bodies pxf2 and nokov3, with skeleton orientation toward the x-axis.

(Ⅱ) Position Placement

Place px4 at the origin with the nose facing the positive x-axis direction. Place the crazyflie drone in front of px4 with the nose facing the positive x-axis direction. Refer to the position as shown below. Power on all devices.

图 8-参考位置

Figure 8 - Reference Position

(Ⅲ) Enable Devices

Configure and enable one crazyflie and one px4 drone in the flightmasters.yaml file.

图 9-启用集群设备

Figure 9 - Enable Swarm Devices

(Ⅳ) Modify Circle Script

Modify the names in the circle.py script (path: ~/FlightMaster2/flightmaster_examples/flightmaster_examples), and the startup should correspond. crazyflie corresponds to rigid body nokov3, and px4 corresponds to rigid body pxf2.

图 10-修改脚本

Figure 10 - Modify Script

(Ⅴ) Launch Graphical Operation Interface

Open a terminal and use the following command to open the flightmaster2 graphical control interface.

cd ~/FlightMaster2/
python fmclient.py
图 11-flightmaster2图形化界面

Figure 11 - Flightmaster2 Graphical Interface

(Ⅵ) Start Service Node

Select RealMode on the graphical interface and check RViz, then click Start FlightSwarm. At this time, the flightmaster2 service node will run, and rviz will also start.

图 12-启动flightmaster2和rviz

Figure 12 - Start Flightmaster2 and rviz

(Ⅶ) Start Circle Script

Click the Run circle.py button on the right side of the graphical interface to start the circle script.

图 13-启动画圈脚本

Figure 13 - Start Circle Script

图 14-rviz显示

Figure 14 - rviz Display

图 15-crazyflie绕px4画圈

Figure 15 - Crazyflie Circling Around PX4