A simulation method for vehicle safe lane-changing strategy based on Unity
The Unity-based vehicle lane-changing strategy simulation method solves the problems of lack of standardization and insufficient performance optimization of lane-changing algorithms in existing vehicle simulation systems, achieves efficient simulation of complex traffic scenarios, and improves the authenticity and reliability of the simulation.
Patent Information
- Application Number
- CN202510947038.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-07-10
AI Technical Summary
Existing vehicle simulation systems lack standardized lane-changing algorithms and performance optimization, resulting in insufficient simulation realism and reliability, making it difficult to effectively promote them in complex traffic scenarios.
A Unity-based vehicle lane-changing strategy simulation method is used to obtain the vehicle's current lane and target lane information, determine the lane-changing requirement, select the target lane, and detect the distance to surrounding vehicles in real time during the lane-changing process. Safety detection and path planning are performed to ensure the rationality and safety of the lane-changing operation.
It achieves in-depth modeling of complex lane-changing behaviors in real traffic, improves the authenticity and reliability of simulation, reduces computing resource requirements, and improves the adaptability and scalability of the system.
Smart Images

Figure CN120452248B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent transportation systems, and in particular to a Unity-based vehicle safe lane-changing strategy simulation method. Background Art
[0002] With the rapid development of intelligent transportation systems, vehicle simulation is playing an increasingly important role in transportation system design, autonomous driving technology testing, and traffic flow optimization. However, existing vehicle simulation systems often rely on complex, specialized simulation software, which is difficult to implement, expensive to develop, and lacks adaptability and flexibility.
[0003] As a powerful game development platform, the Unity engine, with its superior 3D graphics rendering capabilities, cross-platform support, and convenient development environment, has gradually become an ideal tool for vehicle simulation system development. With Unity, developers can quickly build realistic 3D scenes and flexibly implement various traffic simulation requirements, reducing development barriers and costs while improving system scalability and adaptability.
[0004] Some researchers and developers have tried to use Unity for vehicle simulation, but the following shortcomings are still common:
[0005] (1) Lack of standardized lane-changing algorithms: Currently, the lane-changing functions of most vehicle simulation systems are limited to simple vehicle control logic and cannot reflect the complex lane-changing behaviors in real traffic. These implementations usually lack in-depth modeling of the lane-changing decision-making and execution process, such as the triggering conditions for lane changes, dynamic interactions with surrounding vehicles, and real-time assessment of safety distances. In addition, different simulation scenarios and needs have different requirements for the accuracy and adaptability of lane-changing algorithms, but existing implementations lack unified standards and universal solutions, making them difficult to be widely promoted in practical applications. Therefore, developing a standardized and effective lane-changing algorithm is of great significance to improving the authenticity and reliability of vehicle simulation.
[0006] (2) Inadequate performance optimization: In large-scale traffic simulation scenarios, insufficient performance optimization often becomes a system bottleneck, directly affecting the smoothness and effectiveness of the simulation. As the number of vehicles in the simulation increases, the demand for computing resources increases exponentially, especially when complex lane-changing behaviors are involved. Therefore, there is an urgent need for a solution that can achieve efficient performance optimization while ensuring the authenticity and rationality of the simulation to meet the complex requirements of large-scale scenarios. Summary of the Invention
[0007] The purpose of the present invention is to provide a Unity-based vehicle lane-changing strategy simulation method, which can solve the problems of the lack of standardized lane-changing algorithms and insufficient performance optimization in traffic simulation tools in the prior art during actual use.
[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0009] A vehicle safe lane-changing strategy simulation method based on Unity includes the following steps:
[0010] Step 1: Obtain the vehicle's current lane and target lane information;
[0011] Step 2: Determine lane change requirements;
[0012] Step 3, select the target lane: If lane change is required, select a suitable target lane as the lane change direction;
[0013] Step 4, lane change execution: During the lane change process, the distance between the surrounding vehicles and the current vehicle is detected in real time to determine whether to execute the lane change operation;
[0014] Step 5: After the lane change is successful, update the vehicle status information;
[0015] Among them, step 2 specifically includes: detecting whether the current lane can reach the target lane. If the target lane cannot be reached, setting the lane change flag to 1, indicating that a lane change operation needs to be performed; if the target lane can be reached, ending the lane change.
[0016] Preferably, step 2 further specifically includes determining whether a lane change operation needs to be performed by detecting whether there is an obstacle in the current lane, calculating whether the current lane is connected to the target lane, and detecting whether there is a road congestion.
[0017] Preferably, the method for detecting whether there is an obstacle in the current lane is as follows:
[0018] S1, emitting rays from the front of the vehicle to obtain information about the object detected by the rays;
[0019] S2, determining whether the object level is one of the "obstacle" level or the "traffic safety facility" level based on the object information; if so, determining that there is an obstacle or a traffic safety facility ahead, and setting a lane change flag to 1, indicating that a lane change operation is required;
[0020] S3, if not, you can continue to move forward.
[0021] Preferably, the method for detecting whether a road is blocked is as follows:
[0022] S01, when a vehicle enters a lane, it is added to the queue of the current lane;
[0023] S02, when detecting lane change, calculates the occupancy rate of the current lane according to the occupancy rate formula. If the occupancy rate exceeds the threshold, it indicates that the current lane is congested;
[0024] S03: If there is a congestion, the lane change flag is set to 1, indicating that a lane change operation needs to be performed.
[0025] Preferably, the step 3 specifically includes, when the lane change flag is 1, indicating that a lane change is required, calculating the target lane for the vehicle to change lane, and the calculation method is:
[0026] S001, calculating the lane IDs of all lanes in the current lane that can reach the target lane based on the road ID of the current lane and the lane-to-lane connection information;
[0027] S002: When the number of reachable target lanes is greater than 0, it indicates that there are other lanes in the current road section that can reach the target lane. The occupancy rate of each reachable target lane is calculated, and the reachable target lane with the lowest occupancy rate is selected as the lane for lane change.
[0028] S003: If the number of reachable target lanes is equal to 0, then the lane change is terminated.
[0029] Preferably, step 4 specifically includes taking into account the parallel situation of vehicles in the left and right lanes and performing safety detection during the lane changing process.
[0030] Preferably, the safety detection method includes:
[0031] S0001, with the coordinates of the vehicle as the center point Extend the bounding box in the direction of the required lane change , and set the collision detection object to "vehicle level", Represents the distance offset between the current lane and the lane change lane;
[0032] S0002, start the collision detection within the current range. If the collision detection result is greater than 0, it means that there are other vehicles in the lane change direction. Lane change is temporarily not allowed. It is necessary to continue to execute the detection mechanism and set the lane change urgency , waiting for the right time to change lanes;
[0033] If the collision detection result is equal to 0, it means there is no other vehicle in the lane change direction, and the lane change operation is allowed;
[0034] like , it means that the intersection is about to be reached and a new route needs to be reallocated based on the current lane.
[0035] Preferably, step 4 further includes, when the vehicle performs the lane changing action according to the planned lane changing path, adjusting the speed and direction in real time during the operation to ensure a smooth transition.
[0036] Compared with the prior art, the present invention has the following beneficial effects:
[0037] In this invention, after the simulation system obtains information about the current lane and the target lane to be reached, it can calculate whether there are obstacles or traffic jams in the current lane. If lane congestion is detected, the vehicle enters free lane change mode and switches the lane change status to "lane change required." Simultaneously, it calculates whether the current lane is connected to the target lane. If the target lane cannot be reached, the lane change status is also switched to "lane change required," reflecting the complex lane changing behavior in real traffic.
[0038] During the lane-changing process, it is necessary to consider the parallel operation of vehicles in the left and right lanes. Therefore, a safety detection mechanism is introduced in the lane-changing process. The triggering conditions for vehicle lane changes, dynamic interactions with surrounding vehicles, and real-time assessment of safety distances are deeply modeled to reflect the complex lane-changing behaviors in real traffic. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 This is the overall algorithm flow chart of the present invention.
[0041] Figure 2 This is a flow chart of lane change demand detection in the present invention.
[0042] Figure 3 This is a flow chart of lane change path planning in the present invention.
[0043] Figure 4 This is a flow chart of lane change safety detection in the present invention. DETAILED DESCRIPTION
[0044] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0045] Example 1
[0046] See Figure 1-Figure 4 This embodiment discloses a method for simulating a safe lane-changing strategy for a vehicle based on Unity, comprising the following steps:
[0047] Step 1: Obtain the vehicle's current lane and target lane information;
[0048] Step 2: Determine lane change requirements;
[0049] Step 3, select the target lane: If lane change is required, select a suitable target lane as the lane change direction;
[0050] Step 4, lane change execution: During the lane change process, the distance between the surrounding vehicles and the current vehicle is detected in real time to determine whether to execute the lane change operation;
[0051] Step 5: After the lane change is successful, update the vehicle status information;
[0052] Among them, step 2 specifically includes: detecting whether the current lane can reach the target lane. If the target lane cannot be reached, setting the lane change flag to 1, indicating that a lane change operation needs to be performed; if the target lane can be reached, ending the lane change.
[0053] In this embodiment, after obtaining information about the current lane and the target lane to be reached, the simulation system calculates and detects whether the current lane can reach the target lane. Specifically, it detects whether there are obstacles or traffic jams in the current lane. If lane congestion is detected, the vehicle enters free lane change mode and switches the lane change status to "Lane Change Required." Furthermore, determining whether the current lane can reach the target lane also requires calculating whether the current lane is connected to the target lane. If the target lane cannot be reached, the lane change status is also switched to "Lane Change Required," reflecting the complex lane-changing behavior in real traffic. During the lane-changing process, the parallel operation of vehicles in the left and right lanes must be considered, thus incorporating a safety detection mechanism. In-depth modeling of the vehicle's lane-changing triggering conditions, dynamic interactions with surrounding vehicles, and real-time assessment of safety distances is performed, reflecting the complex lane-changing behavior in real traffic.
[0054] Step 2 further specifically includes determining whether a lane change is necessary by detecting whether there are obstacles in the current lane, calculating whether the current lane is connected to the target lane, and detecting whether there is road congestion. In this embodiment, if the current lane is connected to the target lane, it indicates that the vehicle can reach the target lane; if the current lane is not connected to the target lane, it indicates that the vehicle cannot reach the target lane. If the vehicle cannot reach the target lane due to an obstacle, traffic congestion, or the current lane is not connected to the target lane, the vehicle flag is set to indicate that a lane change is required.
[0055] Further optimization, the method for detecting whether there is an obstacle in the current lane is as follows:
[0056] S1, emitting rays from the front of the vehicle to obtain information about the object detected by the rays;
[0057] S2, determining whether the object level is one of the "obstacle" level or the "traffic safety facility" level based on the object information; if so, determining that there is an obstacle or a traffic safety facility ahead, and setting a lane change flag to 1, indicating that a lane change operation is required;
[0058] S3, if not, you can continue to move forward.
[0059] By detecting whether there are obstacles on the road when judging the need to change lanes, the lane change decision and execution process can be deeply modeled, thus reflecting the complex lane changing behavior in real traffic.
[0060] For further optimization, see Figure 3 , the method for detecting whether a road is blocked is as follows:
[0061] S01, when a vehicle enters a lane, it is added to the queue of the current lane;
[0062] S02, when detecting lane change, calculates the occupancy rate of the current lane according to the occupancy rate formula. If the occupancy rate exceeds the threshold, it indicates that the current lane is congested;
[0063] S03: If there is a congestion, the lane change flag is set to 1, indicating that a lane change operation needs to be performed.
[0064] By detecting whether the current lane is congested when judging the need to change lanes, the lane-changing decision-making and execution process can be deeply modeled, thus reflecting the complex lane-changing behavior in real traffic.
[0065] For further optimization, see Figure 3 ,The principle of detecting whether the target lane can be reached in step 2 is as follows:
[0066] 1) Based on the road network data, each road is abstracted into a node. Based on the connection between roads (Connection), the connection between nodes is calculated.
[0067] 2) If the starting point is A and the end point is E, use the A* pathfinding algorithm to calculate the IDs of all roads from A to E, forming a data column, which represents the order of roads that need to be taken from point A to point E.
[0068] 3) Based on the road ID of the current lane, the next road ID can be found.
[0069] 4) Based on the connection status of the lane to be detected, determine whether there is data in the Connection that can reach the next road.
[0070] 5) If it exists, it means that the lane to be detected can reach the next road; otherwise, it cannot be reached.
[0071] A* pathfinding calculation method:
[0072] The A* pathfinding method uses a heuristic function. ; Calculate the estimated cost of each node, where is the total cost from the starting point to the current node, is the estimated cost from the current node to the target node, is the total estimated cost.
[0073] The A* pathfinding calculation process is as follows:
[0074] 【1】Initialize, set the starting point start and the target point goal.
[0075] Create an open list OpenSet (nodes to be visited) and a closed list ClosedSet (nodes that have been visited).
[0076] Add the starting point to OpenSet, set g(start) = 0, and calculate f(start).
[0077] 【2】Iterative search, select from OpenSet The smallest node, current, is moved into the ClosedSet.
[0078] If current == goal, terminate and find the optimal path.
[0079] Traverse all neighbor nodes of current.
[0080] If neighbor is in ClosedSet, skip.
[0081] Calculate g(neighbor) = g(current) + movement cost.
[0082] Compute h(neighbor) (heuristic estimate).
[0083] Calculate f(neighbor) = g(neighbor) + h(neighbor).
[0084] If the neighbor was not in the OpenSet before or f(neighbor) is smaller, update the neighbor's parent node and add it to the OpenSet.
[0085] 【3】Backtracking path: After the target point goal is found, backtrack to the parent node step by step from the goal to obtain the optimal path, which is the road ID sequence of the path from the starting point to the end point.
[0086] By detecting whether all lanes can reach the destination road, the lane change decision and execution process can be deeply modeled, thereby realizing a standardized and effective lane change method, which is of great significance to improving the realism and reliability of vehicle simulation.
[0087] For further optimization, see Figure 1 and Figure 4 , the step 3 specifically includes, when the lane change flag is 1, indicating that a lane change is required, calculating the vehicle's lane change target lane, the calculation method is:
[0088] S001, calculating the lane IDs of all lanes in the current lane that can reach the target lane based on the road ID of the current lane and the lane-to-lane connection information;
[0089] S002: When the number of reachable target lanes is greater than 0, it indicates that there are other lanes in the current road section that can reach the target lane. The occupancy rate of each reachable target lane is calculated, and the reachable target lane with the lowest occupancy rate is selected as the lane for lane change.
[0090] S003: If the number of reachable target lanes is equal to 0, then the lane change is terminated.
[0091] Further optimization, the calculation formula for the occupancy of the target lane is as follows:
[0092]
[0093] in Represents the number of vehicles in the current lane; Representative The length of the vehicle; Representative Safe distance between vehicles; Represents the total length of the lane; the occupancy rate can indirectly reflect the congestion of the lane.
[0094] When the number of reachable target lanes is greater than 0, Real-time evaluation of lane-changing parameters can reflect the complex lane-changing behavior in real traffic and is easier to promote in practical applications.
[0095] Among them, see Figure 1 and Figure 4 , the step 4 specifically includes, considering the parallel situation of vehicles in the left and right lanes, and performing safety detection during the lane changing process.
[0096] Further optimization, the safety detection method includes:
[0097] S0001, with the coordinates of the vehicle as the center point Extend the bounding box in the direction of the required lane change , and set the collision detection object to "vehicle level", Represents the distance offset between the current lane and the lane change lane;
[0098] S0002, start the collision detection within the current range. If the collision detection result is greater than 0, it means that there are other vehicles in the lane change direction. Lane change is temporarily not allowed. It is necessary to continue to execute the detection mechanism and set the lane change urgency , waiting for the right time to change lanes;
[0099] If the collision detection result is equal to 0, it means there is no other vehicle in the lane change direction, and the lane change operation is allowed;
[0100] like , it means that the intersection is about to be reached and a new route needs to be reallocated based on the current lane.
[0101] In the above process, the calculation formula of the vehicle lane change urgency is as follows:
[0102]
[0103] in, is the urgency proportional factor, which is used to adjust the weight range of the lane change urgency; is the distance between the vehicle and the end point of the current lane; Represents the length of the current lane.
[0104] Through dynamic interaction with surrounding vehicles and real-time evaluation of safety distances, it can reflect the complex lane-changing behaviors in real traffic. In-depth modeling of lane-changing decisions and execution processes makes it easier to widely promote them in practical applications.
[0105] In a further optimization, step 4 also includes, when the vehicle executes the lane change according to the planned lane change path, adjusting speed and direction in real time during the operation to ensure a smooth transition. During the lane change process, the vehicle continuously monitors lane change safety. If sufficient lane change space exists, the vehicle's position and direction are gradually updated according to the predetermined lane change trajectory to complete the lane change. If insufficient lane change space exists, the vehicle maintains the current lane and continuously monitors the surrounding environment until the lane change conditions are met before executing the lane change operation.
[0106] Example 2
[0107] See Figure 1-Figure 4This embodiment is a further optimization based on the first embodiment. In actual applications, weather factors are one of the important factors affecting road congestion. The calculation formula for lane traffic congestion probability based on weather conditions is as follows:
[0108]
[0109] : Current traffic flow (vehicles / hour);
[0110] : road capacity on a sunny day (normal condition), which is determined by the road design parameters;
[0111] : Weather impact factor, reflecting the reduction effect of different weather conditions on road capacity. Common values are:
[0112] sunny: ;
[0113] rain: (The road is slippery and visibility is reduced). The specific value is selected according to the change of rainfall;
[0114] Snowy days: (Snow accumulation causes a significant decrease in traffic capacity), the specific value is selected according to the changes in snowfall;
[0115] Foggy Days: (Low visibility affects vehicle speed), the specific value is selected according to changes in visibility;
[0116] : Sensitivity coefficient (usually 5 to 10), used to control the steepness of the summary curve. In this embodiment, , in actual application, it needs to be calibrated according to historical data.
[0117] In S002, when the number of target lanes that can be reached is greater than 0, it indicates that there are other lanes that can reach the target lane in the current road section. At the same time, if there is a target lane that can be reached in special weather conditions (except sunny days), according to the occupancy rate and traffic jam probability The value of is used to select the appropriate target lane.
[0118] The probability that lane congestion can be caused by weather conditions and occupancy rate of the reachable target lane If they are triggered independently, the total lane congestion probability when the two act together is .
[0119] ;
[0120] In this embodiment, select The smallest achievable target lane can balance the real-time congestion risk and weather impact.
[0121] Further optimization, during special time (morning and evening peak hours), the The value increases significantly and needs to be updated in time according to actual conditions.
[0122] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0123] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. It should be pointed out that any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A simulation method for vehicle safe lane-changing strategy based on Unity, characterized by: The following steps are involved: Step 1: Obtain the vehicle's current lane and target lane information; Step 2: Determine lane change requirements; Step 3, select the target lane: If lane change is required, select a suitable target lane as the lane change direction; Step 4, lane change execution: During the lane change process, the distance between the surrounding vehicles and the current vehicle is detected in real time to determine whether to execute the lane change operation; Step 5: After the lane change is successful, update the vehicle status information; The step 2 specifically includes: detecting whether the current lane can reach the target lane; if the target lane cannot be reached, setting the lane change flag to 1 to indicate that a lane change operation is required; if the target lane can be reached, ending the lane change; The step 4 specifically includes taking into account the parallel situation of vehicles in the left and right lanes and performing safety detection during the lane change process; The safety detection method includes: S0001, with the coordinates of the vehicle as the center point Extend the bounding box in the direction of the required lane change , and set the collision detection object to "vehicle level", Represents the distance offset between the current lane and the lane change lane; S0002, start the collision detection within the current range. If the collision detection result is greater than 0, it means that there are other vehicles in the lane change direction. Lane change is temporarily not allowed. It is necessary to continue to execute the detection mechanism and set the lane change urgency , waiting for the right time to change lanes; If the collision detection result is equal to 0, it means there is no other vehicle in the lane change direction, and the lane change operation is allowed; like When it is 0.1, it means that the intersection is about to be reached and a new route needs to be reallocated based on the current lane; In the above process, the calculation formula of the vehicle lane change urgency is as follows: in, is the urgency proportional factor, which is used to adjust the weight range of the lane change urgency; is the distance between the vehicle and the end point of the current lane; Represents the length of the current lane.
2. The method for simulating a safe lane-changing strategy for a vehicle based on Unity according to claim 1, characterized in that: The step 2 further specifically includes determining whether a lane change operation is required by detecting whether there is an obstacle in the current lane, calculating whether the current lane is connected to the target lane, and detecting whether there is a road congestion.
3. The method for simulating a safe lane-changing strategy for a vehicle based on Unity according to claim 2, characterized in that: The method to detect whether there is an obstacle in the current lane is as follows: S1, emitting rays from the front of the vehicle to obtain information about the object detected by the rays; S2, determining whether the object level is one of the "obstacle" level or the "traffic safety facility" level based on the object information; if so, determining that there is an obstacle or a traffic safety facility ahead, and setting the lane change flag to 1, indicating that a lane change operation is required; S3, if not, you can continue to move forward.
4. The method for simulating a safe lane-changing strategy for a vehicle based on Unity according to claim 2, characterized in that: The method for detecting whether a road is blocked is as follows: S01, when a vehicle enters a lane, it is added to the queue of the current lane; S02, when detecting lane change, calculates the occupancy rate of the current lane according to the occupancy rate formula. If the occupancy rate exceeds the threshold, it indicates that the current lane is congested; S03: If there is a congestion, the lane change flag is set to 1, indicating that a lane change operation needs to be performed.
5. The method for simulating a safe lane-changing strategy for a vehicle based on Unity according to claim 2, characterized in that: The step 3 specifically includes, when the lane change flag is 1, indicating that a lane change is required, calculating the target lane for the vehicle to change lane, and the calculation method is: S001, calculating the lane IDs of all lanes in the current lane that can reach the target lane based on the road ID of the current lane and the lane-to-lane connection information; S002: When the number of reachable target lanes is greater than 0, it indicates that there are other lanes in the current road section that can reach the target lane. The occupancy rate of each reachable target lane is calculated, and the reachable target lane with the lowest occupancy rate is selected as the lane for lane change. S003: If the number of reachable target lanes is equal to 0, then the lane change is terminated.
6. The method for simulating safe lane-changing strategies for a vehicle based on Unity according to claim 1, characterized in that: The step 4 also includes, when the vehicle performs the lane changing action according to the planned lane changing path, adjusting the speed and direction in real time during the operation to ensure a smooth transition.
Citation Information
Patent Citations
Processing method for jointly judging traffic jam state based on integral system
CN111353418A
Simulation control method and device for vehicle lane changing, storage medium and electronic equipment
CN113239470A