High-precision road network vehicle simulation method based on ThreeJS

Through the high-precision road network vehicle simulation method based on ThreeJS, a traffic road network model is constructed and a random vehicle generator and traffic light are configured, which solves the problems of large calculation volume and low simulation efficiency in the existing technology, and achieves high precision and dynamic vehicle simulation.

CN119397740APending Publication Date: 2025-02-07四川易方智慧科技有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411372083.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the prior art, when using third-party software to simulate a vehicle, the calculation amount is large and the simulation efficiency is low.

Method used

Using the high-precision road network vehicle simulation method based on ThreeJS, by constructing a traffic road network model, configuring a random vehicle generator and traffic light, dynamically adding vehicles for simulation, and planning the vehicle's driving path.

Benefits of technology

It improves the accuracy of vehicle driving trajectory and road attributes during the simulation process, supports real-time vehicle behavior changes, improves the interactiveness and dynamicity of the simulation, and can intuitively display the movement of vehicles in the road network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119397740A_ABST
    Figure CN119397740A_ABST
Patent Text Reader

Abstract

The invention discloses a high-precision road network vehicle simulation method based on ThreeJS. The method comprises the following steps: S1, constructing an initialization environment; step S101, constructing a traffic road network model; step S102, configuring a random vehicle generator according to the traffic road network model generated in the step S101; s103, configuring a traffic signal lamp; s2, dynamically adding a vehicle for simulation; s201, configuring a random vehicle generator, and loading a vehicle model of a random point location in the scene; and S202, planning a driving path of the vehicle according to the road section vehicle generated in the step S201. Through the method provided by the invention, the effect of vehicle simulation on the lane can be directly and quickly presented, and specific information and intuitive effect required to be displayed by vehicle simulation can be expressed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of simulation, and specifically relates to a high-precision road network vehicle simulation method based on ThreeJS. Background Art

[0002] Vehicle simulation is a technology that uses computers to simulate the operation of cars. It refers to the use of simulation technology to study traffic behavior. It is a technology that tracks and describes the changes in traffic movement over time and space. It contains random characteristics, which can be microscopic or macroscopic, and designs a mathematical model that describes the real-time movement of the transportation system over a certain period of time.

[0003] In the prior art, for example, the technical solution described in the patent with publication number CN115578857 is: a three-dimensional scene vehicle simulation method and system based on a car-following model and road rights, which imports a road network into a selected three-dimensional scene, combines a road speed limit model with the road network to set a road speed limit, combines a traffic light and intersection analysis model with the road network to set road connections and traffic lights by clicking, and generates a simulated road network. The simulated road network is simulated by the car-following model to obtain a vehicle simulation file in a three-dimensional scene.

[0004] In the existing technology, the road network generation using Shp data faces the problem of complex road network topology analysis workflow, and most of them use third-party software such as ArcGIS for topology calculation. Therefore, relevant algorithms are urgently needed to simulate road network data, reduce the calculation amount of vehicle simulation, and improve the effect of vehicle simulation. Summary of the invention

[0005] The purpose of the present invention is to provide a high-precision road network vehicle simulation method based on ThreeJS to solve the problems of large calculation amount and low simulation efficiency when using third-party software for vehicle simulation in the prior art proposed in the background technology.

[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0007] A high-precision road network vehicle simulation method based on ThreeJS, comprising the following steps:

[0008] Step S1, constructing an initialization environment;

[0009] Step S101, constructing a traffic road network model;

[0010] Step S102, configuring a random vehicle generator according to the traffic road network model generated in step S101;

[0011] Step S103, configuration of traffic lights;

[0012] Step S2, dynamically adding vehicles for simulation;

[0013] Step S201, configuring a random vehicle generator to load vehicle models at random points in the scene;

[0014] Step S202, planning the vehicle's driving path according to the road section vehicles generated in step S201.

[0015] According to the above technical solution, in step S101, the construction of the traffic road network model is specifically as follows:

[0016] First, the original high-precision road network data is screened, and the serialized high-precision road network is deserialized to convert the high-precision road network data structure into a data format that can be extracted; the vertex information, trajectory information and section information of each road section are extracted and encapsulated to encapsulate the information required for each section together; each vehicle moves along the trajectory information in the section, and when the vehicle reaches the end of a section, it is moved to the trajectory of the next section.

[0017] According to the above technical solution, in step S102, configuring the random vehicle generator is specifically as follows:

[0018] According to the predefined total number of vehicles, vehicles are randomly added to the road section; the random vehicle generator includes a generation rate of configured random vehicles, that is, the average number of vehicles added to the simulation per minute and a configuration list of configured random vehicles, which is used to store the configuration information of the vehicles.

