Virtual Reality Collision Detection Based on Improved Ant Colony Algorithm
Abstract
:1. Introduction
2. Construction of the Bounding Volume Hierarchy
Optimization of the Traditional Method of Constructing an OBB Bounding Box
- (1)
- The vertex coordinates of the triangular patch are added and divided by the number to obtain the mean value, and then the covariance of the vertex’s coordinate vector is calculated, the mathematical model is derived from Yu Mei’s article [11].
- (2)
- Three eigenvectors of the covariance matrix C are obtained, which are orthogonal to each other. In order to determine the three axial coordinates of the OBB bounding box, the feature vector is unitized. The difference between the maximum and minimum projection values on the coordinate axis is the size of the OBB bounding box.
- (3)
- The coordinates obtained above are in the local coordinate system and need to be converted into global coordinates. Finally, the combined centroid coordinates are
3. An Improved Ant Colony Algorithm Based on Random Collision Detection
3.1. The Random Collision Detection Algorithm
3.2. Random Collision Detection in the 3D Model
3.3. The Traditional Ant Colony Algorithm
3.4. Optimization of the Ant Colony Algorithm
- (1)
- When selecting the next node, the ant is required to compute the transition probability of all the adjacent nodes linked to the current node and then select the route with the highest probability. The main factors affecting the probability of a transition are the factor of the pheromone’s influence and the expectation heuristic factor . The pheromone’s concentration and volatilization status in the ant colony algorithm are different in different stages: a low pheromone concentration and easy volatilization in the early stage; in the later stages, the concentration of pheromones is high and difficult to volatilize, but the traditional ant colony algorithm does not distinguish the ant colony’s state. The values of the parameters , are fixed, and the ant colony algorithm is more likely to fall into the local optimal solution in this case [28].
- (2)
- The volatilization factor represents the degree of volatilization or the reduction in the concentration of pheromones. When the factor is too large, the degree of pheromone volatilization will be accelerated, and the convergence speed of the algorithm will be reduced. If the factor is too small, this will reduce the speed of pheromone volatilization, resulting in too many pheromones and the algorithm falling into the local optimal solution. The value of the factor of volatility in the traditional ant colony algorithm is fixed, so it needs to be improved to make it change dynamically. The algorithm should make the volatile factor larger in the early stage, so that the algorithm has a strong global search ability; in the mature stage, the volatilization factor should be gradually reduced to accelerate the convergence speed of the algorithm:
- (3)
- The reciprocal of the distance between the two nodes is the heuristic factor . The shorter the distance between the two nodes, the larger the heuristic factor, and the higher the probability that the ants will choose the path. However, this relationship can easily make the ants fall into the local optimal solution. In this study, the heuristic factor was improved, and the influence of the position of the starting point and the end point on the probability of an ant selecting it is included in the formula as follows:
- (4)
- The pheromone update rules greatly affect the efficiency of the ant colony in finding the optimal path, and all the ants in the traditional ant colony algorithm simply update their pheromones after reaching the end point, and the advantages of ants walking through shorter paths are not strongly reflected. Therefore, this study improved the pheromone update strategy and added a reward and punishment mechanism, strengthening the pheromone of an excellent path and weakening the pheromone of a poor path.
4. Flow of the Algorithm
- (1)
- Establish a hierarchical bounding box for the target part to be detected and traverse the hierarchical bounding box to see whether the leaf nodes intersect.
- (2)
- If there is a collision between the leaf nodes, feature sampling is performed on the primitive patches between the collision nodes to form a two-dimensional discrete search space.
- (3)
- Initialize the ant population M, the pheromone intensity, visibility, population location and number of iterations of the algorithm.
- (4)
- Calculate the optimal solution of each ant and the current global optimal solution and select the optimal solution after a comparison.
- (5)
- To meet the final requirements, output the best individual that meets the collision threshold.
- (6)
- Conduct the next test.
5. Experiment and Results
5.1. Experiment
- (1)
- Wang Yu believes that the number of feature pairs is an important factor affecting the performance of collision detection algorithms and has done a series of experiments to verify his conjecture [29]. The performance of the sphere-OBB-MACO algorithm in terms of detecting collisions under different feature pairs was simulated. Five feature pairs were selected to detect collisions using the sphere-OBB-MACO algorithm. The two objects with the longest motion time were selected for detection. Table 1 shows the time of collision detection.
- (2)
- In order to verify the impact of the ant colony’s size on the performance of the collision algorithm, different ant colony sizes were selected, and the sphere-OBB-MACO algorithm was used for training on collisions of the equipment of a veneer production line.
- (3)
- We selected the equipment of a veneer production line for the problem of detecting collisions. The number of feature pairs was 50002, the ant colony size = 60, the initial pheromone influence factor and the expected heuristic factor , the maximum number of iterations = 100 and the set value = 50. Three algorithms, namely sphere-OBB (the hierarchical bounding box algorithm), sphere-OBB-ACO and sphere-OBB-MACO, were compared and analyzed, and the final results are shown in Figure 4.
- (4)
- In the fourth experiment, Smagulovak’s BOX-LSTM algorithm [30], Shen Xue Li’s BOX-PSO algorithm [31], JIN Yan-Xia’s BOX-DNN algorithm [32] were selected for comparison with the algorithm designed in this paper so as to judge whether the algorithm designed in this paper was superior to the algorithms designed by other researchers.
5.2. Analysis of the Results
6. Conclusions
- (1)
- Detecting collisions of flexible objects. The improved algorithm in this study is limited to rigid objects, but the detection of collisions between flexible objects is more difficult.
- (2)
- In a simple scenario, due to the small number of models and the simple structure, particle swarm optimization could be used to solve the optimization problem. For detecting collisions between convex polyhedrons, a faster genetic algorithm should be used to solve the optimization problem.
- (1)
- Optimization of the complexity of the hierarchical tree’s structure space. The sphere-OBB structure requires more storage space than a single bounding box structure. In the future, the storage space of the hierarchical tree needs to be optimized.
- (2)
- Optimization of ant colony algorithm. In this study, the pheromone update rules and the correlation coefficients of the ant colony algorithm were improved to optimize the ant colony algorithm. In the future, other intelligent algorithms could be introduced to optimize the ant colony algorithm.
- (3)
- In the future, the acceleration of computer hardware could be studied to further improve the efficiency of detection.
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Zhang, C.; Mu, C.; Wang, Y.; Li, J.; Liu, Z. Collision detection for six-DOF serial robots force/position hybrid control based on continuous friction model. Meas. Control. 2023, 56, 571–582. [Google Scholar] [CrossRef]
- Song, S.; Lan, L.; Yao, J.; Guo, X. Continuous collision detection with medial axis transform for rigid body simulation. Commun. Inf. Syst. 2022, 22, 53–78. [Google Scholar] [CrossRef]
- Wu, D.; Yu, Z.; Adili, A.; Zhao, F. A Self-Collision Detection Algorithm of a Dual-Manipulator System Based on GJK and Deep Learning. Sensors 2023, 23, 523. [Google Scholar] [CrossRef] [PubMed]
- Dyllong, E.; Luther, W. The GJK Distance Algorithm: An Interval Version for Incremental Motions. Numer. Algorithms 2004, 37, 127–136. [Google Scholar] [CrossRef]
- Hu, A.; He, Y. Research on hybrid collision detection algorithm based on separation distance. J. Phys. Conf. Ser. 2022, 2258, 012011. [Google Scholar] [CrossRef]
- Meister, D.; Ogaki, S.; Benthin, C.; Doyle, M.J.; Guthe, M.; Bittner, J. A Survey on Bounding Volume Hierarchies for Ray Tracing. Comput. Graph. Forum 2021, 2, 683–712. [Google Scholar] [CrossRef]
- Gandotra, S.; Pungotra, H.; Moudgil, P.K. Representation of model for efficient collision detection in virtual reality environment. Int. J. Precis. Technol. 2020, 9, 335. [Google Scholar] [CrossRef]
- Jin, Y.; Geng, J.; He, Z.; Lv, C.; Zhao, T. A capsule-based collision detection approach of irregular objects in virtual maintenance. Assem. Autom. 2021, 41, 89–105. [Google Scholar] [CrossRef]
- Mavrovouniotis, M.; Yang, S. Ant algorithms with immigrants schemes for the dynamic vehicle routing problem. Inf. Sci. 2015, 294, 456–477. [Google Scholar] [CrossRef]
- Adery, L.H.; Ichinose, M.; Torregrossa, L.J.; Wade, J.; Nichols, H.; Bekele, E.; Bian, D.; Gizdic, A.; Granholm, E.; Sarkar, N.; et al. The acceptability and feasibility of a novel virtual reality based social skills training game for schizophrenia: Preliminary findings. Psychiatry Res. 2018, 270, 496–502. [Google Scholar] [CrossRef]
- Ding, X.J. Research on Collision Detection Algorithm Based on OBB. Appl. Mech. Mater. 2013, 2755, 433–435. [Google Scholar] [CrossRef]
- Xiong, Y.M.; Chen, Y.M.; Chen, Y.H. Research on Bounding Box-Tree Algorithm for Collision Detection. Adv. Mater. Res. 2011, 186, 645–649. [Google Scholar] [CrossRef]
- Shang, Y.; Wang, H.; Qin, W.; Wang, Q.; Liu, H.; Yin, Y.; Song, Z.; Meng, Z. Design and Test of Obstacle Detection and Harvester Pre-Collision System Based on 2D Lidar. Agronomy 2023, 13, 388. [Google Scholar] [CrossRef]
- Hwang, A.D.; Peli, E.; Jung, J.H. Development of Virtual Reality Walking Collision Detection Test on Head-mounted display. In Proceedings of the SPIE—The International Society for Optical Engineering, San Francisco, CA, USA, 30 January–2 February 2023; p. 12449. [Google Scholar]
- Zhang, X.; Liu, J. Research on Collision Detection Algorithm for Human-SRL Collaborative Motion Planning. J. Phys. Conf. Ser. 2022, 2402, 012021. [Google Scholar] [CrossRef]
- Hao, T.; Liu, Y.; Gong, X.; Kong, D.; Wang, J. Visibility Detection of 3D Objects and Visual K-Nearest Neighbor Query Based on Convex Hull Model. Math. Probl. Eng. 2022, 2022, 8302974. [Google Scholar] [CrossRef]
- Hariyono, J.; Kurnianggoro, L.; Jo, K.H. Analysis of Pedestrian Collision Risk using Fuzzy Inference Model. In Proceedings of the 16th International Conference on Control, Automation and Systems (ICCAS), Gyeongju, Kore, 16–19 October 2016. 제어로봇시스템학회 국제학술대회 논문집. [Google Scholar]
- Huang, Z.; Yang, X.; Min, J.; Wang, H.; Wei, P. Collision detection algorithm on abrasive belt grinding blisk based on improved octree segmentation. Int. J. Adv. Manuf. Technol. 2021, 118, 11–12. [Google Scholar] [CrossRef]
- Cheng, S.; Qu, H. Key Issues of Real-time Collision Detection in Virtual Reality. Int. J. Front. Eng. Technol. 2021, 3, 43–49. [Google Scholar]
- Hu, Y.; Yan, Z.; Yin, Z.; Du, Z. Collision detection based on octree for virtual surgery system. IOP Conf. Ser. Mater. Sci. Eng. 2020, 7, 072107. [Google Scholar] [CrossRef]
- Wang, M.; Mao, Z.; Ma, Y.; Cao, J. Stable and efficient collision detection scheme for hip-surgery training system. Clust. Comput. J. Netw. Softw. Tools Appl. 2019, 22, 8769–8781. [Google Scholar] [CrossRef]
- Kim, M.; Sung, N.J.; Kim, S.J.; Choi, Y.J.; Hong, M. Parallel cloth simulation with effective collision detection for interactive AR application. Multimed. Tools Appl. 2019, 78, 4851–4868. [Google Scholar] [CrossRef]
- Giang, T.; O’sullivan, C. Approximate collision response using closest feature maps. Comput. Graph. 2006, 30, 423–431. [Google Scholar] [CrossRef]
- Wong, W.; Liu, W.; Bennamoun, M. Tree-Traversing Ant Algorithm for term clustering based on featureless similarities. Data Min. Knowl. Discov. 2007, 15, 349–381. [Google Scholar] [CrossRef]
- Dorigo, V.M. Maniezzo, Distributed Optimization by Ant Colonies. In Proceedings of the 1st European Conference on Artificial Life, Paris, France, 11–13 December 1991; Elsevier Publishing: Amsterdam, The Netherlands, 1991; pp. 134–142. [Google Scholar]
- Su, Y.; Bai, Z.; Xie, D. The optimizing resource allocation and task scheduling based on cloud computing and Ant Colony Optimization Algorithm. J. Ambient. Intell. Humaniz. Comput. 2021. [Google Scholar] [CrossRef]
- Zhang, H.; Gao, Y. Solving TSP based on an Improved Ant Colony Optimization Algorithm. J. Phys. Conf. Ser. 2021, 1982, 012061. [Google Scholar] [CrossRef]
- Gao, W. New Ant Colony Optimization Algorithm for the Traveling Salesman Problem. Int. J. Comput. Intell. Syst. 2020, 13, 44–55. [Google Scholar] [CrossRef]
- Yu, W.; Linjuan, M.; Fuquan, Z. Virtual reality collision detection method based on quantum ant colony algorithm. J. Nanjing Univ. Sci. Technol. 2022, 46, 735–741. [Google Scholar] [CrossRef]
- Smagulova, K.; James, A.P. Asurvey on LSTM memristive neural network architectures and applications. Eur. Phys. J. Spec. Top. 2019, 228, 2312–2324. [Google Scholar] [CrossRef]
- Shen, X.; Zhang, J.S. Research of collision detection algorithm based on particle swarm optimization. Int. Conf. Comput. Des. Appl. 2010, 1, V1-60–V1-63. [Google Scholar]
- Jin, Y.; Cheng, Q.; Zhang, J. Fusion of DNN and AABB-circular bounding box self-collision detection. Chin. J. Image Graph. 2020, 1674–1683. [Google Scholar]
Duration/ms | ||||
---|---|---|---|---|
Number of Characteristic Pairs | Detection Rate 20% | Detection Rate 40% | Detection Rate 60% | Detection Rate 80% |
10002 | 5.1 | 8.4 | 10.6 | 13.4 |
20002 | 7.0 | 11.1 | 12.9 | 16.4 |
30002 | 9.2 | 13.4 | 16.1 | 20.8 |
40002 | 12.3 | 15.6 | 18.5 | 22.0 |
50002 | 14.1 | 17.2 | 20.5 | 27.3 |
(A/B) % | ||||
---|---|---|---|---|
Number of Characteristic Pairs | Detection Rate 20% | Detection Rate 40% | Detection Rate 60% | Detection Rate 80% |
10002 | 7.3 | 15.2 | 22.1 | 30.2 |
20002 | 10 | 21.2 | 34.3 | 45.6 |
30002 | 13.3 | 27.8 | 39.6 | 51.2 |
40002 | 16.2 | 35.9 | 55.1 | 62.7 |
50002 | 20.0 | 44.1 | 65.4 | 85.3 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Xu, P.; Sun, Q. Virtual Reality Collision Detection Based on Improved Ant Colony Algorithm. Appl. Sci. 2023, 13, 6366. https://doi.org/10.3390/app13116366
Xu P, Sun Q. Virtual Reality Collision Detection Based on Improved Ant Colony Algorithm. Applied Sciences. 2023; 13(11):6366. https://doi.org/10.3390/app13116366
Chicago/Turabian StyleXu, Peng, and Qingyun Sun. 2023. "Virtual Reality Collision Detection Based on Improved Ant Colony Algorithm" Applied Sciences 13, no. 11: 6366. https://doi.org/10.3390/app13116366
APA StyleXu, P., & Sun, Q. (2023). Virtual Reality Collision Detection Based on Improved Ant Colony Algorithm. Applied Sciences, 13(11), 6366. https://doi.org/10.3390/app13116366