Unity3D-based unmanned aerial vehicle cluster flight trajectory visualization simulation method
Patent Information
- Application Number
- CN202510169152.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2045-02-17
AI Technical Summary
[0005]鉴于此,本发明提供了一种基于Unity3D的无人机集群飞行轨迹可视化仿真方法,以解决现有无人机集群轨迹仿真技术在动态路径规划、飞行协调、视角切换等方面的不足,提高集群飞行仿真过程中的轨迹优化精度与可视化效果
[0086] 1. Based on the improved DACPO path planning algorithm and cubic spline interpolation method, the flight trajectory of UAV swarm can be effectively optimized, solving problems such as path discontinuity and sharp turns in the coordinated flight of multiple UAVs, and significantly improving the smoothness and coordination of swarm flight;
Smart Images

Figure CN120044813B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of drone swarm simulation and visualization technology, and specifically relates to a method for visualizing and simulating the flight trajectory of drone swarms based on Unity3D. Background Technology
[0002] With the rapid development of UAV swarm technology, its applications in various fields such as military reconnaissance, disaster relief, and environmental monitoring are increasing. The flight trajectories of UAV swarms are usually quite complex, involving multiple aspects such as path planning, dynamic obstacle avoidance, and cooperative control. Therefore, the simulation and visualization of swarm flight trajectories are of great significance for optimizing flight control algorithms, verifying mission planning, improving mission execution efficiency, and enhancing system robustness.
[0003] Unity3D, a widely used 3D game engine, provides effective technical support for the visualization of drone swarm trajectories thanks to its powerful modeling, real-time rendering, and physics simulation capabilities. Simulation using Unity3D not only enables the dynamic display of flight paths, attitudes, and swarm behavior, but also leverages its high scalability and interactivity to meet the simulation needs of multiple scenarios and tasks, making it an important tool for drone swarm simulation and visualization. However, existing technologies also face many challenges in efficiently generating and optimizing flight trajectories and ensuring the accuracy and real-time performance of simulation results.
[0004] Therefore, how to effectively combine drone swarm trajectories with visualization technology to improve the expressiveness and accuracy of the flight process has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, the present invention provides a Unity3D-based method for visualizing and simulating the flight trajectories of UAV swarms, addressing the shortcomings of existing UAV swarm trajectory simulation technologies in dynamic path planning, flight coordination, and viewpoint switching, thereby improving the accuracy of trajectory optimization and visualization effects during swarm flight simulation. By integrating an improved DACPO algorithm, cubic spline interpolation, and real-time rendering technology, this invention can dynamically display the flight process and collaborative behavior of multiple UAVs while ensuring simulation accuracy, meeting the high precision and real-time requirements of practical applications.
[0006] This invention provides a method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D, including:
[0007] S1: Create the terrain and flight environment required for swarm flight using the Unity3D platform;
[0008] S2: Export the terrain data and construct the Terrain.csv terrain database;
[0009] S3: Design a kinematic model of a drone for swarm control and integrate it into the Unity3D virtual environment;
[0010] S4: Based on the improved DACPO 3D path planning algorithm, the optimal flight path points are planned for each UAV in the cluster;
[0011] S5: The flight paths of the cluster are smoothly fitted by cubic spline interpolation to obtain a coordinated cluster flight path.
[0012] S6: Merge the optimized trajectory data and generate a UAVsPath.csv file containing cluster trajectory information;
[0013] S7: Unity3D reads the UAVsPath.csv file, parses it, and renders a real-time visualization of the cluster's coordinated flight.
[0014] S8: Configure a camera on each drone to obtain multi-angle real-time perspective information of the swarm flight.
[0015] Preferably, S1 specifically includes:
[0016] Create a terrain object in the Unity3D platform and attach a C# script for terrain generation to the terrain object, using a noise function to generate random terrain undulations;
[0017] In Unity3D, threat zones are defined, using cylindrical and spherical regions to simulate the threat zones that a drone swarm may face during flight.
[0018] Define the boundaries and restrictions of the flight area to ensure that the drone swarm flies within the predetermined spatial range.
[0019] Further optimization, S2 specifically includes:
[0020] The generated terrain is sampled using a custom C# script to extract its height and corresponding XY plane coordinates.
[0021] The sampled terrain data is organized into a CSV file, with each record containing the X coordinate, Y coordinate and the corresponding Z height value, to ensure that changes in terrain height can be accurately reflected.
[0022] Name the exported terrain data Terrain.csv and store it in the Assets folder of your Unity3D project.
[0023] Further optimization, S3 specifically includes:
[0024] Import the FBX format drone model suitable for Unity3D and build the 3D appearance of each drone. The model includes the body, propellers, sensors and exterior paint.
[0025] Design a kinematic model for UAVs suitable for swarm control to calculate the displacement, velocity, and acceleration of the UAVs;
[0026] Based on the UAV trajectory coordinate information, calculate the heading angle, pitch angle, and roll angle to describe the UAV's flight attitude and heading changes;
[0027] By binding the UAV kinematic model to the Unity3D physics engine, the UAV model's response to mechanical changes during simulation can be realized.
[0028] Further optimization, S4 specifically includes:
[0029] Define the objective function and construct the search space. The cluster contains N drones, and each drone needs to optimize n nodes. Each node is represented by a Cartesian coordinate (x, y, y) tuple. j y j , z j The description is as follows: where j is the node index, each node contains 3 degrees of freedom, so the overall optimization dimension is D = 3 × n × N;
[0030] Define decision vector Where X contains the decision variables of all drones and all nodes, arranged in order;
[0031] Define the upper and lower bounds of the search space as vectors. and These represent the lower and upper bounds of each decision variable, respectively. During the planning process, any decision variable exceeding this range must be modified or truncated to between lb and ub.
[0032] Initialize the parameters of the DACPO algorithm, including population size P and maximum number of iterations T. max The lower bound lb for each dimension j j and the upper world ub j Problem dimension D and fitness function handle f;
[0033] Generate the initial population matrix within the defined search space. Among them, each individual X i Through formula X i,j =ib j +rand×(ub j -lb j )generate;
[0034] Among them, X i,j X is the position of the i-th individual in dimension j.i This is the path of the i-th individual, containing n three-dimensional coordinate points. The dimension of the path is 3n, x ij y ij , z ij These are the coordinates of the j-th node on the path of the i-th individual on the x, y, and z axes, respectively.
[0035] X i =[x i1 y i1 , z i1 x i2 y i2 , z i2 , ..., x in y in , z in ];
[0036] Assess each individual's fitness score. i =f(X) i ), where each individual X i fitness f(X) i The total cost of the path is calculated using the following formula;
[0037] f(X i )=w1L(X i )+w2C o (X i )+w3C h (X i )+w4C t (X i );
[0038] Where w1, w2, w3, and w4 are the weighting coefficients of each cost, and f(X) i This includes path length cost L(X) i Obstacle avoidance cost C o (X i ), high cost C h (X i ) and corner cost C t (X i );
[0039] Determine the global optimal solution and its fitness value G f =min{fitness1,...,fitness P}, where i * Index the individual with the lowest fitness value;
[0040] Record the local optimal solution Xp for each individual. i =X i ;
[0041] Enter the optimization loop and continue iterating until the number of iterations t exceeds T. max Each iteration includes generating random numbers r2 to control the search behavior for each individual X. i Generate a random vector U1 that controls whether it enters the exploration phase;
[0042]
[0043] An individual enters either the exploration or development phase based on probability conditions. If it enters the exploration phase, the first or second defense mechanism is randomly selected, and the corresponding strategy is applied to update its position X. i ;
[0044] X i =U1 j ×X i +(1-U1 j )×(y t +rand×(X m -X n ));
[0045] Among them, X m X represents a relatively good individual in the current population or a globally optimal solution. n This represents a poor individual or a locally optimal solution in the current population, rand×(X) m -X n ) represents a dynamic perturbation based on a random factor;
[0046] If the development phase begins, then temporary parameters are calculated. And a random vector U2, and through the formula X i =G s +(α×(1-r2)+r2)×(U2 j ×G s -X i The third or fourth defense mechanism is applied to update the individual's position, where S is a bias term with a small constant.
[0047] Perform boundary checks on the updated locations to ensure that each location component X... i,j Keep at lb j and ub j If it exceeds the range, then use formula X. i,j =lb j +rand×(ub j -lb j Reassign the value;
[0048] Recalculate fitness value i =f(X)i ), and when the condition of fitness is met i ≤G f At that time, update the global optimal solution G. s and its fitness value G f Among them, G s =X i G f =fitness i ;
[0049] The population size P is dynamically adjusted, where, In the formula N min =round(0.8×P), and T=2;
[0050] Record the current global optimal fitness value G f To the convergence curve C(t);
[0051] When the number of iterations t exceeds T max When the time is reached, the optimization loop terminates and the global optimal solution G is output. s and its fitness value G f This serves as the optimal flight path for drone swarms.
[0052] Further optimization, S5 specifically includes:
[0053] After obtaining the globally optimal flight trajectory, the discrete waypoints of each UAV are sampled and the three-dimensional coordinate sequence of the UAV is recorded.
[0054] X i ={(x i,1 y i,1 , z i,1 ), (x i,2 y i,2 , z i,2 ), ..., (x i,j y i,j , z i,j )}, 1≤j≤n;
[0055] Where i represents the i-th drone, and j is the number of nodes;
[0056] The sequence is parameterized, and the Euclidean distance between any two adjacent nodes is given by:
[0057]
[0058] in,
[0059] Calculate cumulative distance Among them, s i,1=0, thus establishing the correspondence between the trajectory parameter s and the node sequence;
[0060] For each coordinate axis x, y, z, construct a cubic spline interpolation function S based on parameter s. i,x (s), S i,y (s), S i,z (s), each spline segment [s] i,j s i,j+1 Within the brackets, the spline function is represented as:
[0061] S i,x (s)=a i,j,x +b i,j,x (ss i,j )+c i,j,x (ss i,j ) 2 +d i,j,x (ss i,j ) 3
[0062] S i,y (s)=a i,j,y +b i,j,y (ss i,j )+c i,j,y (ss i,j ) 2 +d i,j,y (ss i,j ) 3 ;
[0063] S i,z (s)=a i,j, z+b i,j,z (ss i,j )+c i,j,z (ss i,j ) 2 +d i,j,z (ss i,j ) 3
[0064] Among them, a i,j,k b i,j,k c i,j,k , d i,j,k k∈{x,y,z} are spline coefficients, which are solved using the above conditions;
[0065] The optimized trajectory must meet flight altitude restrictions:
[0066]
[0067] Among them, S i,n =s i,n This represents the cumulative total distance.
[0068] The optimized cubic spline function parameters {a i,j,k b i,j,k c i,j,k , d i,j,k Each drone i is saved to form the final trajectory dataset.
[0069] Further optimization, S6 specifically includes:
[0070] After completing trajectory optimization, the optimized path points of each drone are stored in a readable and writable array;
[0071] Define a structure array A = {A1, A2, ..., A...} containing N fields. N}, where each field A i (i = 1, 2, ..., N) stores the flight path data of the i-th UAV. The data for each path point includes the position coordinates (x, y, y). i,j y i,j , z i,j );
[0072] Use a data export tool to export the structure array A as a CSV file. The coordinates of all path points for each drone are listed in column headers: x1, y1, z1, x2, y2, z2, ..., x j y j , z j Arrange them sequentially to generate the file UAVsPath.csv;
[0073] Each line records the coordinates of a path point, such as (x i,j y i,j , z i,j Let be the three-dimensional coordinates of the i-th UAV at path point j;
[0074] Place the UAVsPath.csv file in the Assets\Drone folder of your Unity3D project.
[0075] Further optimization, S7 includes the following steps:
[0076] In the Unity3D environment, first read the 3D position coordinates (x, y, x) of each path point for each drone from the generated UAVsPath.csv file. i,j y i,j , z i,j These waypoints represent the specific locations of the drone during its flight;
[0077] Parse the data in the UAVsPath.csv file, extract the path points of each drone in sequence, and output the 3D coordinates (x, y, z) of each path point. i,j y i,j , z i,j Convert the coordinates to a coordinate format that can be recognized in Unity3D;
[0078] Write a C# script and attach it to each drone in the cluster. This script will make each drone move according to the trajectory flight data read from the UAVsPath.csv file.
[0079] Render each path point, connect adjacent path points with line segments to form the drone's flight path, and dynamically draw a smooth flight path according to the order of the path points, so that the flight path can be visualized.
[0080] During the simulation, Unity3D displays the flight paths of multiple drones in real time. By combining the drone dynamics model and dynamically updating the displayed content, it ensures that the flight trajectory of the drone swarm is displayed synchronously with the actual movement process.
[0081] Further optimization, S8 includes the following steps:
[0082] Configure a virtual camera for each drone, write C# scripts to attach the camera to the drone, and manage the camera through Unity3D's virtual camera system, synchronizing it with the drone's position and orientation;
[0083] During flight, each drone's camera continuously captures real-time perspective information and transmits this perspective data to the Unity3D engine;
[0084] Different flight perspectives can be switched in real time as needed to view the flight dynamics of each drone and observe the flight path and relative position of the entire cluster.
[0085] The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D provided by this invention has the following beneficial effects:
[0086] 1. Based on the improved DACPO path planning algorithm and cubic spline interpolation method, the flight trajectory of UAV swarm can be effectively optimized, solving problems such as path discontinuity and sharp turns in the coordinated flight of multiple UAVs, and significantly improving the smoothness and coordination of swarm flight;
[0087] 2. Leveraging the powerful rendering and physical simulation capabilities of the Unity3D platform, this invention can display the flight trajectory and dynamic behavior of drone swarms in real time, solving the problems of insufficiently realistic visualization and poor real-time performance in traditional flight simulation systems, and improving the efficiency of flight control and mission verification.
[0088] 3. By equipping each drone with a virtual camera, this invention enables multi-angle viewing of swarm flight, helping users to monitor the flight process more comprehensively and improving safety and operability during flight. Attached Figure Description
[0089] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0090] Figure 1 This is a flowchart of the method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D provided by the present invention;
[0091] Figure 2 A simulation environment diagram created for this invention;
[0092] Figure 3 This is a flowchart of the DACPO algorithm of the present invention;
[0093] Figure 4 This is a visualization of the flight trajectory of the UAV swarm, as presented in this invention.
[0094] Figure 5 This is a visualization of the drone swarm flight perspective of the present invention. Detailed Implementation
[0095] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, to avoid obscuring the invention with unnecessary details, only processing steps closely related to the solution of this invention are shown in the drawings, while other details not closely related to this invention are omitted.
[0096] like Figure 1 As shown, this invention provides a method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D, including the following steps:
[0097] S1: Create the terrain and flight environment required for cluster flight using the Unity3D platform (e.g., ... Figure 2 As shown), specifically including:
[0098] Create a terrain object in the Unity3D platform and attach a C# script for terrain generation to the terrain object, using a noise function to generate random terrain undulations;
[0099] In Unity3D, threat zones are defined, using cylindrical and spherical regions to simulate the threat zones that a drone swarm may face during flight.
[0100] Define the boundaries and restrictions of the flight area to ensure that the drone swarm flies within the predetermined spatial range;
[0101] S2: Export the terrain data and construct the Terrain.csv terrain database, specifically including:
[0102] The generated terrain is sampled using a custom C# script to extract its height and corresponding XY plane coordinates.
[0103] The sampled terrain data is organized into a CSV file, with each record containing the X coordinate, Y coordinate and the corresponding Z height value, to ensure that changes in terrain height can be accurately reflected.
[0104] Name the exported terrain data Terrain.csv and store it in the Assets folder of your Unity3D project;
[0105] S3: Design a kinematic model for swarm-controlled UAVs and integrate it into the Unity3D virtual environment, specifically including:
[0106] Import the FBX format drone model suitable for Unity3D and build the 3D appearance of each drone. The model includes the body, propellers, sensors and exterior paint.
[0107] Design a kinematic model for UAVs suitable for swarm control, including parameters such as position and velocity, to calculate the displacement, velocity and acceleration of the UAVs;
[0108] Based on the UAV trajectory coordinate information, the heading angle, pitch angle and roll angle are accurately calculated to describe the UAV's flight attitude and heading changes;
[0109] By binding the drone's kinematic model to Unity3D's physics engine, the drone model's response to mechanical changes during simulation can be realized, ensuring the realism of the simulation effect.
[0110] S4: Based on the improved DACPO 3D path planning algorithm, it plans the optimal flight waypoints for each UAV in the cluster, specifically including:
[0111] Define the objective function and construct the search space. The cluster contains N drones, and each drone needs to optimize n nodes. Each node is represented by a Cartesian coordinate (x, y, y) tuple. j y i , z j The description is as follows: where j is the node index, each node contains 3 degrees of freedom, so the overall optimization dimension is D = 3 × n × N;
[0112] Define decision vector Where X contains the decision variables of all drones and all nodes, arranged in order;
[0113] Define the upper and lower bounds of the search space as vectors. and These represent the lower and upper bounds of each decision variable, respectively. During the planning process, any decision variable exceeding this range must be modified or truncated to between lb and ub.
[0114] like Figure 3 As shown, the parameters for initializing the DACPO algorithm include population size P and maximum number of iterations T. max The lower bound lb for each dimension j j and the upper world ub j Problem dimension D and fitness function handle f;
[0115] Generate the initial population matrix within the defined search space. Among them, each individual X i Through formula X i,j =lb j +rand×(ub j -lb j This generation ensures population diversity;
[0116] Among them, X i,j X is the position of the i-th individual in dimension j. i This is the path of the i-th individual, containing n three-dimensional coordinate points. The dimension of the path is 3n, x ij y ij , z ij These are the coordinates of the j-th node on the path of the i-th individual on the x, y, and z axes, respectively.
[0117] X i =[x i1 y i1 , z i1 x i2 y i2 , z i2 , ..., x in y in , z in ];
[0118] Assess each individual's fitness score. i =f(X) i ), where each individual X i fitness f(X) i The total cost of the path is calculated using the following formula;
[0119] f(X i )=w1L(X i )+w2C o (X i )+w3C h (X i )+w4C t (X i );
[0120] Where w1, w2, w3, and w4 are the weighting coefficients of each cost, and f(X) i This includes path length cost L(X) i Obstacle avoidance cost C o (X i ), high cost C h (X i ) and corner cost C t (X i );
[0121] Determine the global optimal solution and its fitness value G i =min{fitness1,...,fitness P}, where i * Index the individual with the lowest fitness value;
[0122] Record the local optimal solution Xp for each individual. i =X i ;
[0123] Enter the optimization loop and continue iterating until the number of iterations t exceeds T. max Each iteration includes generating random numbers r2 to control the search behavior for each individual X. i Generate a random vector U1 that controls whether it enters the exploration phase;
[0124]
[0125] An individual enters either the exploration or development phase based on probability conditions. If it enters the exploration phase, the first or second defense mechanism is randomly selected, and the corresponding strategy is applied to update its position X. i ;
[0126] X i =U1j ×X i +(1-U1 j )×(y t +rand×(X m -X n ));
[0127] Among them, X m X represents the position of an individual m in the current population, usually a relatively good individual or a globally optimal solution. n This represents the position n of an individual in the current population, typically a poor individual or a locally optimal solution, and is expressed as rand×(X). m -X n ) represents a dynamic perturbation based on a random factor;
[0128] If the development phase begins, then temporary parameters are calculated. And a random vector U2, and through the formula X i =G s +(α×(1-r2)+r2)×(U2 j ×G s -X i The third or fourth defense mechanism is applied to update the individual's position, where S is a bias term with a small constant.
[0129] Perform boundary checks on the updated locations to ensure that each location component X... i,j Keep at lb j and ub j If it exceeds the range, then use formula X. i,j =lb j +rsnd×(ub j -lb j Reassign the value;
[0130] Recalculate fitness value i =f(X) i ), and when the condition of fitness is met i ≤G f At that time, update the global optimal solution G. s and its fitness value G f G s =X i G f =fitness i ;
[0131] The population size P is dynamically adjusted, where, In the formula N min =round(0.8×P), and T=2;
[0132] Record the current global optimal fitness value G f To the convergence curve C(t);
[0133] When the number of iterations t exceeds T max When the time is reached, the optimization loop terminates and the global optimal solution G is output. s and its fitness value G f As the optimal flight path for drone swarms;
[0134] S5: The swarm's flight paths are smoothly fitted using cubic spline interpolation to obtain a coordinated swarm flight path, specifically including:
[0135] After obtaining the globally optimal flight trajectory, the discrete waypoints of each UAV are sampled and the three-dimensional coordinate sequence of the UAV is recorded.
[0136] X i ={(x i,1 y i,1 , z i,1 ), (x i,2 y i,2 , z i,2 ), ..., (x i,j y i,j , z i,j )}, 1≤j≤n;
[0137] Where i represents the i-th drone, and j is the number of nodes;
[0138] The sequence is parameterized, and the Euclidean distance between any two adjacent nodes is denoted as .
[0139]
[0140] in,
[0141] Calculate cumulative distance Among them, s i,1 =0, thus establishing the correspondence between the trajectory parameter s and the node sequence;
[0142] For each coordinate axis x, y, z, construct a cubic spline interpolation function S based on parameter s. i,x (s), S i,y (s), S i,z (s), each spline segment [s] i,j s i,j+1 Within a given area, a spline function can be expressed as:
[0143] S i,x (s)=a i,j,x +b i,j,x (ss i,j )+ci,j,x (ss i,j ) 2 +d i,j,x (ss i,j ) 3
[0144] S i,y (s)=a i,j,y +b i,j,y (ss i,j )+c i,j,y (ss i,j ) 2 +d i,j,y (ss i,j ) 3 ;
[0145] S i,z (s)=a i,j,z +b i,j,z (ss i,j )+a i,j,z (ss i,j ) 2 +d i,j,z (ss i,j ) 3
[0146] Among them, a i,j,k b i,j,k c i,j,k , d i,j,k k∈{x,y,z} are spline coefficients, which are solved using the above conditions;
[0147] The optimized trajectory must meet flight altitude restrictions:
[0148]
[0149] Among them, S i,n =s i,n This represents the cumulative total distance.
[0150] The optimized cubic spline function parameters {a i,j,k b i,j,k c i,j,k , d i,j,k Each drone i is saved to form the final trajectory dataset.
[0151] S6: Merge the optimized trajectory data to generate a UAVsPath containing cluster trajectory information. csv The documents specifically include:
[0152] After completing trajectory optimization, the optimized path points of each drone are stored in a readable and writable array;
[0153] Define a structure array A = {A1, A2, ..., A...} containing N fields. N}, where each field A i (i = 1, 2, ..., N) stores the flight path data of the i-th UAV. The data for each path point includes the position coordinates (x, y, y). i,j y i,j , z i,j );
[0154] Use a data export tool to export the structure array A as a CSV file. The coordinates of all path points for each drone are listed in column headers: x1, y1, z1, x2, y2, z2, ..., x j y i The zj values are arranged sequentially, generating the file UAVsPath.csv;
[0155] Each line records the coordinates of a path point, such as (x i,j y i,j , z i,j Let be the three-dimensional coordinates of the i-th UAV at path point j;
[0156] Place the UAVsPath.csv file in the Assets\Drone folder of your Unity3D project;
[0157] S7: Unity3D reads the UAVsPath.csv file, parses it, and renders a real-time visualization of the cluster's coordinated flight, including the following steps:
[0158] In the Unity3D environment, first read the 3D position coordinates (x, y, x) of each path point for each drone from the generated UAVsPath.csv file. i ,j,y i ,j,z i These waypoints (j) represent the specific locations of the UAV during its flight.
[0159] Parse UAVsPath. csv The data in the file extracts the path points of each drone in sequence and sets the three-dimensional coordinates (x, y, z) of each path point. i,j y i,j , z i,j Convert the coordinates to a coordinate format that can be recognized in Unity3D;
[0160] Write a C# script and attach it to each drone in the cluster. This script will make each drone move according to the trajectory flight data read from the UAVsPath.csv file.
[0161] Render each path point, connect adjacent path points with line segments to form the drone's flight path, and dynamically draw a smooth flight path based on the order of the path points, making the flight path visually apparent (e.g., Figure 4 (as shown);
[0162] During the simulation, Unity3D will display the flight paths of multiple drones in real time. By combining the drone dynamics model and dynamically updating the displayed content, it ensures that the flight trajectory of the drone swarm is displayed synchronously with the actual movement process.
[0163] S8: Configure the camera of each drone to obtain multi-angle real-time perspective information of the swarm flight, including the following steps:
[0164] Configure a virtual camera for each drone, write C# scripts to attach the camera to the drone, and manage the camera through Unity3D's virtual camera system, synchronizing it with the drone's position and orientation;
[0165] During flight, each drone's camera continuously captures real-time perspective information and transmits this perspective data to the Unity3D engine for viewing via Display.
[0166] Different flight perspectives can be switched in real time as needed to view the flight dynamics of each drone (e.g., ...). Figure 5 As shown in the figure, the flight path and relative position of the entire cluster can be observed at the same time.
[0167] The present invention provides a visualization simulation method for the flight trajectory of UAV swarms based on Unity3D. By integrating the improved DACPO algorithm, cubic spline interpolation method and real-time rendering technology, it can dynamically display the flight process and collaborative behavior of multiple UAVs while ensuring simulation accuracy, thus meeting the high precision and high real-time requirements of practical applications.
[0168] It should be noted that the purpose of disclosing the embodiments is to help further understand the present invention. However, those skilled in the art will understand that various substitutions and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the content disclosed in the embodiments, and the scope of protection of the present invention is defined by the claims.
Claims
1. A method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D, characterized in that, include: S1: Create the terrain and flight environment required for swarm flight using the Unity3D platform; S2: Export the terrain data and construct the Terrain.csv terrain database; S3: Design a kinematic model of a drone for swarm control and integrate it into the Unity3D virtual environment; S4: Based on the improved DACPO 3D path planning algorithm, the optimal flight path points are planned for each UAV in the cluster; S4 specifically includes: Define the objective function and construct the search space, which includes the cluster. Each drone requires an optimized number of nodes. Each node uses Cartesian coordinates in triplets. Description, in which, The index is for nodes, and each node contains 3 degrees of freedom, therefore the overall optimization dimension is... ; Define decision vector ,in, The decision variables, including all drones and all nodes, are arranged sequentially. Define the upper and lower bounds of the search space as vectors. and Let and represent the lower and upper bounds of each decision variable, respectively. During the planning process, any decision variable exceeding these bounds must be modified or truncated to . and between; Initialize the parameters of the DACPO algorithm, including population size. Maximum number of iterations Each dimension lower bound and the Upper Realm Problem Dimension and fitness function handle ; Generate the initial population matrix within the defined search space. , among which each individual Through formula generate; in, It is the first Individuals The position of the dimension It is the first The path of each individual includes There are three-dimensional coordinate points, and the path dimension is... , They are the first On the path of each individual Each node , , The coordinates of the axis; ; Assess the fitness value of each individual. , among which each individual fitness This is the total cost of the path, and the specific calculation formula is as follows; ; in, These are the weighting coefficients for each cost. Including path length cost Obstacle avoidance costs High cost and the cost of turning corners ; Determine the global optimal solution and its fitness value ,in, Index the individual with the lowest fitness value; Record the local optimal solution for each individual. ; Enter the optimization loop and continue iterating until the specified number of iterations is reached. Exceed Each iteration includes generating random numbers. Control search behavior for each individual Generate a random vector that controls whether it enters the exploration phase. ; ; An individual enters either the exploration or development phase based on probability conditions. If it enters the exploration phase, it randomly selects either the first or second defense mechanism and applies the corresponding strategy to update its position. ; ; in, This represents a relatively good individual in the current population or a globally optimal solution. This represents a poor individual or a locally optimal solution in the current population. It represents a dynamic perturbation based on a random factor; If the development phase begins, then temporary parameters are calculated. and random vectors And through the formula The third or fourth defense mechanism is applied to update the individual's location, where A bias term that is a small constant; Perform boundary checks on the updated locations to ensure that each location component is within bounds. Stay and If it exceeds the range, then use the formula. Reassign; Recalculate fitness value and when the conditions are met Update the global optimal solution. and its fitness value ,in, ; Dynamically adjust population size ,in, In the formula ,and ; Record the current global optimal fitness value To convergence curve ; When the number of iterations Exceed When the time is reached, terminate the optimization loop and output the global optimal solution. and its fitness value As the optimal flight path for drone swarms; S5: The flight paths of the cluster are smoothly fitted by cubic spline interpolation to obtain a coordinated cluster flight path. S6: Merge the optimized trajectory data and generate a UAVsPath.csv file containing cluster trajectory information; S7: Unity3D reads the UAVsPath.csv file, parses it, and renders a real-time visualization of the cluster's coordinated flight. S8: Configure a camera on each drone to obtain multi-angle real-time perspective information of the swarm flight.
2. The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D according to claim 1, characterized in that: S1 specifically includes: Create a terrain object in the Unity3D platform and attach a C# script for terrain generation to the terrain object, using a noise function to generate random terrain undulations; In Unity3D, threat zones are defined, using cylindrical and spherical regions to simulate the threat zones that a drone swarm may face during flight. Define the boundaries and restrictions of the flight area to ensure that the drone swarm flies within the predetermined spatial range.
3. The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D according to claim 1, characterized in that: S2 specifically includes: The generated terrain is sampled using a custom C# script to extract its height and corresponding XY plane coordinates. The sampled terrain data is organized into a CSV file, with each record containing the X coordinate, Y coordinate and the corresponding Z height value, to ensure that changes in terrain height can be accurately reflected. Name the exported terrain data Terrain.csv and store it in the Assets folder of your Unity3D project.
4. The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D according to claim 1, characterized in that: S3 specifically includes: Import the FBX format drone model suitable for Unity3D and build the 3D appearance of each drone. The model includes the body, propellers, sensors and exterior paint. Design a kinematic model for UAVs suitable for swarm control to calculate the displacement, velocity, and acceleration of the UAVs; Based on the UAV trajectory coordinate information, calculate the heading angle, pitch angle, and roll angle to describe the UAV's flight attitude and heading changes; By binding the UAV kinematic model to the Unity3D physics engine, the UAV model's response to mechanical changes during simulation can be realized.
5. The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D according to claim 1, characterized in that: S5 specifically includes: After obtaining the globally optimal flight trajectory, the discrete waypoints of each UAV are sampled and the three-dimensional coordinate sequence of the UAV is recorded. ; in, Indicates the first A drone, The number of nodes; The sequence is parameterized, and the Euclidean distance between any two adjacent nodes is defined as: ; in, ; Calculate cumulative distance ,in, Thus, track parameters are established. The correspondence between the node sequences; For each coordinate axis , construct based on parameters cubic spline interpolation function , , Each spline segment Within, the spline function is represented as: ; in, The spline coefficients are obtained by solving the problem based on the above conditions. The optimized trajectory must meet flight altitude restrictions: ; in, This represents the cumulative total distance. The optimized cubic spline function parameters For each drone Save the data to form the final trajectory dataset. .
6. The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D according to claim 1, characterized in that: S6 specifically includes: After completing trajectory optimization, the optimized path points of each drone are stored in a readable and writable array; Definition includes A structure array of fields Each field ( Save the corresponding number The flight path data of the drone, including the location coordinates of each path point. ; Use a data export tool to export the structure array. Export as a CSV file, with the coordinates of all path points for each drone arranged by column header. Arrange them sequentially to generate the file UAVsPath.csv; Each line records the coordinates of a path point, such as For the first Drone at the waypoint 3D coordinates; Place the UAVsPath.csv file in the Assets\Drone folder of your Unity3D project.
7. The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D according to claim 1, characterized in that: S7 includes the following steps: In the Unity3D environment, first read the 3D position coordinates of each path point for each drone from the generated UAVsPath.csv file. These waypoints represent the specific locations of the drone during its flight; The data in the UAVsPath.csv file is parsed, the path points of each drone are extracted in sequence, and the 3D coordinates of each path point are extracted. Convert it into a coordinate format that can be recognized in Unity3D; Write a C# script and attach it to each drone in the cluster. This script will make each drone move according to the trajectory flight data read from the UAVsPath.csv file. Render each path point, connect adjacent path points with line segments to form the drone's flight path, and dynamically draw a smooth flight path according to the order of the path points, so that the flight path can be visualized. During the simulation, Unity3D displays the flight paths of multiple drones in real time. By combining the drone dynamics model and dynamically updating the displayed content, it ensures that the flight trajectory of the drone swarm is displayed synchronously with the actual movement process.
8. The method for visualizing and simulating the flight trajectory of a drone swarm based on Unity3D according to claim 1, characterized in that: S8 includes the following steps: Configure a virtual camera for each drone, write C# scripts to attach the camera to the drone, and manage the camera through Unity3D's virtual camera system, synchronizing it with the drone's position and orientation; During flight, each drone's camera continuously captures real-time perspective information and transmits this perspective data to the Unity3D engine; Different flight perspectives can be switched in real time as needed to view the flight dynamics of each drone and observe the flight path and relative position of the entire cluster.
Citation Information
Patent Citations
Unity3D-based quad-rotor unmanned aerial vehicle city simulation method
CN112034733A
Real-time visualization method for trajectory motion of quad-rotor unmanned aerial vehicle based on Unity3D
CN117010276A