[0019] According to the above technical solution, in step S103, the configuration of the traffic light is specifically as follows:

[0020] Configure traffic lights; traffic lights are located at the end points of the road section, including deceleration areas and parking areas; in order to control the movement of vehicles under the unified control of traffic lights, the coordinates of the trajectory points on each road section in the high-precision road network should be equally divided;

[0021] First, the vertical direction of the vector and the normalization of the vector are used to constrain the trajectory coordinates of each lane. The three-dimensional vertical direction vector is determined by cross product calculation, the unit length of the vector is adjusted, and the modulus of the vector length is calculated. Each component of the vector is divided by the length of the vector to obtain the center point of the starting point and the end point of the road. In this way, the coordinates of multiple points between the starting point and the end point on the center line of the lane are determined. After determination, all coordinates are stored in an object in the format of an array and lane attributes for subsequent vehicle travel.

[0022] According to the above technical solution, the deceleration zone is specifically: with the deceleration distance and the deceleration coefficient as the control unit, it is the area where the vehicle decelerates using the deceleration coefficient; firstly, a deceleration zone length is determined globally, and the vehicle enters the deceleration zone range, and the position is updated in real time by multiplying the current speed by the speed reduction ratio per frame;

[0023] The parking area is specifically: characterized by the parking distance, which is the parking area of ​​the vehicle. The area is a dynamic interval. The parking distance is determined based on the initial speed and deceleration. Whether to enter the parking area is determined while ensuring that the distance is not a negative number.

[0024] According to the above technical solution, in step S201, a random vehicle generator is configured to load a vehicle model at a random point in the scene as follows;

[0025] Use GLTFLoader in Three.js to traverse the vehicle model and copy it into the configuration list, as shown below:

[0026] vehicleModels.push(gltf.scene) (1)

[0027] The vehicle configuration list in equation (1) is introduced into the following equation and randomly added to the scene:

[0028] vehicleModels[Math.floor(Math.random()*vehicleModels.length)].clone()

[0029] Here, Math.random() generates a random number between 0 and 1, multiplies it by the length of the vehicleModels.length array to enlarge the random number to the length of the array, and uses Math.floor to get the integer downward, and finally .clone(): clones the selected model.

[0030] According to the above technical solution, in step S202, the vehicle's driving path is specifically planned as follows:

[0031] Planning a driving path of the vehicle according to the road segment vehicles generated in step S201;

[0032] Math.abs(ax-bx)+Math.abs(ay-by) (3)

[0033] openList.push(newNode(start.x,start.y,0,heuristic(start,end))) (4)

[0034] vehicle.position.distanceTo(light.position) (5)

[0035] direction=targetPosition.clone().sub(vehicle.position).normalize(); (6)

[0036] vehicle.position.add(direction.multiplyScalar(0.1)) (6)

[0037] Formula (3) is used to calculate the Manhattan distance between two nodes in the road section; Formula (4) is used to add the starting node in the road section to the open node list; the initial information of the traffic light is configured in the trafficLights list; Formula (5) is used to determine the distance between the traffic light and the vehicle on the road section; Formula (6) is used to calculate the direction vector from the current position of the vehicle to the target position and normalize it; Formula (7) is used to move the vehicle's position along the calculated direction vector by a small step.

[0038] Compared with the prior art, the present invention has the following beneficial effects:

[0039] The method of the present invention can construct an accurate traffic road network model by screening and processing high-precision road network data, so that the vehicle's driving trajectory and road properties during the simulation process are highly consistent with the actual situation. The method can dynamically add vehicles for simulation, support real-time vehicle behavior changes, improve the interactivity and dynamics of the simulation, and allow users to observe vehicle behavior under different traffic conditions. By planning the vehicle's driving path, the simulation system can display the vehicle's driving effects under different conditions (such as traffic light changes, road congestion, etc.), helping users understand the complexity of traffic flow. Using the graphics rendering capabilities of Three.js, the movement of vehicles in the road network can be displayed in a visual way, and the relative position, speed and mutual influence between vehicles can be intuitively expressed, providing an effective tool for traffic research and education. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a schematic diagram of the flow chart of the simulation method of the present invention. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0042] Embodiment 1

[0043] like Figure 1 As shown, a high-precision road network vehicle simulation method based on ThreeJS includes the following steps:

[0044] Step S1, constructing an initialization environment;

[0045] Step S101, constructing a traffic road network model; the construction of the traffic road network model is specifically as follows:

[0046] The first step is to filter the original high-precision road network data. The main filtering criteria is to determine the specific information of each attribute on the high-precision road network through the class name, and deserialize the serialized high-precision road network. Deserialization is achieved through the deserialization function in the programming language. Its main function is to convert the high-precision road network data structure into a data format that can be extracted.

