Unmanned aerial vehicle cluster flight path visual simulation method based on Unity3D
By integrating the improved DACPO algorithm and cubic spline interpolation method on the Unity3D platform, combined with real-time rendering technology, the shortcomings of the drone cluster trajectory simulation technology in path planning, flight coordination and perspective switching are solved, and high-precision and high-reality visual simulation of the drone cluster flight trajectory is achieved.
Patent Information
- Application Number
- CN202510169152.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2045-02-17
AI Technical Summary
The existing drone cluster trajectory simulation technology has shortcomings in dynamic path planning, flight coordination and perspective switching, and it is difficult to achieve high-precision and high-reality simulation results.
The Unity3D-based visual simulation method of drone cluster flight trajectory is adopted, and the improved DACPO algorithm, cubic spline interpolation method and real-time rendering technology are integrated to dynamically display the flight process and coordinated behavior of multiple drones.
It significantly improves the smoothness and coordination of cluster flight, improves the efficiency of flight control and mission verification, realizes multi-angle perspective display, and enhances the safety and operability of the flight process.
Smart Images

Figure CN120044813A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of unmanned aerial vehicle cluster simulation visualization, and in particular relates to a method for visualizing the flight trajectory of an unmanned aerial vehicle cluster based on Unity3D. Background Art
[0002] With the rapid development of UAV swarm technology, its applications in military reconnaissance, disaster relief, environmental monitoring and other fields are increasing. The flight trajectory of UAV swarms is usually more complex, involving path planning, dynamic obstacle avoidance, collaborative control and other aspects. 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] As a widely used 3D game engine, Unity3D provides effective technical support for the visualization of drone cluster trajectories with its powerful modeling, real-time rendering and physical simulation capabilities. Through simulation with Unity3D, not only can the dynamic display of flight paths, postures and cluster behaviors be achieved, but also its high scalability and interactivity can be used to meet the simulation requirements of multiple scenes and multiple tasks, making it an important tool for drone cluster 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 UAV cluster 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 method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D, so as to solve the deficiencies of existing drone cluster trajectory simulation technology in terms of dynamic path planning, flight coordination, and perspective switching, and to improve the trajectory optimization accuracy and visualization effect during cluster flight simulation. The present invention integrates an improved DACPO algorithm, a cubic spline interpolation method, and real-time rendering technology, and can dynamically display the flight process and collaborative behavior of multiple drones while ensuring simulation accuracy, thus meeting the high-precision and high-real-time requirements in practical applications.
[0006] The present invention provides a method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D, comprising:
[0007] S1: Create the terrain and flight environment required for cluster flight through the Unity3D platform;
[0008] S2: Export the terrain data and construct the Terrain.csv terrain database;
[0009] S3: Design the kinematic model of swarm-controlled drones and integrate it into the Unity3D virtual environment;
[0010] S4: Based on the improved DACPO three-dimensional path planning algorithm, the optimal flight track points are planned for each UAV in the cluster;
[0011] S5: Smooth fitting of cluster track points is performed through cubic spline interpolation to obtain a coordinated cluster flight path;
[0012] S6: Merge the optimized trajectory data to generate the UAVsPath.csv file containing cluster trajectory information;
[0013] S7: Unity3D reads the UAVsPath.csv file, parses it and renders the visualization of the cluster collaborative flight in real time;
[0014] S8: Configure the camera of each drone to obtain multi-angle real-time viewing information of cluster flight.
[0015] Preferably, S1 specifically includes:
[0016] Create a terrain object in the Unity3D platform, attach the C# script for terrain generation to the terrain object, and use the noise function to generate random terrain undulations;
[0017] Divide the threat area in Unity3D, and use cylindrical and spherical areas to simulate the threat areas that drone clusters may face during flight;
[0018] Define the boundaries and flight restrictions of the flight area to ensure that the drone cluster flies within the predetermined space.
[0019] Further preferably, S2 specifically includes:
[0020] The generated terrain is sampled through a custom C# script to extract the terrain height value and the corresponding XY plane coordinates;
[0021] The sampled terrain data is organized into a CSV file, where each record contains the X coordinate, Y coordinate and the corresponding Z height value to ensure that the height changes of the terrain can be accurately reflected;
[0022] Name the exported terrain data Terrain.csv and store it in the Assets folder of the Unity3D project.
[0023] Further preferably, S3 specifically includes:
[0024] Import drone models in fbx format suitable for Unity3D and build the three-dimensional appearance of each drone, including the body, propellers, sensors and exterior paint;
[0025] Design a UAV kinematic model suitable for swarm control to calculate the displacement, velocity and acceleration of the UAV;
[0026] According to the coordinate information of the drone trajectory, the heading angle, pitch angle and roll angle are calculated to describe the flight attitude and heading change of the drone;
[0027] The UAV kinematic model is bound to the Unity3D physics engine to realize the response of the UAV model to mechanical changes during the simulation.
[0028] Further preferably, S4 specifically includes:
[0029] Define the objective function and construct the search space. The cluster contains N drones. Each drone needs to optimize the number of nodes n. Each node is represented by a triple Cartesian coordinate (x j ,y j , z j ), where j is the node index and each node contains 3 degrees of freedom, so the overall optimization dimension is D = 3 × n × N;
[0030] Defining the decision vector Among them, X contains the decision variables of all drones and all nodes, arranged in order;
[0031] Set the search space upper and lower bounds to vectors and Respectively represent the lower and upper bounds of each decision variable. During the planning process, any decision variable exceeding this range needs to be corrected or truncated to between lb and ub;
[0032] Initialize the parameters of the DACPO algorithm, including the population size P and the maximum number of iterations T max , the lower bound lb for each dimension j j and upper bound ub j , problem dimension D and fitness function handle f;
[0033] Generate an initial population matrix within the defined search space Among them, each individual X i By formula X i,j =ib j +rand×(ub j -lb j )generate;
[0034] Among them, X i,j is the position of the ith individual in the jth dimension, Xi is the path of the ith individual, which contains n three-dimensional coordinate points. The dimension of the path is 3n, x ij ,y ij , z ij are the x-, y-, and z-axis coordinates of the j-th node on the ith individual path, respectively;
[0035] X i =[x i1 ,y i1 , z i1 , x i2 ,y i2 , z i2 , …, x in ,y in , z in ];
[0036] Evaluate the fitness value of each individual i =f(X i ), where each individual X i The fitness f(X i ) is the total cost of the path, and the specific calculation formula is as follows;
[0037] f(X i )=w 1 L(X i )+w 2 C o (X i )+w 3 C h (X i )+w 4 C t (X i );
[0038] Among them, w 1 , w 2 , w 3 , w 4 is the weight coefficient of each cost, f(X i ) includes the path length cost L(X i ), obstacle avoidance cost C o (X i ), height cost C h (X i ) and the corner cost C t (X i );
[0039] Determine the global optimal solution Its fitness value G f =min{fitness 1 ,..., fitness P}, where i * is the index of the individual with the smallest fitness value;
[0040] Record each individual's local optimal solution Xp i =X i ;
[0041] Enter the optimization loop and continue iterating until the number of iterations t exceeds T max , where each iteration includes generating a random number 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] According to the probability condition, the individual enters the exploration phase or the development phase. If it enters the exploration phase, it randomly selects the first defense mechanism or the second defense mechanism and applies the corresponding strategy to update the 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 represents a better individual or a global optimal solution in the current population, X n represents a poor individual or a local optimal solution in the current population, rand×(X m -X n ) represents a dynamic disturbance based on a random factor;
[0046] If entering the development phase, calculate temporary parameters and random vector U2, and by formula X i =G s +(α×(1-r2)+r2)×(U2 j ×G s -X i )-S applies the third defense mechanism or the fourth defense mechanism to update the individual position, where S is a small constant bias term;
[0047] Perform bounds checking on the updated position to ensure that each position component X i,j Keep in lb j andub j If it exceeds, the formula X i,j =lb j+rand×(ub j -lb j ) reassign;
[0048] Recalculate the fitness value fitness i =f(X i ), and meet the condition fitness i ≤G f When the global optimal solution G is updated s Its fitness value G f , where G s =X i , G f =fitness i ;
[0049] Dynamically adjust the population size P, where Where 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 optimization cycle is terminated and the global optimal solution G is output s Its fitness value G f As the optimal flight trajectory for drone swarms.
[0052] Further preferably, S5 specifically includes:
[0053] After obtaining the global optimal flight trajectory, node sampling is performed on the discrete track points of each UAV 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] Among them, i represents the i-th UAV, j is the number of nodes;
[0056] The sequence is parameterized, and the Euclidean distance between every two adjacent nodes is:
[0057]
[0058] in,
[0059] Calculate the cumulative distance Among them, s i,1 =0, thereby establishing the corresponding relationship between the track 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 ], the spline function is expressed 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} is the spline coefficient, which is solved by the above conditions;
[0065] The optimized trajectory must meet the flight altitude restrictions:
[0066]
[0067] Among them, S i,n =s i,n is 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}Save each drone i to form the final trajectory data set
[0069] Further preferably, S6 specifically includes:
[0070] After completing trajectory optimization, save the optimized path points of each drone in a readable and writable array;
[0071] Define a structure array A containing N fields = {A 1 , A2, ..., A N}, where each field A i (i=1, 2, ..., N) stores the flight path data information corresponding to the i-th UAV. The data of each path point includes the position coordinates (x i,j ,y i,j , z i,j );
[0072] Use the data export tool to export the structure array A into a CSV file format. Click the column header x to display the coordinates of all the path points of each drone. 1 ,y 1 , z 1 , x 2 ,y 2 , z 2 , ..., x j ,y j , z j Arrange them in sequence to generate the file UAVsPath.csv;
[0073] Each line records the coordinate information of a path point, such as (x i,j ,y i,j , z i,j ) is the three-dimensional coordinate of the i-th UAV at path point j;
[0074] Place the UAVsPath.csv file in the Unity3D project's Assets\Drone folder.
[0075] Further preferably, S7 comprises the following steps:
[0076] In the Unity3D environment, first read the 3D position coordinates (x i,j ,y i,j , z i,j ), these waypoints represent the specific location of the drone during the flight;
[0077] Parse the data in the UAVsPath.csv file, extract the path points of each drone in order, and calculate the three-dimensional coordinates (x i,j ,y i,j , z i,j ) into a coordinate format that can be recognized in Unity3D;
[0078] Write a C# script and mount it on each drone in the cluster. This script is used to make each drone move according to the trajectory flight data read from the UAVsPath.csv file;
[0079] Render each path point and use line segments to connect adjacent path points to form the flight trajectory of the drone. According to the order of the path points, a smooth flight line is dynamically drawn to visualize the flight trajectory.
[0080] During the simulation, Unity3D displays the flight paths of multiple drones in real time. Combined with the drone dynamics model, it dynamically updates the display content to ensure that the flight trajectory of the drone cluster is displayed synchronously with the actual movement process.
[0081] Further preferably, S8 comprises the following steps:
[0082] Configure a virtual camera for each drone, write a C# script, and attach the camera to the drone. The camera is managed by Unity3D's virtual camera system and synchronized with the drone's position and orientation.
[0083] During the flight, the camera of each drone continuously captures real-time perspective information and transmits this perspective data to the Unity3D engine;
[0084] Switch between different flight perspectives in real time as needed to view the flight dynamics of each drone, while observing the flight path and relative position of the entire cluster.
[0085] The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D provided by the present 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 the UAV cluster can be effectively optimized, solving the problems of path discontinuity and sharp turns in the coordinated flight of multiple UAVs, and significantly improving the smoothness and coordination of cluster flight;
[0087] 2. Through the powerful rendering and physical simulation capabilities of the Unity3D platform, the present invention can display the flight trajectory and dynamic behavior of the drone cluster 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. The present invention configures a virtual camera for each drone to achieve multi-angle viewing display of cluster flight, which can help users monitor the flight process more comprehensively and improve the safety and operability during the flight. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0090] Figure 1 It is a flow chart of a method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D provided by the present invention;
[0091] Figure 2 A simulation environment diagram created for the present invention;
[0092] Figure 3 DACPO algorithm flow chart of the present invention;
[0093] Figure 4 This is a visualization effect diagram of the flight trajectory of the drone cluster of the present invention;
[0094] Figure 5 This is a visualization effect diagram of the UAV cluster flight perspective of the present invention. DETAILED DESCRIPTION
[0095] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in order to avoid blurring the present invention due to unnecessary details, only the processing steps closely related to the scheme of the present invention are shown in the accompanying drawings, and other details that are not closely related to the present invention are omitted.
[0096] like Figure 1As shown, the present invention provides a method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D, comprising the following steps:
[0097] S1: Use the Unity3D platform to create the terrain and flight environment required for cluster flight (such as Figure 2 ), including:
[0098] Create a terrain object in the Unity3D platform, attach the C# script for terrain generation to the terrain object, and use the noise function to generate random terrain undulations;
[0099] Divide the threat area in Unity3D, and use cylindrical and spherical areas to simulate the threat areas that drone clusters may face during flight;
[0100] Define the boundaries and flight restrictions of the flight area to ensure that the drone cluster flies within the predetermined space;
[0101] S2: Export the terrain data and construct the Terrain.csv terrain database, which specifically includes:
[0102] The generated terrain is sampled through a custom C# script to extract the terrain height value and the corresponding XY plane coordinates;
[0103] The sampled terrain data is organized into a CSV file, where each record contains the X coordinate, Y coordinate and the corresponding Z height value to ensure that the height changes of the terrain can be accurately reflected;
[0104] Name the exported terrain data Terrain.csv and store it in the Unity3D project Assets folder;
[0105] S3: Design the kinematic model of the swarm-controlled drone and integrate it into the Unity3D virtual environment, including:
[0106] Import drone models in fbx format suitable for Unity3D and build the three-dimensional appearance of each drone, including the body, propellers, sensors and exterior paint;
[0107] Design a kinematic model of drones suitable for cluster control, covering parameters such as position and velocity, to calculate the displacement, velocity and acceleration of drones;
[0108] According to the coordinate information of the drone trajectory, the heading angle, pitch angle and roll angle are accurately calculated to describe the flight attitude and heading changes of the drone;
[0109] Bind the UAV kinematic model to the Unity3D physics engine to achieve the UAV model's response to mechanical changes during the simulation process, ensuring the authenticity of the simulation effect;
[0110] S4: Based on the improved DACPO 3D path planning algorithm, the optimal flight path points are planned for each UAV in the cluster, including:
[0111] Define the objective function and construct the search space. The cluster contains N drones. Each drone needs to optimize the number of nodes n. Each node is represented by a triple Cartesian coordinate (x j ,y i , z j ), where j is the node index and each node contains 3 degrees of freedom, so the overall optimization dimension is D = 3 × n × N;
[0112] Defining the decision vector Among them, X contains the decision variables of all drones and all nodes, arranged in order;
[0113] Set the search space upper and lower bounds to vectors and Respectively represent the lower and upper bounds of each decision variable. During the planning process, any decision variable exceeding this range needs to be corrected or truncated to between lb and ub;
[0114] like Figure 3 As shown, the parameters of the DACPO algorithm are initialized, including the population size P, the maximum number of iterations T max , the lower bound lb for each dimension j j and upper bound ub j , problem dimension D and fitness function handle f;
[0115] Generate an initial population matrix within the defined search space Among them, each individual X i By formula X i,j =lb j +rand×(ub j -lb j ) generation to ensure the diversity of the population;
[0116] Among them, X i,j is the position of the ith individual in the jth dimension, X i is the path of the ith individual, which contains n three-dimensional coordinate points. The dimension of the path is 3n, x ij ,y ij , z ij are the x-, y-, and z-axis coordinates of the j-th node on the ith individual path, respectively;
[0117] Xi =[x i1 ,y i1 , z i1 , x i2 ,y i2 , z i2 , …, x in ,y in , z in ];
[0118] Evaluate the fitness value of each individual i =f(X i ), where each individual X i The fitness f(X i ) is the total cost of the path, and the specific calculation formula is as follows;
[0119] f(X i )=w 1 L(X i )+w 2 C o (X i )+w 3 C h (X i )+w 4 C t (X i );
[0120] Among them, w 1 , w 2 , w 3 , w 4 is the weight coefficient of each cost, f(X i ) includes the path length cost L(X i ), obstacle avoidance cost C o (X i ), height cost C h (X i ) and the corner cost C t (X i );
[0121] Determine the global optimal solution Its fitness value G i =min{fitness 1 ,..., fitness P}, where i * is the index of the individual with the smallest fitness value;
[0122] Record each individual's local optimal solution Xp i =X i ;
[0123] Enter the optimization loop and continue iterating until the number of iterations t exceeds T max , where each iteration includes generating a random number 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] According to the probability condition, the individual enters the exploration phase or the development phase. If it enters the exploration phase, it randomly selects the first defense mechanism or the second defense mechanism and applies the corresponding strategy to update the position X. i ;
[0126] X i =U1 j ×X i +(1-U1 j )×(y t +rand×(X m -X n ));
[0127] Among them, X m represents the position of an individual m in the current population, usually a better individual or a global optimal solution, X n represents the n position of an individual in the current population, usually a poor individual or a local optimal solution, rand×(X m -X n ) represents a dynamic disturbance based on a random factor;
[0128] If entering the development phase, calculate temporary parameters and random vector U2, and by formula X i =G s +(α×(1-r2)+r2)×(U2 j ×G s -X i )-S applies the third defense mechanism or the fourth defense mechanism to update the individual position, where S is a small constant bias term;
[0129] Perform bounds checking on the updated position to ensure that each position component X i,j Keep in lb j andub j If it exceeds, the formula X i,j =lb j +rsnd×(ub j -lb j ) reassign;
[0130] Recalculate the fitness value fitness i =f(Xi ), and meet the condition fitness i ≤G f When the global optimal solution G is updated s Its fitness value G f , where G s =X i , G f =fitness i ;
[0131] Dynamically adjust the population size P, where Where 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 optimization cycle is terminated and the global optimal solution G is output s Its fitness value G f As the best flight trajectory for drone swarms;
[0134] S5: Smooth fitting of the cluster's track points is performed through cubic spline interpolation to obtain a coordinated cluster flight path, including:
[0135] After obtaining the global optimal flight trajectory, node sampling is performed on the discrete track points of each UAV 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] Among them, i represents the i-th UAV, j is the number of nodes;
[0138] The sequence is parameterized, and the Euclidean distance between every two adjacent nodes is
[0139]
[0140] in,
[0141] Calculate the cumulative distance Among them, si,1 =0, thereby establishing the corresponding relationship between the track 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 ], the spline function can be expressed as:
[0143] 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
[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} is the spline coefficient, which is solved by the above conditions;
[0147] The optimized trajectory must meet the flight altitude restrictions:
[0148]
[0149] Among them, S i,n =s i,n is 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}Save each drone i to form the final trajectory data set
[0151] S6: Merge the optimized trajectory data to generate UAVsPath containing cluster trajectory information. csv The documents include:
[0152] After completing trajectory optimization, save the optimized path points of each drone in a readable and writable array;
[0153] Define a structure array A containing N fields = {A 1 , A 2 , ..., A N}, where each field A i (i=1, 2, ..., N) stores the flight path data information corresponding to the i-th UAV. The data of each path point includes the position coordinates (x i,j ,y i,j , z i,j );
[0154] Use the data export tool to export the structure array A into a CSV file format. Click the column header x to display the coordinates of all the path points of each drone. 1 ,y 1 , z 1 , x 2 ,y 2 , z 2 , ..., x j ,y i , zj are arranged in sequence to generate the file UAVsPath.csv;
[0155] Each line records the coordinate information of a path point, such as (x i,j ,y i,j , z i,j ) is the three-dimensional coordinate of the i-th UAV at path point j;
[0156] Put the UAVsPath.csv file in the Unity3D project Assets\Drone folder;
[0157] S7: Unity3D reads the UAVsPath.csv file, parses it, and renders the visualization of the cluster cooperative flight in real time, including the following steps:
[0158] In the Unity3D environment, first read the 3D position coordinates (x i ,j,y i ,j,z i ,j),These waypoints represent the specific positions of the UAV during the flight;
[0159] Parse UAVsPath. csv The data in the file is used to extract the path points of each drone in sequence, and the three-dimensional coordinates (x i,j ,y i,j , z i,j ) into a coordinate format that can be recognized in Unity3D;
[0160] Write a C# script and mount it on each drone in the cluster. This script is used to make each drone move according to the trajectory flight data read from the UAVsPath.csv file;
[0161] Render each path point and use line segments to connect adjacent path points to form the flight trajectory of the drone. According to the order of the path points, a smooth flight line is dynamically drawn to visualize the flight trajectory (such as Figure 4 shown);
[0162] During the simulation, Unity3D will display the flight paths of multiple drones in real time. Combined with the drone dynamics model, it will dynamically update the display content to ensure that the flight trajectory of the drone cluster is displayed synchronously with the actual movement process.
[0163] S8: Configure the camera of each drone to obtain multi-angle real-time viewing information of the cluster flight, including the following steps:
[0164] Configure a virtual camera for each drone, write a C# script, and attach the camera to the drone. The camera is managed by Unity3D's virtual camera system and synchronized with the drone's position and orientation.
[0165] During the flight, the camera of each drone will continuously capture real-time perspective information and pass this perspective data to the Unity3D engine for viewing through the Display;
[0166] Switch different flight perspectives in real time according to needs, and view the flight dynamics of each drone through these perspectives (such as Figure 5 ), while observing the flight path and relative position of the entire cluster.
[0167] The Unity3D-based UAV cluster flight trajectory visualization simulation method provided by the present invention can dynamically display the flight process and collaborative behavior of multiple UAVs while ensuring the simulation accuracy, by integrating the improved DACPO algorithm, cubic spline interpolation method and real-time rendering technology, thus meeting the high-precision and high-real-time requirements in practical applications.
[0168] It should be noted that the purpose of publishing the embodiments is to help further understand the present invention, but 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 contents disclosed in the embodiments, and the scope of protection claimed by the present invention shall be subject to the scope defined in the claims.
Claims
1. A method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D, characterized in that: include: S1: Create the terrain and flight environment required for cluster flight through the Unity3D platform; S2: Export the terrain data and construct the Terrain.csv terrain database; S3: Design the kinematic model of swarm-controlled drones and integrate it into the Unity3D virtual environment; S4: Based on the improved DACPO three-dimensional path planning algorithm, the optimal flight track points are planned for each UAV in the cluster; S5: Smooth fitting of cluster track points is performed through cubic spline interpolation to obtain a coordinated cluster flight path; S6: Merge the optimized trajectory data to generate the UAVsPath.csv file containing cluster trajectory information; S7: Unity3D reads the UAVsPath.csv file, parses it and renders the visualization of the cluster collaborative flight in real time; S8: Configure the camera of each drone to obtain multi-angle real-time viewing information of cluster flight.
2. The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D according to claim 1, characterized in that: S1 specifically includes: Create a terrain object in the Unity3D platform, attach the C# script for terrain generation to the terrain object, and use the noise function to generate random terrain undulations; Divide the threat area in Unity3D, and use cylindrical and spherical areas to simulate the threat areas that drone clusters may face during flight; Define the boundaries and flight restrictions of the flight area to ensure that the drone cluster flies within the predetermined space.
3. The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D according to claim 1, characterized in that: S2 specifically includes: The generated terrain is sampled through a custom C# script to extract the terrain height value and the corresponding XY plane coordinates; The sampled terrain data is organized into a CSV file, where each record contains the X coordinate, Y coordinate and the corresponding Z height value to ensure that the height changes of the terrain can be accurately reflected; Name the exported terrain data Terrain.csv and store it in the Assets folder of the Unity3D project.
4. The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D according to claim 1, characterized in that: S3 specifically includes: Import drone models in fbx format suitable for Unity3D and build the three-dimensional appearance of each drone, including the body, propellers, sensors and exterior paint; Design a UAV kinematic model suitable for swarm control to calculate the displacement, velocity and acceleration of the UAV; According to the coordinate information of the drone trajectory, the heading angle, pitch angle and roll angle are calculated to describe the flight attitude and heading change of the drone; The UAV kinematic model is bound to the Unity3D physics engine to realize the response of the UAV model to mechanical changes during the simulation.
5. The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D according to claim 1, characterized in that: S4 specifically includes: Define the objective function and construct the search space. The cluster contains N drones. Each drone needs to optimize the number of nodes n. Each node is represented by a triple Cartesian coordinate (x j ,y j , z j ), where j is the node index and each node contains 3 degrees of freedom, so the overall optimization dimension is D = 3 × n × N; Defining the decision vector Among them, X contains the decision variables of all drones and all nodes, arranged in order; Set the search space upper and lower bounds to vectors and Respectively represent the lower and upper bounds of each decision variable. During the planning process, any decision variable exceeding this range needs to be corrected or truncated to between lb and ub; Initialize the parameters of the DACPO algorithm, including the population size P and the maximum number of iterations T max , the lower bound lb for each dimension j j and upper bound ub j , problem dimension D and fitness function handle f; Generate an initial population matrix within the defined search space Among them, each individual X i By formula X i,j =lb j +rand×(ub j -lb j )generate; Among them, X i,j is the position of the ith individual in the jth dimension, X i is the path of the ith individual, which contains n three-dimensional coordinate points. The dimension of the path is 3n, x ij ,y ij , z ij are the x-, y-, and z-axis coordinates of the j-th node on the ith individual path, respectively; X i =[x i1 ,y i1 ,z i1 ,x i2 ,y i2 ,z i2 ,...,x in ,y in ,z in ]; Evaluate the fitness value of each individual i =f(X i ), where each individual X i The fitness f(X i ) is the total cost of the path, and the specific calculation formula is as follows; f(X i )=w1L(X i )+w2C o (X i )+w3C h (X i )+w4C t (X i ); Among them, w1, w2, w3, w4 are the weight coefficients of each cost, f(X i ) includes the path length cost L(X i ), obstacle avoidance cost C o (X i ), height cost C h (X i ) and the corner cost C t (X i ); Determine the global optimal solution and its fitness value G f =min{fitness1,...,fitness P }, where i * is the index of the individual with the smallest fitness value; Record each individual's local optimal solution Xp i =X i ; Enter the optimization loop and continue iterating until the number of iterations t exceeds T max , where each iteration includes generating a random number r2 to control the search behavior, for each individual X i Generate a random vector U1 that controls whether it enters the exploration phase; According to the probability condition, the individual enters the exploration phase or the development phase. If it enters the exploration phase, it randomly selects the first defense mechanism or the second defense mechanism and applies the corresponding strategy to update the position X. i ; X i =U1 j ×X i +(1-U1 j )×(y t +rand×(X m -X n )); Among them, X m represents a better individual or a global optimal solution in the current population, X n represents a poor individual or a local optimal solution in the current population, rand×(X m -X n ) represents a dynamic disturbance based on a random factor; If entering the development phase, calculate temporary parameters and random vector U2, and by formula X i =G s +(α×(1-r2)+r2)×(U2 j ×G s -X i )-S applies the third defense mechanism or the fourth defense mechanism to update the individual position, where S is a small constant bias term; Perform bounds checking on the updated position to ensure that each position component X i,j Keep in lb j andub j If it exceeds, the formula X i,j =lb j +rand×(ub j -lb j ) reassign; Recalculate the fitness value fitness i =f(X i ), and meet the condition fitness i ≤G f When the global optimal solution G is updated s and its fitness value G f , where G s =X i , G f =fitness i ; Dynamically adjust the population size P, where Where N min =round(0.8×P), and T=2; Record the current global optimal fitness value G f To the convergence curve C(t); When the number of iterations t exceeds T max When , the optimization cycle is terminated and the global optimal solution G is output s and its fitness value G f As the optimal flight trajectory for drone swarms.
6. The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D according to claim 1, characterized in that: S5 specifically includes: After obtaining the global optimal flight trajectory, node sampling is performed on the discrete track points of each UAV and the three-dimensional coordinate sequence of the UAV is recorded; 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; Among them, i represents the i-th UAV, j is the number of nodes; The sequence is parameterized, and the Euclidean distance between every two adjacent nodes is: in, Calculate the cumulative distance Among them, s i,1 =0, thereby establishing the corresponding relationship between the track parameter s and the node sequence; For each coordinate axis x, yz, 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 ], the spline function is expressed as: S i,x (s)=a i,j,x +b i,j,x (s-s i,j )+c i,j,x (s-s i,j ) 2 +d i,j,x (s-s i,j ) 3 S i,y (s)=a i,j,y +b i,j,y (s-s i,j )+c i,j,y (s-s i,j ) 2 +d i,j,y (s-s i,j ) 3 ; S i,z (s)=a i,j,z +b i,j,z (s-s i,j )+c i,j,z (s-s i,j ) 2 +d i,j,z (s-s i,j ) 3 Among them, a i,j,k , b i,j,k , c i,j,k , ,d i,j,k , k∈{x, y, z} is the spline coefficient, which is solved by the above conditions; The optimized trajectory must meet the flight altitude restrictions: z min ≤S i,z (s)≤z max , Among them, S i,n =s i,n is the cumulative total distance; The optimized cubic spline function parameters {a i,j,k , b i,j,k , c i,j,k , d i,j,k }Save each drone i to form the final trajectory data set 7. The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D according to claim 1, characterized in that: S6 specifically includes: After completing trajectory optimization, save the optimized path points of each drone in a readable and writable array; Define a structure array A containing N fields = {A1, A2, ..., A N }Where each field A i (i=1, 2, ..., N) stores the flight path data information corresponding to the i-th UAV. The data of each path point includes the position coordinates (x i,j ,y i,j , z i,j ); Use the data export tool to export the structure array A into a CSV file format, with the coordinates of all the path points of each drone sorted by column headers x1, y1, z1, x2, y2, z2, ..., x j ,y j , z j Arrange them in sequence to generate the file UAVsPath.csv; Each line records the coordinate information of a path point, such as (x i,j ,y i,j , z i,j ) is the three-dimensional coordinate of the i-th UAV at path point j; Place the UAVsPath.csv file in the Unity3D project's Assets\Drone folder.
8. The method for visualizing and simulating the flight trajectory of a drone cluster 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 (x i,j ,y i,j , z i,j ), these waypoints represent the specific location of the drone during the flight; Parse the data in the UAVsPath.csv file, extract the path points of each drone in order, and calculate the three-dimensional coordinates (x i,j ,y i,j , z i,j ) into a coordinate format that can be recognized in Unity3D; Write a C# script and mount it on each drone in the cluster. This script is used to make each drone move according to the trajectory flight data read from the UAVsPath.csv file; Render each path point and use line segments to connect adjacent path points to form the flight trajectory of the drone. According to the order of the path points, a smooth flight line is dynamically drawn to visualize the flight trajectory. During the simulation, Unity3D displays the flight paths of multiple drones in real time. Combined with the drone dynamics model, it dynamically updates the display content to ensure that the flight trajectory of the drone cluster is displayed synchronously with the actual movement process.
9. The method for visualizing and simulating the flight trajectory of a drone cluster based on Unity3D according to claim 1, characterized in that: S8 includes the following steps: Configure a virtual camera for each drone, write a C# script, and attach the camera to the drone. The camera is managed by Unity3D's virtual camera system and synchronized with the drone's position and orientation. During the flight, the camera of each drone continuously captures real-time perspective information and transmits this perspective data to the Unity3D engine; Switch between different flight perspectives in real time as needed to view the flight dynamics of each drone, while observing 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
Law enforcement unmanned aerial vehicle path planning method for countering low-altitude airspace aircraft
CN114879716A
Cooperative attack task allocation method for heterogeneous unmanned aerial vehicle group
CN115829230A
Real-time visualization method for trajectory motion of quad-rotor unmanned aerial vehicle based on Unity3D
CN117010276A
Flight simulation method and device for unmanned aerial vehicle cluster
CN118428052A
Cited By
Partitioning and hierarchical caching-based track point visual rendering method adaptive to localization
CN121658567A