Control method and device of virtual aircraft, storage medium and electronic equipment
By acquiring the status and obstacle data of the virtual aircraft and using neural networks to generate multi-dimensional control commands, the problem of low control efficiency of the virtual aircraft is solved, and more efficient control is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-10-31
- Publication Date
- 2026-06-02
AI Technical Summary
In the process of controlling virtual aircraft, existing technologies require frequent switching of control channels, resulting in low efficiency.
By acquiring flight status data of the virtual aircraft, representation data of virtual target objects, and representation data of virtual obstacles, a flight reference vector is determined using a neural network, and multi-dimensional flight control commands are generated based on this vector to control the virtual aircraft to fly in the virtual scene.
This technology enables virtual aircraft to execute multiple flight control commands simultaneously in a virtual environment, avoiding frequent switching and improving operational efficiency.
Smart Images

Figure CN118012081B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a control method and apparatus, storage medium and electronic device for a virtual aircraft. Background Technology
[0002] In a virtual environment, a virtual aircraft with dynamics simulation capabilities can perform a variety of different flight maneuvers. For example, a helicopter typically has four control channels: throttle, pitch, roll, and turn. The helicopter's flight is controlled by linearly superimposing the four control channels according to the direction or speed input by the user.
[0003] For example, if the user inputs the command to fly 45 degrees to the left and forward, the helicopter needs to hover and, by rotating the control channel, first turn the aircraft 45 degrees to the left to align its direction, then accelerate and lower its nose angle to fly to the target point and complete the flight mission. However, when more complex flight missions arise, it is necessary to divide the mission into multiple stages and frequently switch between the four control channels, performing only one specific action in each stage to finally complete the mission.
[0004] In the above control method, the need to constantly switch control channels and then control the virtual aircraft to perform different actions in stages results in a low efficiency problem in the control process of the virtual aircraft.
[0005] There is currently no effective solution to the above problems. Summary of the Invention
[0006] This application provides a control method and apparatus for a virtual aircraft, a storage medium, and an electronic device to at least solve the technical problem of low efficiency in the control process of a virtual aircraft.
[0007] According to one aspect of the embodiments of this application, a control method for a virtual aircraft is provided, comprising: acquiring flight state data of the virtual aircraft, first representation data of a virtual target object, and second representation data of virtual obstacles, wherein the flight state data is used to represent the current flight state of the virtual aircraft, the first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in a virtual scene, and the second representation data is used to represent the spatial relative relationship between the virtual obstacles and the virtual aircraft in the virtual scene, wherein the virtual target object is the flight target of the virtual aircraft, and the virtual obstacles include obstacles located in front of the virtual aircraft in the virtual scene; determining a flight reference vector based on the flight state data, the first representation data, and the second representation data, wherein the flight reference vector is used to represent the target flight state that the virtual aircraft is expected to achieve; determining multi-dimensional flight control commands for the virtual aircraft based on the flight reference vector and the flight state data, wherein the multi-dimensional flight control commands are used to control the virtual aircraft to fly in order to achieve the desired target flight state; and controlling the virtual aircraft to fly in the virtual scene according to the multi-dimensional flight control commands.
[0008] Optionally, determining the flight reference vector based on the flight state data, the first characterization data, and the second characterization data includes: concatenating the flight state data, the first characterization data, and the second characterization data into a network input vector; and inputting the network input vector into a target neural network to obtain the flight reference vector. The target neural network is used to determine the flight reference vector based on the network input vector and pre-trained target weight parameters. The flight reference vector includes N-dimensional expected translational velocity data and M-dimensional expected angular velocity data, where N is equal to 2, 3, or a positive integer greater than 3, and M is equal to 2, 3, or a positive integer greater than 3.
[0009] Optionally, the above-mentioned inputting the network input vector into the target neural network to obtain the flight reference vector includes: inputting the network input vector into a multi-layer network structure in the target neural network to obtain the flight reference vector, wherein the multi-layer network structure is used to implement the following formula: r = W2*tanh(W1*tanh(W0*x+b0)+b1)+b2, where r represents the flight reference vector, x represents the network input vector, and the pre-trained target weight parameters include the pre-trained matrices W0, W1, W2 and bias vectors b0, b1, b2.
[0010] Optionally, before inputting the above-mentioned network input vectors into the target neural network to obtain the flight reference vectors, the method further includes: obtaining a set of network input sample vectors, wherein each network input sample vector in the set of network input sample vectors is a vector obtained by concatenating the sample flight state data of the virtual aircraft, the first sample representation data of the virtual sample object, and the second sample representation data of the virtual sample obstacle, wherein the sample flight state data is used to represent the sample flight state of the virtual aircraft, the first sample representation data is used to represent the spatial relative relationship between the virtual sample object and the virtual aircraft in the virtual scene, the second sample representation data is used to represent the spatial relative relationship between the virtual sample obstacle and the virtual aircraft in the virtual scene, the virtual sample object is the flight target of the virtual aircraft, and the virtual sample obstacle includes obstacles located in front of the virtual aircraft in the virtual scene. Sample obstacles; a set of network input sample vectors is used to train the neural network to be trained. During the training process, when the value of the target loss function corresponding to the neural network to be trained does not meet the preset convergence condition, the weight parameters to be trained in the neural network to be trained are adjusted; when the value of the target loss function meets the preset convergence condition, the training ends, and the neural network to be trained at the end of training is determined as the target neural network, and the weight parameters to be trained in the neural network to be trained at the end of training are determined as the target weight parameters; whereby the value of the target loss function is determined based on the random exploration vector, the random exploration vector is a vector obtained by sampling the estimated reference vector using a Gaussian distribution, and the estimated reference vector is a reference vector determined by the neural network to be trained based on the input network sample vector and the weight parameters to be trained.
[0011] Optionally, the above-mentioned acquisition of the flight state data of the virtual aircraft includes: acquiring a set of state data of the virtual aircraft in the root coordinate system, wherein the first set of state data includes the altitude of the virtual aircraft above the ground, the roll angle and pitch angle of the virtual aircraft; acquiring a first set of velocity data of the virtual aircraft in the root coordinate system, wherein the first set of velocity data includes the translational velocity of the virtual aircraft in multiple dimensions; acquiring a second set of velocity data of the virtual aircraft in the body coordinate system, wherein the second set of velocity data includes the angular velocity of the virtual aircraft in multiple dimensions; wherein the flight state data includes a set of state data, a first set of velocity data and a second set of velocity data; wherein the origin of the root coordinate system is the projection point of the origin of the body coordinate system onto the ground, the Z-axis of the root coordinate system is parallel to the Z-axis of the world coordinate system, and the X-axis of the root coordinate system is the axis obtained by projecting the X-axis of the body coordinate system onto a direction parallel to the ground.
[0012] Optionally, the above-mentioned acquisition of the first representation data of the virtual target object includes: acquiring the direction vector of the target connection direction in the body coordinate system, wherein the target connection direction is the direction of the connection between the virtual aircraft and the virtual target object; acquiring the target distance between the virtual aircraft and the virtual target object; wherein the first representation data includes the direction vector and the target distance.
[0013] Optionally, the above-mentioned acquisition of the second representation data of the virtual obstacle includes: when the virtual obstacle includes a group of obstacles, acquiring P directional representation data of the virtual obstacle relative to the virtual aircraft, wherein the P directional representation data correspond to P directions respectively, and the directional representation data are used to represent the volume of the obstacle in the corresponding direction or the distance between the obstacle in the corresponding direction and the virtual aircraft. The larger the directional representation data, the larger the volume of the obstacle in the corresponding direction or the closer the distance between the obstacle in the corresponding direction and the virtual aircraft. P is a positive integer greater than or equal to 2.
[0014] Optionally, the above-mentioned acquisition of P directional representation data of virtual obstacles relative to virtual aircraft includes: starting from the origin of the virtual aircraft's body coordinate system, emitting Q segments of rays to the left and right of the X-axis at 90° angles to obtain Q directional distance representation data, where Q is a positive integer greater than or equal to 2, and the distance representation data is used to represent the distance between the obstacle and the virtual aircraft at the corresponding directional location; and determining P directional representation data based on the Q directional distance representation data, where P is less than Q.
[0015] Optionally, the above-mentioned acquisition of the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle includes: acquiring the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle in the current frame of the target game application; the above-mentioned control of the virtual aircraft to fly in the virtual scene according to flight control commands of multiple dimensions includes: controlling the virtual aircraft to fly in the virtual scene in the next frame of the current frame according to flight control commands of multiple dimensions.
[0016] According to another aspect of the embodiments of this application, a control device for a virtual aircraft is also provided, comprising: a first acquisition unit, configured to acquire flight state data of the virtual aircraft, first representation data of a virtual target object, and second representation data of virtual obstacles, wherein the flight state data is used to represent the current flight state of the virtual aircraft, the first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in a virtual scene, and the second representation data is used to represent the spatial relative relationship between the virtual obstacles and the virtual aircraft in a virtual scene, wherein the virtual target object is the flight target of the virtual aircraft, and the virtual obstacles include obstacles located in front of the virtual aircraft in the virtual scene; a first processing unit, configured to determine a flight reference vector based on the flight state data, the first representation data, and the second representation data, wherein the flight reference vector is used to represent the target flight state that the virtual aircraft is expected to achieve; a second processing unit, configured to determine multiple-dimensional flight control commands for the virtual aircraft based on the flight reference vector and the flight state data, wherein the multiple-dimensional flight control commands are used to control the virtual aircraft to fly in order to achieve the desired target flight state; and a control unit, configured to control the virtual aircraft to fly in a virtual scene according to the multiple-dimensional flight control commands.
[0017] Optionally, the first processing unit includes: a first splicing module for splicing flight state data, first representation data, and second representation data into a network input vector; and a first processing module for inputting the network input vector into a target neural network to obtain a flight reference vector, wherein the target neural network is used to determine the flight reference vector based on the network input vector and pre-trained target weight parameters, and the flight reference vector includes N-dimensional expected translational velocity data and M-dimensional expected angular velocity data, where N is equal to 2, 3, or a positive integer greater than 3, and M is equal to 2, 3, or a positive integer greater than 3.
[0018] Optionally, the first processing module includes: a first processing submodule, used to input the network input vector into a multi-layer network structure in the target neural network to obtain a flight reference vector, wherein the multi-layer network structure is used to implement the following formula: r = W2*tanh(W1*tanh(W0*x+b0)+b1)+b2, where r represents the flight reference vector, x represents the network input vector, and the pre-trained target weight parameters include pre-trained matrices W0, W1, W2 and bias vectors b0, b1, b2.
[0019] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the control method of the virtual aircraft described above when it is run.
[0020] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described method.
[0021] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the control method of the virtual aircraft through the computer program.
[0022] Through the embodiments provided in this application, a flight reference vector is determined based on the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle. Then, based on the flight reference vector and the flight status data, multi-dimensional flight control commands for the virtual aircraft are determined, thereby controlling the virtual aircraft to fly in a virtual scene. In other words, by determining the flight reference vector based on the flight status data, the first representation data, and the second representation data, and further determining multi-dimensional flight control commands, the virtual aircraft can simultaneously execute multiple-dimensional flight control commands. This avoids frequent switching of control operations on the virtual aircraft, solves the technical problem of low efficiency in the control process of the virtual aircraft, and achieves the technical effect of improving operational efficiency. Attached Figure Description
[0023] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0024] Figure 1 This is a schematic diagram illustrating an application scenario of an optional virtual aircraft control method according to an embodiment of this application;
[0025] Figure 2 This is a flowchart of an optional virtual aircraft control method according to an embodiment of this application;
[0026] Figure 3 This is a schematic diagram illustrating the spatial relative relationship between an optional virtual obstacle and a virtual aircraft according to an embodiment of this application;
[0027] Figure 4 This is a schematic diagram of an optional virtual aircraft control method according to an embodiment of this application;
[0028] Figure 5 This is a schematic diagram of an optional target neural network training process according to an embodiment of this application;
[0029] Figure 6This is a schematic diagram of the running logic of each frame in an optional game scene according to an embodiment of this application;
[0030] Figure 7 This is a schematic diagram of the encoding process of virtual obstacles from the perspective of an optional virtual aircraft according to an embodiment of this application;
[0031] Figure 8 This is a schematic diagram of the control method for virtual aircraft in related technologies;
[0032] Figure 9 This is a schematic diagram of the structure of an optional virtual flight control device according to an embodiment of this application;
[0033] Figure 10 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation
[0034] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0035] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0036] According to one aspect of the embodiments of this application, a control method for a virtual aircraft is provided. As an optional implementation, the above-described control method for a virtual aircraft can be applied, but is not limited to, to applications such as... Figure 1 The application scenarios shown are as follows. In, for example... Figure 1In the application scenario shown, terminal device 102 can communicate with server 106 via network 104, but is not limited to this. Server 106 can perform operations on database 108, such as write or read data operations. Terminal device 102 may include, but is not limited to, a human-computer interaction screen, a processor, and a memory. The human-computer interaction screen may be used to display the flight status of a virtual aircraft, the movement of a virtual target object, etc., of the target application on terminal device 102. The processor may be used to respond to the human-computer interaction operations, execute corresponding operations, or generate corresponding instructions and send the generated instructions to server 106. The memory is used to store relevant processing data, such as flight status data of the virtual aircraft, first representation data, and second representation data.
[0037] As an optional approach, the following steps in the virtual aircraft control method can be executed on server 106: Step S102: Obtain flight state data of the virtual aircraft, first representation data of the virtual target object, and second representation data of the virtual obstacles, wherein the flight state data is used to represent the current flight state of the virtual aircraft, the first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in the virtual scene, and the second representation data is used to represent the spatial relative relationship between the virtual obstacles and the virtual aircraft in the virtual scene. The virtual target object is the flight target of the virtual aircraft, and the virtual obstacles include obstacles located in front of the virtual aircraft in the virtual scene; Step S104: Determine a flight reference vector based on the flight state data, the first representation data, and the second representation data, wherein the flight reference vector is used to represent the target flight state that the virtual aircraft is expected to achieve; Step S106: Determine multi-dimensional flight control commands for the virtual aircraft based on the flight reference vector and the flight state data, wherein the multi-dimensional flight control commands are used to control the virtual aircraft to fly in order to achieve the desired target flight state; Step S108: Control the virtual aircraft to fly in the virtual scene according to the multi-dimensional flight control commands.
[0038] As an optional example, this embodiment does not limit the execution subject of the above steps S102 to S108. For example, the above steps S102 to S108 can be executed on the terminal device 102 or the server 106, or they can be partially executed on the terminal device 102 and partially executed on the computing server communicating with the server 106.
[0039] By employing the above method, a flight reference vector is determined based on the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacles. Then, based on the flight reference vector and the flight status data, multi-dimensional flight control commands for the virtual aircraft are determined, thereby controlling the virtual aircraft to fly in the virtual scene. In other words, by determining the flight reference vector based on the flight status data, the first representation data, and the second representation data, and further determining multi-dimensional flight control commands, the virtual aircraft can execute multiple dimensions of flight control commands simultaneously. This avoids frequent switching of control operations on the virtual aircraft, solves the technical problem of low efficiency in the control process of virtual aircraft, and achieves the technical effect of improving operational efficiency.
[0040] To address the aforementioned technical problem of low efficiency in the control process of virtual aircraft, this application proposes a control method for virtual aircraft. Figure 2 This is a flowchart of a control method for a virtual aircraft according to an embodiment of this application, the process including the following steps:
[0041] Step S202: Obtain flight status data of the virtual aircraft, first representation data of the virtual target object, and second representation data of the virtual obstacle. The flight status data is used to represent the current flight status of the virtual aircraft. The first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in the virtual scene. The second representation data is used to represent the spatial relative relationship between the virtual obstacle and the virtual aircraft in the virtual scene. The virtual target object is the flight target of the virtual aircraft. The virtual obstacle includes obstacles located in front of the virtual aircraft in the virtual scene.
[0042] Step S204: Determine the flight reference vector based on the flight state data, the first characterization data, and the second characterization data, wherein the flight reference vector is used to characterize the target flight state that the virtual aircraft is expected to achieve;
[0043] In the embodiments of this application, a helicopter in a game scene is used as an example to describe the control method of the above-mentioned virtual aircraft.
[0044] As an optional example, methods for obtaining flight status data of a virtual aircraft, first representation data of a virtual target object, and second representation data of virtual obstacles include:
[0045] Acquire the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle in the current frame of the target game application.
[0046] The flight status data includes, but is not limited to, the helicopter's altitude above the ground, roll angle, and pitch angle in the current frame of the game; the first representation data includes, but is not limited to, the relative positional relationship between the virtual target object and the helicopter, such as the distance between the helicopter and the virtual target object; the second representation data includes, but is not limited to, the relative positional relationship between virtual obstacles and the helicopter, such as... Figure 3 As shown, the distance between the high-rise building and the helicopter, as well as their azimuth information, are displayed. The following will describe in detail, with reference to specific embodiments, the methods for acquiring flight status data, the first characterization data, and the second characterization data.
[0047] In the embodiments of this application, the virtual target object may be, but is not limited to, the target object that the helicopter expects to follow or chase, such as a virtual character that is running away or a stationary helipad.
[0048] like Figure 4 As shown, after acquiring flight status data, first characterization data, and second characterization data, the flight reference vector can be determined. The methods for determining the flight reference vector include:
[0049] The flight status data, the first characterization data, and the second characterization data are concatenated into a network input vector.
[0050] The network input vector is input into the target neural network to obtain the flight reference vector. The target neural network is used to determine the flight reference vector based on the network input vector and the target weight parameters obtained through pre-training. The flight reference vector includes expected translational velocity data in N dimensions and expected angular velocity data in M dimensions. N is equal to 2, 3, or a positive integer greater than 3, and M is equal to 2, 3, or a positive integer greater than 3.
[0051] For example, assuming the flight state data has 9-dimensional state components, the first representation data has 4-dimensional components, and the second representation data has 7-dimensional components, then the concatenated 20-dimensional vector is input into the target neural network. For example, the 20-dimensional vector is input into a three-layer Multi-Layer Perceptron (MLP), and the output of the MLP is the flight reference vector r.
[0052] As an optional implementation, the above method inputs the network input vector into the target neural network to obtain the flight reference vector, including:
[0053] The network input vector is input into the multi-layer network structure in the target neural network to obtain the flight reference vector, wherein the multi-layer network structure is used to implement the following formula (1):
[0054] r=W2*tanh(W1*tanh(W0*x+b0)+b1)+b2 (1)
[0055] Where r represents the flight reference vector, x represents the network input vector, and the pre-trained target weight parameters include pre-trained matrices W0, W1, W2 and bias vectors b0, b1, b2. The training process and adjustment of weight parameters in the multi-layer network structure will be described below with reference to specific embodiments.
[0056] For example, suppose the reference vector r is a 6-dimensional vector, which represents the desired flight state of the helicopter in the next frame. This includes, but is not limited to, the desired 3-dimensional translational velocity. b v x d , b v y d , b v z d and three-dimensional expected angular velocity b w x d , b w y d , b w z d For example, at a certain instant, if the reference vector r1 = (1,0,0,0,0,0), meaning the desired flight direction is... r v x d The aircraft moves forward at a speed of 1; if r2 = (0,0,0,0,0,-1), it is desired that the aircraft hovers at a speed of 1. b w z d Turn left with an angular velocity of -1.
[0057] In this context, the superscript 'w' indicates that the component is relative to the world coordinate system, the superscript 'r' indicates that the component is relative to the root coordinate system, and the superscript 'b' indicates that the component is relative to the aircraft body coordinate system. Specifically, as shown below... Figure 3 As shown.
[0058] It should be noted that the world coordinate system consists of three mutually perpendicular and intersecting coordinate axes: X, Y, and Z. By default, the X-axis points horizontally to the right of the screen, the positive Y-axis points vertically upwards, and the positive Z-axis points perpendicular to the screen plane towards the user. The aircraft coordinate system can be determined, but is not limited to, based on the helicopter's direction of motion and flight attitude. For example, the current flight direction of the helicopter can always be used as the X-axis, and the Y and Z axes, which are perpendicular to it, can be determined based on the X-axis. Specifically, as shown... Figure 3As shown; the root coordinate system refers to a system where, at any given moment, the origin of the body coordinate system is projected onto the ground as the origin of the root coordinate system, the Z-axis of the root coordinate system is parallel to the Z-axis of the world coordinate system, and the X-axis of the root coordinate system is projected onto the ground as the direction parallel to the ground. Therefore, r p z This indicates the altitude of the helicopter above the ground. r n x , r n y These represent the roll angle and pitch angle of the helicopter in the root coordinate system, respectively.
[0059] Obviously, it's easy to understand that helicopters can fly in various angles and directions within the three-dimensional space of a game scene, such as moving along the X-axis, moving along the Y-axis, turning 45 degrees to the left, or flipping 180 degrees. To ensure that the flight reference vector can more accurately represent the helicopter's flight state, it typically requires expected translational velocity data in two or more dimensions, and expected angular velocity data in two or more dimensions.
[0060] Step S206: Based on the flight reference vector and flight state data, determine the multi-dimensional flight control commands for the virtual aircraft. The multi-dimensional flight control commands are used to control the virtual aircraft to achieve the desired target flight state.
[0061] like Figure 4 and Figure 5 As shown, based on the output of the MLP in the above embodiment, the flight reference vector r is obtained. Based on the flight reference vector r and the flight state data, the multi-dimensional flight control commands u of the helicopter are determined.
[0062] Suppose u is a 4-dimensional vector, in its four components, b u x , b u y , b u z These represent the components of the torque exerted by the air on the aircraft along the x, y, and z axes of the body coordinate system; we can also call them roll torque, pitch torque, and yaw torque, respectively; the last component, u... m This represents the lift provided by the air to the helicopter's main propeller, which points in the z-axis direction of the aircraft's coordinate system. The superscript b indicates that this component is relative to the aircraft's coordinate system.
[0063] Step S208: Control the virtual aircraft to fly in the virtual scene according to flight control commands in multiple dimensions.
[0064] like Figure 4 As shown, as an optional example, after obtaining flight control commands u from multiple dimensions, the flight control commands are applied to the helicopter's underlying controller to control the helicopter to fly in the virtual scene. The specific implementation process is as follows:
[0065] The multi-dimensional flight control commands u are passed to the PhysicsX physics engine for physics simulation. For example, the helicopter's underlying controller u = C(x,r) is called. This controller uses the helicopter's current state and reference vector r to calculate the multi-dimensional flight control commands u. Specifically, u can be calculated using, but is not limited to, the following formula (2).
[0066]
[0067] in,
[0068]
[0069]
[0070]
[0071] in, Used to represent target flight status data The first partial derivative with respect to the current flight status data h; r represents the target flight status data, h represents the flight status data corresponding to the helicopter's current flight status, dt represents the interval duration, for example, when dt = 0.0333 seconds, it means that the time interval between each frame of the game is 0.0333 seconds; m is the helicopter mass, I x I y I z Let D and E represent the moments of inertia of the helicopter along the three axes of the fuselage coordinate system, respectively. D = 0.0001 is the translational drag coefficient, and E = 0.00001 is the rotational drag coefficient. b w x , b w y , b w z These represent the angular velocities on the X, Y, and Z axes of the helicopter's body coordinates contained in the flight status data of the current frame of the virtual aircraft. These coefficients can be obtained, but are not limited to, from the helicopter's physics engine.
[0072] Obviously, it is easy to understand that the above-mentioned control method for virtual aircraft is also applicable to the case where there are no virtual obstacles in the virtual scene. In this case, the flight reference vector is determined based on the flight status data and the second characterization data, and flight control commands in multiple dimensions are determined.
[0073] Through the embodiments provided in this application, a flight reference vector is determined based on the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle. Then, based on the flight reference vector and the flight status data, multi-dimensional flight control commands for the virtual aircraft are determined, thereby controlling the virtual aircraft to fly in a virtual scene. In other words, by determining the flight reference vector based on the flight status data, the first representation data, and the second representation data, and further determining multi-dimensional flight control commands, the virtual aircraft can simultaneously execute multiple-dimensional flight control commands. This avoids frequent switching of control operations on the virtual aircraft, solves the technical problem of low efficiency in the control process of the virtual aircraft, and achieves the technical effect of improving operational efficiency.
[0074] As an optional example, before inputting the above network input vector into the target neural network to obtain the flight reference vector, the method further includes:
[0075] A set of network input sample vectors is obtained. Each network input sample vector in the set of network input sample vectors is a vector obtained by concatenating the sample flight state data of the virtual aircraft, the first sample representation data of the virtual sample object, and the second sample representation data of the virtual sample obstacle. The sample flight state data is used to represent the sample flight state of the virtual aircraft. The first sample representation data is used to represent the spatial relative relationship between the virtual sample object and the virtual aircraft in the virtual scene. The second sample representation data is used to represent the spatial relative relationship between the virtual sample obstacle and the virtual aircraft in the virtual scene. The virtual sample object is the flight target of the virtual aircraft. The virtual sample obstacle includes the sample obstacle located in front of the virtual aircraft in the virtual scene.
[0076] The neural network to be trained is trained using a set of network input sample vectors. During the training process, when the value of the target loss function corresponding to the neural network to be trained does not meet the preset convergence condition, the weight parameters to be trained in the neural network to be trained are adjusted. When the value of the target loss function meets the preset convergence condition, the training ends, and the neural network to be trained at the end of the training is determined as the target neural network, and the weight parameters to be trained in the neural network to be trained at the end of the training are determined as the target weight parameters.
[0077] The target loss function is determined based on the random exploration vector, which is a vector obtained by sampling the estimated reference vector using a Gaussian distribution. The estimated reference vector is a reference vector determined by the neural network to be trained based on the input network sample vector and the weight parameters to be trained.
[0078] like Figure 5As shown, suppose a set of input sample vectors are X1, X2, X3, ..., where each input sample vector is a vector obtained by concatenating sample flight state data, first sample representation data and second sample representation data. For example, a 20-dimensional sample vector is obtained by concatenating the components of the 9-dimensional sample flight state vector, the components of the 4-dimensional first sample representation vector and the components of the 7-dimensional second sample representation vector.
[0079] Using the above set of sample vectors, the neural network to be trained is trained, and training stops when the value of the target loss function corresponding to the neural network to be trained meets the preset convergence condition. The value of the target loss function is determined based on the random exploration vector.
[0080] Specifically, we use a random number generator to randomly initialize the weight parameters of the target neural network, and then during the game, we run a process such as... Figure 6 In the loop shown, in each frame of the game, the reinforcement learning algorithm will generate a random exploration on the output r of the target neural network. For example, it will use the following formula (3) to sample the reference vector r using a Gaussian distribution:
[0081] Δr~N(0,1) (3)
[0082] Using r+Δr instead of the reference vector r to enter the helicopter's underlying dynamics controller for subsequent processing, the loss function of the current frame's flight state data can be defined as the following formula (4):
[0083] Loss = R * (Δr) 2 (4)
[0084] Where R is the value of the reinforcement learning reward function, and its expression is:
[0085] R=0.8*exp(-0.001*TargetDistance2)+0.2*exp(-0.1*ObstableDistance2)
[0086] Where TargetDistance is the horizontal distance between the machine's coordinates and the target point, and ObstableDistance is the horizontal distance between the machine's coordinates and the nearest obstacle, which can be determined by... Figure 7 The barcode shown in (b) is obtained by taking the minimum distance during the acquisition process.
[0087] It should be noted that after inputting the current flight state from the current frame of the game screen into the neural network model and obtaining the output flight reference vector r, r+Δr is used as the new flight reference vector r'. Using the above formula (2), combined with the new flight reference vector r', the multi-dimensional flight control command u is calculated. Then, in the next frame after the current frame, the helicopter is controlled to reach the target flight state. The target flight state is then used as the model input for the next training, and so on, generating a set of multi-frame flight state data. In other words, only the helicopter's flight state data from the current frame of the game screen needs to be used as the input to the neural network model to generate a set of multi-frame flight state data and train it to obtain the expected flight reference vector r.
[0088] During the training of a neural network model, by collecting the model input x, model output r, Δr, and loss for each frame, reinforcement learning algorithms can be used to estimate the gradient of the loss with respect to the weight parameters W0, W1, W2, b0, b1, and b2 of the neural network to be trained. Using gradient descent, the weights of the neural network to be trained can be continuously updated, ultimately resulting in a well-performing target neural network capable of quickly chasing a target point (e.g., a virtual target object) while skillfully avoiding obstacles such as tall buildings.
[0089] After model training is complete, the determined weight parameters of the target neural network will continue to be used as follows: Figure 6 The flowchart shown illustrates how to control the helicopter's flight status in an actual game scenario.
[0090] Obviously, adjusting the weight parameters in the neural network to be trained when the target loss function does not meet the preset convergence conditions is just one example and is not a limitation. For example, other network structure parameters in the neural network can also be adjusted.
[0091] By employing the above method, and utilizing reinforcement learning algorithms to sample the reference vector r output by the target neural network using a Gaussian distribution, more of the random explorations that improve the reinforcement learning reward function value R are retained, thereby increasing the reinforcement learning reward function value and achieving the technical effect of improving the accuracy of the target neural network.
[0092] As an optional example, the above-mentioned acquisition of flight status data of the virtual aircraft includes:
[0093] Obtain a set of state data of the virtual aircraft in the root coordinate system. The first set of state data includes the height of the virtual aircraft above the ground, the roll angle and pitch angle of the virtual aircraft.
[0094] Obtain the first set of velocity data of the virtual aircraft in the root coordinate system, wherein the first set of velocity data includes the translational velocity of the virtual aircraft in multiple dimensions;
[0095] Obtain the second set of velocity data of the virtual aircraft in the body coordinate system, wherein the second set of velocity data includes the angular velocity of the virtual aircraft in multiple dimensions;
[0096] The flight status data includes a set of status data, a first set of speed data, and a second set of speed data.
[0097] In this system, the origin of the root coordinate system is the projection point of the origin of the body coordinate system onto the ground. The Z-axis of the root coordinate system is parallel to the Z-axis of the world coordinate system, and the X-axis of the root coordinate system is the axis obtained by projecting the X-axis of the body coordinate system onto a direction parallel to the ground.
[0098] In the game environment, by executing control commands, helicopters can navigate between virtual buildings (e.g., city skyscrapers) and fly to a predetermined target location, such as a helipad. It's easy to understand that flight status data includes, but is not limited to, the helicopter's motion and attitude in each frame of the game, typically represented by a 9-dimensional state vector. This 9-dimensional state vector includes, but is not limited to, the following: r p z , r n x , r n y , r v x , r v y , r v z , b w x , b w y , b w z The letter in the superscript of each component indicates the reference coordinate system of that component.
[0099] Based on the descriptions of the world coordinate system, root coordinate system, and body coordinate system in the above embodiments, it can be seen that... r p z This indicates the altitude of the helicopter above the ground. r n x , r n y These represent the roll angle and pitch angle of the helicopter in the root coordinate system, respectively. The superscript 'w' indicates that a quantity is relative to the world coordinate system, the superscript 'r' indicates that a quantity is relative to the root coordinate system, and the superscript 'b' indicates that a quantity is relative to the aircraft body coordinate system.
[0100] Therefore, taking a helicopter represented by a single rigid body as an example, of the six degrees of freedom of motion in the world coordinate system, three components exist in the transformation from the world coordinate system to the root coordinate system, leaving only one component. r p z , r n x , r n y These three components exist in the transformation from the root coordinate system to the body coordinate system. The reason for constructing the root coordinate system and only using... r p z , r n x , r n y These three components are used as inputs to the subsequent target neural network because at any given time, the helicopter's control decisions are related to these three components, but not to the other three components (the helicopter's x and y coordinates in the world coordinate system, and its rotation azimuth angle relative to the z-axis).
[0101] Based on the same principle, due to the helicopter's three-dimensional translational velocity r v x , r v y , r v z (with the root coordinate system as the reference frame) and the three-dimensional angular velocity of the helicopter b w x , b w y , b w z (Using the aircraft's coordinate system as a reference frame) is related to the helicopter's control decisions, and therefore, it is also used as part of the input vector for the subsequent target neural network.
[0102] As another alternative example, the acquisition of the first representation data of the virtual target object described above includes:
[0103] Obtain the direction vector of the target connection direction in the body coordinate system, where the target connection direction is the direction of the connection between the virtual aircraft and the virtual target object;
[0104] Obtain the target distance between the virtual aircraft and the virtual target object;
[0105] The first set of representation data includes the direction vector and the target distance.
[0106] As described in the above embodiments, the first characterization data is used to characterize the spatial relative relationship between the virtual target object and the virtual aircraft (helicopter) in the virtual scene. The virtual target object can be, but is not limited to, the target that the helicopter wants to chase, for example... Figure 3As shown, the virtual target object is a target point that the helicopter wants to chase. This target point can be, but is not limited to, a virtual character that is running away or a stationary helipad. In other words, the virtual target object can be a moving or stationary virtual character, virtual building, virtual object, etc.
[0107] Assuming we use 4-dimensional vector components to describe the virtual target object, the line connecting the helicopter to the virtual target object (e.g., ...) Figure 3 The direction of the dashed line (in the diagram) is taken as a unit vector, and the representation of this unit vector in the body coordinate system is... b t x , b t y , b t z The components that make up the 3-dimensional vector, the fourth dimension of the vector component d represents the distance between the virtual target object and the helicopter. The components of the 3-dimensional vector can be, but are not limited to, the components obtained by projecting the above unit vector onto the X, Y, and Z axes of the aircraft coordinate system respectively.
[0108] from Figure 3 It can be seen that by using the components of the above 4-dimensional vector, the spatial relative relationship between the virtual target object and the helicopter can be completely and accurately represented, which helps to control the helicopter to chase the virtual target object in the virtual scene. This includes the spatial positional relationship and spatial distance relationship between the two.
[0109] As another alternative example, the acquisition of the second representation data of the virtual obstacle described above includes:
[0110] When the virtual obstacle includes a set of obstacles, obtain P directional representation data of the virtual obstacle relative to the virtual aircraft. The P directional representation data correspond to P directions, and the directional representation data are used to represent the volume of the obstacle in the corresponding direction or the distance between the obstacle in the corresponding direction and the virtual aircraft. The larger the directional representation data, the larger the volume of the obstacle in the corresponding direction or the closer the distance between the obstacle in the corresponding direction and the virtual aircraft. P is a positive integer greater than or equal to 2.
[0111] As described in the above embodiments, the second characterization data is used to characterize the spatial relative relationship between virtual obstacles and virtual aircraft (helicopters) in the virtual scene, such as... Figure 3 As shown, assuming the virtual obstacle is a tall building obstacle perceived by a helicopter, the tall building obstacle information is described using 7-dimensional vector components. The specific process of determining the components of the 7-dimensional vector is described below with reference to a specific embodiment.
[0112] like Figure 7Figure (a) shows a horizontal cross-sectional view of the tall building obstacle and the helicopter from a top-down perspective. The XY axes in Figure (a) are the XY axes of the root coordinate system, and the height of the cross-section is the current height of the aircraft coordinate system. The squares and circles in Figure (a) represent the cross-section of the tall building obstacle at this height.
[0113] When the tall building obstacle includes a group of obstacles, P azimuth representation data of the tall building obstacle relative to the helicopter are obtained. For example, representation data 1 shows the first tall building located at a 45-degree angle to the left front of the helicopter, representation data 2 shows the second tall building located directly in front of the helicopter, representation data 3 shows the third tall building located at a 45-degree angle to the right rear of the helicopter, and so on. The azimuth representation data is used to represent the volume of the tall building obstacle in the corresponding azimuth or the distance between the tall building obstacle in the corresponding azimuth and the helicopter, etc.
[0114] As an optional example, the above acquisition of P azimuth representation data of virtual obstacles relative to the virtual aircraft includes:
[0115] Starting from the origin of the virtual aircraft's coordinate system, Q segments of rays are emitted to the left and right of the X-axis at 90° angles to the left and right, respectively, to obtain distance representation data in Q directions, where Q is a positive integer greater than or equal to 2. The distance representation data is used to represent the distance between the virtual aircraft and the obstacles in the corresponding directions.
[0116] Based on the distance representation data in Q directions, determine P direction representation data, where P is less than Q.
[0117] In the embodiments of this application, it is assumed that from such Figure 3 Starting from the origin of the machine coordinate system shown, and moving towards... Figure 7 In the diagram (a), Q-segment rays are emitted from 90° to the left and right of the X-axis, where Q = 181.
[0118] (i) Based on 181 rays, distance characterization data in each direction is obtained;
[0119] (ii) Using the following formula (5), and combining the distance representation data between tall buildings and helicopters in various directions, a depth estimation barcode is obtained, such as... Figure 7 The multiple barcodes shown in (b) above.
[0120] I = exp(-d 2 (5)
[0121] Where d represents the distance between the helicopter and the tall building obstacle, I represents the normalized pixel value, 1 represents pure black, 0 represents pure white, the darker the color, the closer the tall building obstacle is to the helicopter, and the lighter the color, the farther the tall building obstacle is from the helicopter.
[0122] (iii) Adopting as Figure 7 The kernels shown in the seven triangular regions in (c) are convolved with the depth estimate C to obtain a 7-dimensional code of P=7. This 7-dimensional code is used to represent the obstacles in front of the helicopter. For example, the larger the value, the larger the volume of the tall buildings in that direction or the closer they are; the smaller the value, the smaller the volume of the tall buildings in that direction or the farther they are. And the smaller the value, the more likely the helicopter will eventually choose to move in that direction.
[0123] It should be noted that the value of P mentioned above is related to the kernel represented by the triangular region participating in the convolution operation. For example, the value of P is equal to the number of triangular regions.
[0124] Using the above method, by performing convolution processing on the distance representation data in Q directions, the situation of virtual obstacles that the helicopter can perceive and that are located directly in front of the helicopter is determined, and the helicopter is controlled to fly in the direction that can avoid the virtual obstacles, ensuring that the helicopter can skillfully avoid the virtual obstacles while also quickly pursuing the target virtual object.
[0125] As an optional example, the above-mentioned flight control commands, which control the virtual aircraft to fly in a virtual scene according to multiple dimensions, include:
[0126] Following multi-dimensional flight control commands, the virtual aircraft is controlled to fly in the virtual scene in the next frame of the current frame.
[0127] like Figure 6 As shown, after obtaining the flight reference vector r through the above embodiment, the current flight state in the current frame of the game screen is input into the target neural network model, and the output flight reference vector r is obtained. Then, r+Δr is used as the new flight reference vector r'. Using the above formula (2), multiple dimensions of flight control commands u are calculated, where u represents multiple dimensions of control commands such as pitch, roll, rotation and lift given by the air to the main propeller.
[0128] In the next frame of the current frame, by executing control commands in multiple dimensions simultaneously, the helicopter can be quickly controlled to fly in the virtual scene according to the target flight state.
[0129] However, in related technologies, the implementation process of virtual aircraft control methods, such as... Figure 8As shown, when a helicopter starts flying forward from a hovering state (Action 1), if a moving skyscraper suddenly appears blocking its path, the helicopter needs to stop moving forward, return to hover, and then begin a special action (Action 2). Afterward, it needs to wait for the special action to stop and the helicopter to return to hover before continuing with the next action. This not only consumes a lot of manpower designing behavior trees (what actions to take under what conditions), but also makes the helicopter's movements very rigid and inefficient.
[0130] For example, when controlling a helicopter to fly to a target position 45 degrees to the left and forward, you need to first turn the helicopter 45 degrees to the left by turning the command while it is hovering. After the direction is aligned, return to hovering, then increase the throttle and adjust the pitch angle to control the helicopter to fly to the desired target position.
[0131] However, the flight control command u obtained through the above embodiments of this application can simultaneously execute control commands for accelerating forward and turning left, avoiding frequent braking, hovering, turning and then accelerating forward before each change of direction of movement, thus achieving the technical effect of improving the operational efficiency of the helicopter.
[0132] Furthermore, because this approach utilizes a data-driven reinforcement learning algorithm, it possesses a degree of versatility, avoiding the need for designing specific behavior tree AIs tailored to different task requirements, as is required in traditional solutions. Therefore, this approach not only shortens the development cycle of helicopter navigation AI in games but also significantly improves navigation performance (motion smoothness, aircraft pursuit speed) compared to manually designed AI.
[0133] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0134] According to another aspect of the embodiments of this application, as follows is also provided Figure 9 The control device for a virtual aircraft shown includes:
[0135] The first acquisition unit 902 is used to acquire flight status data of the virtual aircraft, first representation data of the virtual target object, and second representation data of the virtual obstacle. The flight status data is used to represent the current flight status of the virtual aircraft, the first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in the virtual scene, and the second representation data is used to represent the spatial relative relationship between the virtual obstacle and the virtual aircraft in the virtual scene. The virtual target object is the flight target of the virtual aircraft, and the virtual obstacle includes obstacles located in front of the virtual aircraft in the virtual scene.
[0136] The first processing unit 904 is used to determine a flight reference vector based on flight state data, first characterization data, and second characterization data, wherein the flight reference vector is used to characterize the target flight state that the virtual aircraft is expected to achieve.
[0137] In the embodiments of this application, the virtual target object may be, but is not limited to, the target object that the helicopter expects to follow or chase, such as a virtual character that is running away or a stationary helipad.
[0138] like Figure 4 As shown, after acquiring flight status data, first characterization data, and second characterization data, the flight reference vector can be determined. The methods for determining the flight reference vector include:
[0139] The flight status data, the first characterization data, and the second characterization data are concatenated into a network input vector.
[0140] The network input vector is input into the target neural network to obtain the flight reference vector. The target neural network is used to determine the flight reference vector based on the network input vector and the target weight parameters obtained through pre-training. The flight reference vector includes expected translational velocity data in N dimensions and expected angular velocity data in M dimensions. N is equal to 2, 3, or a positive integer greater than 3, and M is equal to 2, 3, or a positive integer greater than 3.
[0141] For example, assuming the flight state data has 9-dimensional state components, the first representation data has 4-dimensional components, and the second representation data has 7-dimensional components, then the concatenated 20-dimensional vector is input into the target neural network. For example, the 20-dimensional vector is input into a three-layer Multi-Layer Perceptron (MLP), and the output of the MLP is the flight reference vector r.
[0142] The second processing unit 906 is used to determine multi-dimensional flight control commands for the virtual aircraft based on the flight reference vector and flight state data. The multi-dimensional flight control commands are used to control the virtual aircraft to achieve the desired target flight state.
[0143] like Figure 4 and Figure 5 As shown, based on the output of the MLP in the above embodiment, the flight reference vector r is obtained. Based on the flight reference vector r and the flight state data, the multi-dimensional flight control commands u of the helicopter are determined.
[0144] Suppose u is a 4-dimensional vector, in its four components, b u x , b u y , b u z These represent the components of the torque exerted by the air on the aircraft along the x, y, and z axes of the body coordinate system; we can also call them roll torque, pitch torque, and yaw torque, respectively; the last component, u... m This represents the lift provided by the air to the helicopter's main propeller, which points in the z-axis direction of the aircraft's coordinate system. The superscript b indicates that this component is relative to the aircraft's coordinate system.
[0145] The control unit 908 is used to control the virtual aircraft to fly in a virtual scene according to flight control commands in multiple dimensions.
[0146] like Figure 4 As shown, as an optional example, after obtaining flight control commands u from multiple dimensions, the flight control commands are applied to the helicopter's underlying controller to control the helicopter to fly in the virtual scene. The specific implementation process is as follows:
[0147] The flight control commands u of multiple dimensions are given to the PhysicsX physics engine to perform physical simulation. For example, the helicopter's underlying controller u = C(x,r) is called. The controller uses the helicopter's current state and reference vector r to calculate the flight control commands u of multiple dimensions. Specifically, it can be calculated using the above formula (2) and the controller can calculate u. For a detailed description, please refer to the above embodiments. It will not be repeated here.
[0148] Obviously, it is easy to understand that the above-mentioned control method for virtual aircraft is also applicable to the case where there are no virtual obstacles in the virtual scene. In this case, the flight reference vector is determined based on the flight status data and the second characterization data, and flight control commands in multiple dimensions are determined.
[0149] By applying the aforementioned device to determine a flight reference vector based on the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacles, and then determining multi-dimensional flight control commands for the virtual aircraft based on the flight reference vector and the flight status data, the virtual aircraft can be controlled to fly in a virtual scene. In other words, by determining the flight reference vector based on the flight status data, the first representation data, and the second representation data, and further determining multi-dimensional flight control commands, the virtual aircraft can execute multiple dimensions of flight control commands simultaneously. This avoids frequent switching of control operations on the virtual aircraft, solves the technical problem of low efficiency in the control process of virtual aircraft, and achieves the technical effect of improving operational efficiency.
[0150] Optionally, the first processing unit 904 includes:
[0151] The first splicing module is used to splice the flight status data, the first representation data, and the second representation data into a network input vector.
[0152] The first processing module is used to input the network input vector into the target neural network to obtain the flight reference vector. The target neural network is used to determine the flight reference vector based on the network input vector and the pre-trained target weight parameters. The flight reference vector includes N-dimensional expected translational velocity data and M-dimensional expected angular velocity data, where N is equal to 2, 3, or a positive integer greater than 3, and M is equal to 2, 3, or a positive integer greater than 3.
[0153] Optionally, the first processing module mentioned above includes:
[0154] The first processing submodule is used to input the network input vector into the multi-layer network structure in the target neural network to obtain the flight reference vector, wherein the multi-layer network structure is used to implement the following formula:
[0155] r=W2*tanh(W1*tanh(W0*x+b0)+b1)+b2
[0156] Where r represents the flight reference vector, x represents the network input vector, and the pre-trained target weight parameters include the pre-trained matrices W0, W1, W2 and bias vectors b0, b1, b2.
[0157] Optionally, the above-mentioned device further includes:
[0158] The second acquisition unit is used to acquire a set of network input sample vectors. Each network input sample vector in the set of network input sample vectors is a vector obtained by concatenating the sample flight state data of the virtual aircraft, the first sample representation data of the virtual sample object, and the second sample representation data of the virtual sample obstacle. The sample flight state data is used to represent the sample flight state of the virtual aircraft. The first sample representation data is used to represent the spatial relative relationship between the virtual sample object and the virtual aircraft in the virtual scene. The second sample representation data is used to represent the spatial relative relationship between the virtual sample obstacle and the virtual aircraft in the virtual scene. The virtual sample object is the flight target of the virtual aircraft. The virtual sample obstacle includes the sample obstacle located in front of the virtual aircraft in the virtual scene.
[0159] The third processing unit is used to train the neural network to be trained using a set of network input sample vectors. During the training process, when the value of the target loss function corresponding to the neural network to be trained does not meet the preset convergence condition, the weight parameters to be trained in the neural network to be trained are adjusted. When the value of the target loss function meets the preset convergence condition, the training ends, and the neural network to be trained at the end of the training is determined as the target neural network, and the weight parameters to be trained in the neural network to be trained at the end of the training are determined as the target weight parameters.
[0160] The target loss function is determined based on the random exploration vector, which is a vector obtained by sampling the estimated reference vector using a Gaussian distribution. The estimated reference vector is a reference vector determined by the neural network to be trained based on the input network sample vector and the weight parameters to be trained.
[0161] Optionally, the first acquisition unit 902 mentioned above includes:
[0162] The first acquisition module is used to acquire a set of state data of the virtual aircraft in the root coordinate system. The first set of state data includes the height of the virtual aircraft above the ground, the roll angle and pitch angle of the virtual aircraft.
[0163] The second acquisition module is used to acquire the first set of velocity data of the virtual aircraft in the root coordinate system, wherein the first set of velocity data includes the translational velocity of the virtual aircraft in multiple dimensions.
[0164] The third acquisition module is used to acquire the second set of velocity data of the virtual aircraft in the body coordinate system, wherein the second set of velocity data includes the angular velocity of the virtual aircraft in multiple dimensions;
[0165] The flight status data includes a set of status data, a first set of speed data, and a second set of speed data.
[0166] In this system, the origin of the root coordinate system is the projection point of the origin of the body coordinate system onto the ground. The Z-axis of the root coordinate system is parallel to the Z-axis of the world coordinate system, and the X-axis of the root coordinate system is the axis obtained by projecting the X-axis of the body coordinate system onto a direction parallel to the ground.
[0167] Optionally, the first acquisition unit 902 mentioned above includes:
[0168] The fourth acquisition module is used to acquire the direction vector of the target connection direction in the body coordinate system, wherein the target connection direction is the direction of the connection between the virtual aircraft and the virtual target object;
[0169] The fifth acquisition module is used to acquire the target distance between the virtual aircraft and the virtual target object;
[0170] The first set of representation data includes the direction vector and the target distance.
[0171] Optionally, the first acquisition unit 902 mentioned above includes:
[0172] The sixth acquisition module is used to acquire P directional representation data of the virtual obstacle relative to the virtual aircraft when the virtual obstacle includes a group of obstacles. The P directional representation data correspond to P directions, and the directional representation data are used to represent the volume of the obstacle in the corresponding direction or the distance between the obstacle in the corresponding direction and the virtual aircraft. The larger the directional representation data, the larger the volume of the obstacle in the corresponding direction or the closer the distance between the obstacle in the corresponding direction and the virtual aircraft. P is a positive integer greater than or equal to 2.
[0173] Optionally, the sixth acquisition module mentioned above includes:
[0174] The second processing submodule is used to emit Q segments of rays from the origin of the virtual aircraft's body coordinate system to the left and right of the X-axis at 90°, and obtain distance representation data in Q directions, where Q is a positive integer greater than or equal to 2. The distance representation data is used to represent the distance between the virtual aircraft and the obstacles in the corresponding directions.
[0175] Based on the distance representation data in Q directions, determine P direction representation data, where P is less than Q.
[0176] Optionally, the first acquisition unit 902 mentioned above includes:
[0177] The seventh acquisition module is used to acquire the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle in the current frame of the target game application.
[0178] The aforementioned control unit 908 includes:
[0179] The second processing module is used to control the virtual aircraft to fly in the virtual scene in the next frame of the current frame according to flight control commands in multiple dimensions.
[0180] By applying the aforementioned device to determine a flight reference vector based on the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacles, and then determining multi-dimensional flight control commands for the virtual aircraft based on the flight reference vector and the flight status data, the virtual aircraft can be controlled to fly in a virtual scene. In other words, by determining the flight reference vector based on the flight status data, the first representation data, and the second representation data, and further determining multi-dimensional flight control commands, the virtual aircraft can execute multiple dimensions of flight control commands simultaneously. This avoids frequent switching of control operations on the virtual aircraft, solves the technical problem of low efficiency in the control process of virtual aircraft, and achieves the technical effect of improving operational efficiency.
[0181] It should be noted that the embodiments of the control device for the virtual aircraft described here can refer to the embodiments of the control method for the virtual aircraft described above, and will not be repeated here.
[0182] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described control method for a virtual aircraft is also provided. This electronic device may be... Figure 10 The terminal device shown is illustrated in this embodiment, which uses this electronic device as an example of a backend device. Figure 10 As shown, the electronic device includes a memory 1002 and a processor 1004. The memory 1002 stores a computer program, and the processor 1004 is configured to execute the steps of any of the above method embodiments via the computer program.
[0183] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.
[0184] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0185] S1, acquire the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle. The flight status data is used to represent the current flight status of the virtual aircraft. The first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in the virtual scene. The second representation data is used to represent the spatial relative relationship between the virtual obstacle and the virtual aircraft in the virtual scene. The virtual target object is the flight target of the virtual aircraft. The virtual obstacle includes obstacles located in front of the virtual aircraft in the virtual scene.
[0186] S2, determine the flight reference vector based on the flight state data, the first characterization data, and the second characterization data, wherein the flight reference vector is used to characterize the target flight state that the virtual aircraft is expected to achieve;
[0187] S3, based on the flight reference vector and flight state data, determines the multi-dimensional flight control commands for the virtual aircraft. These multi-dimensional flight control commands are used to control the virtual aircraft to achieve the desired target flight state.
[0188] S4 controls the virtual aircraft to fly in a virtual scene according to flight control commands from multiple dimensions.
[0189] Alternatively, as those skilled in the art will understand, Figure 10 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, mobile internet devices (MIDs), PADs, and other target terminals. Figure 10 This does not limit the structure of the aforementioned electronic devices or electronic equipment. For example, electronic devices or electronic equipment may also include components that are more... Figure 10 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 10 The different configurations shown.
[0190] The memory 1002 can be used to store software programs and modules, such as the program instructions / modules corresponding to the virtual flight control method and device in this embodiment. The processor 1004 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, thereby realizing the aforementioned virtual flight control method. The memory 1002 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1002 may further include memory remotely located relative to the processor 1004, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 1002 may be used, but is not limited to, to store flight status data, first characterization data, and second characterization data of the virtual flight. As an example, such as... Figure 10 As shown, the memory 1002 may include, but is not limited to, the first acquisition unit 902, the first processing unit 904, the second processing unit 906, and the control unit 908 of the virtual flight vehicle's control device. Furthermore, it may include, but is not limited to, other module units of the virtual flight vehicle's control device, which will not be elaborated upon in this example.
[0191] Optionally, the transmission device 1006 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 1006 includes a Network Interface Controller (NIC), which can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 1006 is a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0192] In addition, the aforementioned electronic device also includes: a display 1008 for displaying directional information of the target sound; and a connection bus 1010 for connecting the various module components in the aforementioned electronic device.
[0193] In other embodiments, the target terminal or server can be a node in a distributed system, which can be a blockchain system. This blockchain system is formed by connecting multiple nodes through network communication. The nodes can form a peer-to-peer (P2P) network, and any type of computing device, such as a server or terminal, can become a node in the blockchain system by joining this peer-to-peer network.
[0194] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the virtual aircraft control method provided in various optional implementations of the above-described server verification processing, wherein the computer program is configured to execute the steps in any of the above-described method embodiments during runtime.
[0195] Optionally, in this embodiment, the computer-readable storage medium described above may be configured to store a computer program for performing the following steps:
[0196] S1, acquire the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle. The flight status data is used to represent the current flight status of the virtual aircraft. The first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in the virtual scene. The second representation data is used to represent the spatial relative relationship between the virtual obstacle and the virtual aircraft in the virtual scene. The virtual target object is the flight target of the virtual aircraft. The virtual obstacle includes obstacles located in front of the virtual aircraft in the virtual scene.
[0197] S2, determine the flight reference vector based on the flight state data, the first characterization data, and the second characterization data, wherein the flight reference vector is used to characterize the target flight state that the virtual aircraft is expected to achieve;
[0198] S3, based on the flight reference vector and flight state data, determines the multi-dimensional flight control commands for the virtual aircraft. These multi-dimensional flight control commands are used to control the virtual aircraft to achieve the desired target flight state.
[0199] S4 controls the virtual aircraft to fly in a virtual scene according to flight control commands from multiple dimensions.
[0200] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the target terminal. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0201] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0202] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods of the various embodiments of this application.
[0203] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0204] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or the indirect coupling or communication connection of units or modules may be electrical or other forms.
[0205] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0206] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0207] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A control method for a virtual aircraft, characterized in that, include: The system acquires flight status data of a virtual aircraft, first representation data of a virtual target object, and second representation data of virtual obstacles. The flight status data represents the current flight status of the virtual aircraft. The first representation data represents the spatial relative relationship between the virtual target object and the virtual aircraft in the virtual scene. The second representation data represents the spatial relative relationship between the virtual obstacles and the virtual aircraft in the virtual scene. The virtual target object is the flight target of the virtual aircraft, and the virtual obstacles include obstacles located in front of the virtual aircraft in the virtual scene. The flight status data, the first characterization data, and the second characterization data are concatenated into a network input vector. The network input vector is input into a multi-layer network structure in the target neural network, and the activation function in the multi-layer network structure is used to calculate the network input vector and the pre-trained first matrix and first bias vector to obtain a first calculation result; the activation function is used to calculate the first calculation result and the pre-trained second matrix and second bias vector to obtain a second calculation result; the second calculation result and the pre-trained third matrix and third bias vector are used to calculate a flight reference vector, wherein the flight reference vector is used to characterize the target flight state that the virtual aircraft is expected to achieve; Based on the flight reference vector and the flight state data, flight control commands for the virtual aircraft in multiple dimensions are determined, wherein the flight control commands in multiple dimensions are used to control the virtual aircraft to fly in order to achieve the desired target flight state; The virtual aircraft is controlled to fly in the virtual scene according to the flight control commands of the multiple dimensions.
2. The method according to claim 1, characterized in that, After inputting the network input vector into the multi-layer network structure of the target neural network, the method further includes: Perform the following calculations in the multi-layer network structure: r = W2 * tanh(W1 * tanh(W0 * x + b0) + b1) + b2 Where r represents the flight reference vector, which includes N dimensions of expected translational velocity data and M dimensions of expected angular velocity data, where N is equal to 2, 3, or a positive integer greater than 3, and M is equal to 2, 3, or a positive integer greater than 3, and x represents the network input vector, where the first matrix is W0, the second matrix is W1, the third matrix is W2, the first bias vector is b0, the second bias vector is b1, and the third bias vector is b2.
3. The method according to claim 1, characterized in that, Before inputting the network input vector into the target neural network, the method further includes: A set of network input sample vectors is obtained, wherein each network input sample vector in the set of network input sample vectors is a vector obtained by concatenating the sample flight state data of the virtual aircraft, the first sample representation data of the virtual sample object, and the second sample representation data of the virtual sample obstacle. The sample flight state data is used to represent the sample flight state of the virtual aircraft, the first sample representation data is used to represent the spatial relative relationship between the virtual sample object and the virtual aircraft in the virtual scene, and the second sample representation data is used to represent the spatial relative relationship between the virtual sample obstacle and the virtual aircraft in the virtual scene. The virtual sample object is the flight target of the virtual aircraft, and the virtual sample obstacle includes sample obstacles located in front of the virtual aircraft in the virtual scene. The neural network to be trained is trained using the set of network input sample vectors. During the training process, when the value of the target loss function corresponding to the neural network to be trained does not meet the preset convergence condition, the weight parameters to be trained in the neural network to be trained are adjusted. When the value of the target loss function meets the preset convergence condition, the training ends, and the neural network to be trained at the end of the training is determined as the target neural network, and the weight parameters to be trained in the neural network to be trained at the end of the training are determined as the target weight parameters. The target loss function is determined based on a random exploration vector, which is a vector obtained by sampling the estimated reference vector using a Gaussian distribution. The estimated reference vector is a reference vector determined by the neural network to be trained based on the input sample vector and the weight parameters to be trained.
4. The method according to claim 1, characterized in that, The acquisition of flight status data of the virtual aircraft includes: Obtain a set of state data of the virtual aircraft in the root coordinate system, wherein the set of state data includes the height of the virtual aircraft above the ground, the roll angle and the pitch angle of the virtual aircraft; Obtain the first set of velocity data of the virtual aircraft in the root coordinate system, wherein the first set of velocity data includes the translational velocity of the virtual aircraft in multiple dimensions; Obtain a second set of velocity data of the virtual aircraft in the body coordinate system, wherein the second set of velocity data includes the angular velocities of the virtual aircraft in multiple dimensions; The flight status data includes the set of status data, the first set of speed data, and the second set of speed data; Wherein, the origin of the root coordinate system is the projection point of the origin of the body coordinate system onto the ground, the Z-axis of the root coordinate system is parallel to the Z-axis of the world coordinate system, and the X-axis of the root coordinate system is the axis obtained by projecting the X-axis of the body coordinate system onto a direction parallel to the ground.
5. The method according to claim 1, characterized in that, Obtain the first representation data of the virtual target object, including: Obtain the direction vector of the target connection direction in the body coordinate system, wherein the target connection direction is the direction of the connection between the virtual aircraft and the virtual target object; Obtain the target distance between the virtual aircraft and the virtual target object; The first characterization data includes the direction vector and the target distance.
6. The method according to claim 1, characterized in that, Acquire second representation data of the virtual obstacles, including: When the virtual obstacle includes a set of obstacles, P directional representation data of the virtual obstacle relative to the virtual aircraft are obtained, wherein the P directional representation data correspond to P directions respectively, and the directional representation data are used to represent the volume of the obstacle in the corresponding direction or the distance between the obstacle in the corresponding direction and the virtual aircraft. The larger the directional representation data, the larger the volume of the obstacle in the corresponding direction or the closer the distance between the obstacle in the corresponding direction and the virtual aircraft. P is a positive integer greater than or equal to 2.
7. The method according to claim 6, characterized in that, The acquisition of P azimuth representation data of the virtual obstacle relative to the virtual aircraft includes: Starting from the origin of the virtual aircraft's coordinate system, Q segments of rays are emitted to the left and right of the X-axis at 90° angles to the left and right, respectively, to obtain distance representation data in Q directions, where Q is a positive integer greater than or equal to 2. The distance representation data is used to represent the distance between the virtual aircraft and the obstacles in the corresponding directions. Based on the distance representation data in the Q directions, determine the P directions representation data, where P is less than Q.
8. The method according to any one of claims 1 to 7, characterized in that, The acquisition of flight status data of the virtual aircraft, first representation data of the virtual target object, and second representation data of the virtual obstacle includes: acquiring the flight status data of the virtual aircraft, the first representation data of the virtual target object, and the second representation data of the virtual obstacle in the current frame of the target game application; Controlling the virtual aircraft to fly in the virtual scene according to the flight control commands of the multiple dimensions includes: controlling the virtual aircraft to fly in the virtual scene in the next frame of the current frame according to the flight control commands of the multiple dimensions.
9. A control device for a virtual flight vehicle, characterized in that, include: The first acquisition unit is used to acquire flight status data of a virtual aircraft, first representation data of a virtual target object, and second representation data of virtual obstacles. The flight status data is used to represent the current flight status of the virtual aircraft. The first representation data is used to represent the spatial relative relationship between the virtual target object and the virtual aircraft in the virtual scene. The second representation data is used to represent the spatial relative relationship between the virtual obstacles and the virtual aircraft in the virtual scene. The virtual target object is the flight target of the virtual aircraft. The virtual obstacles include obstacles located in front of the virtual aircraft in the virtual scene. The first splicing module is used to splice the flight status data, the first representation data and the second representation data into a network input vector; A first processing module is configured to input the network input vector into a multi-layer network structure in a target neural network, and use the activation function in the multi-layer network structure to calculate the network input vector and a pre-trained first matrix and a first bias vector to obtain a first calculation result; use the activation function to calculate the first calculation result and a pre-trained second matrix and a second bias vector to obtain a second calculation result; and calculate a flight reference vector based on the second calculation result and a pre-trained third matrix and a third bias vector, wherein the flight reference vector is used to characterize the target flight state that the virtual aircraft is expected to achieve. The second processing unit is used to determine multi-dimensional flight control commands for the virtual aircraft based on the flight reference vector and the flight state data, wherein the multi-dimensional flight control commands are used to control the virtual aircraft to fly in order to achieve the desired target flight state. The control unit is used to control the virtual aircraft to fly in the virtual scene according to the flight control commands of the multiple dimensions.
10. The apparatus according to claim 9, characterized in that, The first processing module includes: The first processing submodule is used to perform the following calculations in the multi-layer network structure: r = W2 * tanh(W1 * tanh(W0 * x + b0) + b1) + b2 Where r represents the flight reference vector, which includes N dimensions of expected translational velocity data and M dimensions of expected angular velocity data, where N is equal to 2, 3, or a positive integer greater than 3, and M is equal to 2, 3, or a positive integer greater than 3, and x represents the network input vector, where the first matrix is W0, the second matrix is W1, the third matrix is W2, the first bias vector is b0, the second bias vector is b1, and the third bias vector is b2.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program can be executed by a terminal device or computer at runtime as described in any one of claims 1 to 8.
12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method described in any one of claims 1 to 8.
13. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 8 through the computer program.