[0047] Extract the vertex information, trajectory information and section information of the encapsulated road to encapsulate the information required for each section together; each vehicle moves along the trajectory information in the section, and when the vehicle reaches the end of a section, it moves to the trajectory of the next section. In essence, the movement of a vehicle from one section to another is to obtain all the attributes of the two sections to splice the head and tail points, and then integrate the point arrays of the two sections, which is the basis for building the bottom layer of the vehicle's driving road.

[0048] Step S102, configuring a random vehicle generator according to the traffic road network model generated in step S101;

[0049] Step S103, configuration of traffic lights; firstly, use the normalization of the vector vertical direction and the vector to constrain the trajectory coordinates of each lane; determine the three-dimensional vertical direction vector through cross product calculation, adjust the unit length of the vector, calculate the modulus of the vector length, divide each component of the vector by the length of the vector, and obtain the center point of the starting point and the end point of the road, so as to determine the coordinates of multiple points between the starting point and the end point on the center line of the lane, and after determination, store all coordinates in an object in the format of an array and lane attributes for subsequent vehicle travel.

[0050] Step S2, dynamically adding vehicles for simulation;

[0051] Step S201, configuring a random vehicle generator to load vehicle models at random points in the scene;

[0052] Step S202, planning the vehicle's driving path according to the road section vehicles generated in step S201.

[0053] The method of the present invention can construct an accurate traffic road network model by screening and processing high-precision road network data, so that the vehicle's driving trajectory and road properties during the simulation process are highly consistent with the actual situation. The method can dynamically add vehicles for simulation, support real-time vehicle behavior changes, improve the interactivity and dynamics of the simulation, and allow users to observe vehicle behavior under different traffic conditions. By planning the vehicle's driving path, the simulation system can display the vehicle's driving effects under different conditions (such as traffic light changes, road congestion, etc.), helping users understand the complexity of traffic flow. Using the graphics rendering capabilities of Three.js, the movement of vehicles in the road network can be displayed in a visual way, and the relative position, speed and mutual influence between vehicles can be intuitively expressed, providing an effective tool for traffic research and education.

[0054] Since the present invention involves random vehicle generators and traffic light configurations, users can freely configure different traffic flows, vehicle types, and signal states according to different test requirements and scenarios to adapt to a variety of simulation scenarios. By extracting and encapsulating vertex information and trajectory information of roads, effective data management is achieved, the efficiency and operability of data processing are improved, and subsequent analysis and modification are convenient.

[0055] Embodiment 2

[0056] This embodiment is a further refinement of the first embodiment.

[0057] Step 1: Construct the initialization environment, which is divided into the following three basic conditions:

[0058] Condition 1: The construction of the traffic road network model first involves screening the original high-precision road network data, deserializing the serialized high-precision road network, extracting the vertex information, trajectory information, and section information of each road section that encapsulates the road; each vehicle moves along the trajectory information in the road section, and when the vehicle reaches the end of a section, it is moved to the trajectory of the next section.

[0059] Condition 2: Based on the traffic road network model generated in Condition 1, configure the random vehicle generator to randomly add vehicles to the road segment according to the predefined number of vehicles. The random vehicle generator has two constraints: the vehicle generation rate, that is, the average number of vehicles added to the simulation per minute, and the vehicle configuration list, which mainly stores the vehicle configuration information.

[0060] Condition 3: Traffic lights are located at the end of the road section, which includes two areas: one is the deceleration area, which is controlled by the deceleration distance and the deceleration coefficient, and is the area where the vehicle uses the deceleration coefficient to decelerate; the other is the parking area, which is characterized by the parking distance and is the parking area of ​​the vehicle. The area is a dynamic interval; at the same time, in order to control the movement of vehicles under the unified control of traffic lights, the coordinates of the trajectory points on each road section in the high-precision road network must first be divided equally. First, the vertical direction of the vector and the normalization of the vector are used to constrain the trajectory coordinates of each lane, and the center point of the starting point and the end point of the road can be obtained, so as to determine the coordinates of multiple points between the starting point and the end point on the center line of the lane.

[0061] Step 2: Dynamically add vehicles for simulation;

[0062] Step a, configure the random vehicle generator, and load the vehicle model at random points in the scene; Formula (1) uses GLTFLoader in Three.js to traverse the vehicle model and copy it into the configuration list; Formula (2) introduces the vehicle configuration list in Formula (1) and randomly adds it to the scene;

[0063] vehicleModels.push(gltf.scene) (1)

[0064] vehicleModels[Math.floor(Math.random()*vehicleModels.length)].clone() (2)

[0065] Step b, planning the vehicle's driving path according to the road section vehicles generated in step a;

[0066] Math.abs(ax-bx)+Math.abs(ay-by) (3)

[0067] openList.push(new Node(start.x,start.y,0,heuristic(start,end))) (4)

[0068] vehicle.position.distanceTo(light.position) (5)

[0069] direction=targetPosition.clone().sub(vehicle.position).normalize()(6)

[0070] vehicle.position.add(direction.multiplyScalar(0.1)) (7)

[0071] Formula (3) is used to calculate the Manhattan distance between two nodes in a road section; Formula (4) is used to add the starting node in the road section to the open node list; the initial information of the traffic light is configured in the trafficLights list; Formula (5) is used to determine the distance between the traffic light and the vehicle on the road section; Formula (6) is used to calculate the direction vector from the current position of the vehicle to the target position and normalize it; Formula (7) is used to move the vehicle's position along the calculated direction vector by a small step.

[0072] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0073] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A high-precision road network vehicle simulation method based on ThreeJS, characterized by: The following steps are involved: Step S1, constructing an initialization environment; Step S101, constructing a traffic road network model; Step S102, configuring a random vehicle generator according to the traffic road network model generated in step S101; Step S103, configuration of traffic lights; Step S2, dynamically adding vehicles for simulation; Step S201, configuring a random vehicle generator to load vehicle models at random points in the scene; Step S202, planning the vehicle's driving path according to the road section vehicles generated in step S201.

2. A high-precision road network vehicle simulation method based on ThreeJS according to claim 1, characterized in that: In step S101, the construction of the traffic road network model is specifically as follows: First, the original high-precision road network data is screened, and the serialized high-precision road network is deserialized to convert the high-precision road network data structure into a data format that can be extracted; the vertex information, trajectory information and section information of each road section are extracted and encapsulated to encapsulate the information required for each section together; each vehicle moves along the trajectory information in the section, and when the vehicle reaches the end of a section, it is moved to the trajectory of the next section.

3. A high-precision road network vehicle simulation method based on ThreeJS according to claim 1, characterized in that: Step S102, configuring the random vehicle generator is specifically as follows: According to the predefined total number of vehicles, vehicles are randomly added to the road section; the random vehicle generator includes a generation rate of configured random vehicles, that is, the average number of vehicles added to the simulation per minute and a configuration list of configured random vehicles, which is used to store the configuration information of the vehicles.

4. A high-precision road network vehicle simulation method based on ThreeJS according to claim 1, characterized in that: Step S103: The configuration of the traffic light is specifically as follows: Configure traffic lights; traffic lights are located at the end points of the road section, including deceleration areas and parking areas; in order to control the movement of vehicles under the unified control of traffic lights, the coordinates of the trajectory points on each road section in the high-precision road network should be equally divided; First, the vertical direction of the vector and the normalization of the vector are used to constrain the trajectory coordinates of each lane. The three-dimensional vertical direction vector is determined by cross product calculation, the unit length of the vector is adjusted, and the modulus of the vector length is calculated. Each component of the vector is divided by the length of the vector to obtain the center point of the starting point and the end point of the road. In this way, the coordinates of multiple points between the starting point and the end point on the center line of the lane are determined. After determination, all coordinates are stored in an object in the format of an array and lane attributes for subsequent vehicle travel.

5. A high-precision road network vehicle simulation method based on ThreeJS according to claim 4, characterized in that: The deceleration zone is specifically defined as follows: the deceleration distance and deceleration coefficient are used as control units, and it is the area where the vehicle decelerates using the deceleration coefficient. First, the length of the deceleration zone is determined globally, and the vehicle is judged to enter the deceleration zone range. The position is updated in real time by multiplying the current speed by the speed reduction ratio per frame. The parking area is specifically: characterized by the parking distance, which is the parking area of ​​the vehicle. The area is a dynamic interval. The parking distance is determined based on the initial speed and deceleration. Whether to enter the parking area is determined while ensuring that the distance is not a negative number.

6. A high-precision road network vehicle simulation method based on ThreeJS according to claim 1, characterized in that: Step S201, configuring a random vehicle generator, and loading a vehicle model at a random point in the scene is specifically as follows; Use GLTFLoader in Three.js to traverse the vehicle model and copy it into the configuration list, as shown below: vehicleModels.push(gltf.scene)(1) The vehicle configuration list in equation (1) is introduced into the following equation and randomly added to the scene: vehicleModels[Math.floor(Math.random()*vehicleModels.length)].clone() Here, Math.random() generates a random number between 0 and 1, multiplies it by the length of the vehicleModels.length array to scale it up to the length of the array, and uses Math.floor to get an integer down, and finally .clone() is used to clone the selected model.

Citation Information

Cited By

  • Unity-based vehicle safe lane changing strategy simulation method

    CN120452248A