# 邻近查询包（Proximity Query Package）

**邻近查询包**（Proximity Query Package，PQP）是一个C++软件库，用于在由三角形构成的几何模型上执行三类邻近查询：碰撞检测、距离计算和容差验证。它由[北卡罗来纳大学教堂山分校](https://www.edgepedia.org/zh/university-of-north-carolina-at-chapel-hill)的埃里克·拉森（Eric Larsen）和斯特凡·戈特沙尔克（Stefan Gottschalk）编写，版本1.3的版权年份为1999年，并建立在[OBB树](https://www.edgepedia.org/zh/obbtree)包围体层次结构以及UNC几何计算组开发的矩形扫掠球体之上。<sup>[1](https://github.com/motion-planning/pqp)</sup>

| 关键事实 | 详情 |
|---|---|
| 支持的查询 | 碰撞检测（可选报告哪些三角形重叠）、距离计算和容差验证<sup>[1](https://github.com/motion-planning/pqp)</sup> |
| 输入模型 | 三角网格；PQP只处理三角形，并会三角化其他多边形面<sup>[1](https://github.com/motion-planning/pqp)</sup><sup> • </sup><sup>[6](https://www.openrobots.org/move3d/doc/group__pqp.html)</sup> |
| 包围体 | 距离和容差查询默认使用矩形扫掠球体（RSS）；碰撞检测使用有向包围盒（OBB）<sup>[1](https://github.com/motion-planning/pqp)</sup> |
| 版本 | 1.3，发布历史中的最终版本，增加了`isnan()` NaN测试，取代一个有时会被优化掉的比较<sup>[1](https://github.com/motion-planning/pqp)</sup> |
| 许可 | 教育、研究和非营利用途免费；北卡罗来纳大学教堂山分校不提供担保，也不承担维护义务<sup>[1](https://github.com/motion-planning/pqp)</sup> |
| 奠基论文 | 《OBB树：一种用于快速干涉检测的层次结构》（SIGGRAPH 1996）和《使用扫掠球体的快速邻近查询》（UNC技术报告TR99-018）<sup>[1](https://github.com/motion-planning/pqp)</sup> |

## 查询类型

该库在模型对之间执行三类查询<sup>[1](https://github.com/motion-planning/pqp)</sup>：

1. **碰撞检测**判断两个模型是否重叠，并可选地判断模型的哪些三角形重叠。
2. **距离计算**返回两个模型之间的距离，定义为使模型重叠的最短平移长度。
3. **容差验证**检测两个模型之间的距离是小于还是大于用户提供的容差值。

这一定义在实践中很重要：由于它度量的是使模型重叠的最短平移，而不是点到点的最小值，因此运动规划器用它来判断机器人构型距离接触有多远。封装库直接暴露该距离；例如，BioMove3D的pqp模块提供`pqp_robot_robot_distance`，它返回两个机器人之间的最小距离以及各自最近点。<sup>[6](https://www.openrobots.org/move3d/doc/group__pqp.html)</sup>

## 算法与包围体

**碰撞检测**使用有向包围盒层次结构，即三维空间中任意取向的矩形盒子，按OBB树组织。该树在预处理步骤中构建：递归地为三角形组拟合紧致OBB，并沿最长轴分割；使用凸包拟合时，对n个三角形的构建耗时为O(n log² n)，不使用凸包时为O(n log n)。<sup>[2](https://www.cs.cornell.edu/courses/cs667/2005sp/readings/gottschalk96.pdf)</sup> 运行时，算法遍历两棵树，并使用分离轴定理测试OBB对是否重叠（若能找到一条轴将两个盒子分开，就证明它们不重叠）；该测试平均约需100次操作，实际少于200次，比早期的盒子重叠测试约快一个数量级。OBB树实现能以交互式速率检测由数十万个多边形构成的模型之间的所有接触。<sup>[2](https://www.cs.cornell.edu/courses/cs667/2005sp/readings/gottschalk96.pdf)</sup>

**距离和容差查询**使用矩形扫掠球体层次结构。RSS是球心扫过三维矩形时球体所覆盖的体积，即以原点为中心的球体与任意取向矩形的[闵可夫斯基和](https://www.edgepedia.org/zh/minkowski-sum)；它与底层几何紧密贴合。<sup>[3](https://www.researchgate.net/publication/2364364_Fast_Distance_Queries_with_Rectangular_Swept_Sphere_Volumes)</sup> 配套算法精确计算两个RSS之间的距离，并使用基于连贯性和优先级导向搜索的遍历技术加速查询。对于近似距离计算，当两个包围体之间距离的界无法将当前估计值降低超过可接受的相对或绝对误差时，就终止递归分支。<sup>[3](https://www.researchgate.net/publication/2364364_Fast_Distance_Queries_with_Rectangular_Swept_Sphere_Volumes)</sup> 据报道，这些算法在许多基准测试上相较早期的包围体层次距离方法取得了显著加速，并被应用于虚拟原型、动态仿真和运动规划。<sup>[3](https://www.researchgate.net/publication/2364364_Fast_Distance_Queries_with_Rectangular_Swept_Sphere_Volumes)</sup>

## 在机器人软件中的使用

PQP成为机器人运动规划软件栈中的标准碰撞检测器。OMPL.app是开放运动规划库的前端，包含用于FCL和PQP碰撞检测器的轻量级封装，OMPL演示程序可在`app::FCL`和`app::PQP`状态有效性检查器之间选择。<sup>[4](https://ompl.kavrakilab.org/core/index.html)</sup><sup> • </sup><sup>[5](https://github.com/ompl/omplapp/blob/main/demos/SE3RigidBodyPlanning/CollisionCheckers.cpp)</sup> BioMove3D规划系统直接在该库之上构建其pqp模块，为每个环境对象和机器人本体关联一个`PQP_Model`，并在PQP运行前使用Move3D包围盒作为快速预测试。<sup>[6](https://www.openrobots.org/move3d/doc/group__pqp.html)</sup> 不来梅大学的一个静态碰撞检测算法基准测试套件将PQP纳入其封装的库中，并将其与偏移曲面一起作为可选的距离计算方法提供。<sup>[7](https://cgvr.cs.uni-bremen.de/research/colldet_benchmark/index.shtml)</sup>

## 相对于后续库的性能

基准测试表明，PQP的表现取决于工作负载。一项在路径规划背景下对碰撞检测器的比较得出结论：性能强烈依赖于测试用例。<sup>[8](https://citeseerx.ist.psu.edu/document?doi=084d171f63cfcf83845437f68fee309921fcfa65&repid=rep1&type=pdf)</sup> 在一项拆卸规划研究中，FCL和PQP的BVH实现（二者均来自同一UNC团队）表现几乎相同，并被一起报告。<sup>[9](https://openscience.ub.uni-mainz.de/bitstreams/46efd957-9f0b-458e-9a37-305d6ce52d96/download)</sup> 相比之下，在卡内基梅隆大学一项使用259,135次记录的碰撞检查的移动操作清理桌面任务研究中，FCL的速度是ODE和PQP的6倍，并且在活动自由度和预分配优化后，最快与最慢检查器之间的差距达到27倍。<sup>[10](https://www.andrew.cmu.edu/user/amj1/papers/ISER2016.pdf)</sup> 一则OpenRAVE插件公告同样报告，其基于FCL的检查器的速度是[OpenRAVE](https://www.edgepedia.org/zh/openrave)自带的ODE、Bullet和PQP插件的3到5倍。<sup>[11](https://sourceforge.net/p/openrave/mailman/message/34955013/)</sup>

一项面向触觉的研究测得PQP的碰撞检查时间随网格面数呈对数增长，为O(log n)，并指出一个结构性限制：PQP只处理刚体对象，因为对变形模型每帧更新OBB层次结构至少需要O(n log n)。<sup>[12](https://pmc.ncbi.nlm.nih.gov/articles/PMC9337716/)</sup>

## 源流

PQP源自UNC一系列邻近查询系统。OBB树碰撞算法出现在斯特凡·戈特沙尔克、林明（Ming C. Lin）和[迪内什·马诺查](https://www.edgepedia.org/zh/dinesh-manocha)（Dinesh Manocha）的SIGGRAPH 1996工作中，而同一团队较早的RAPID库构建在OBB树数据结构之上。<sup>[2](https://www.cs.cornell.edu/courses/cs667/2005sp/readings/gottschalk96.pdf)</sup><sup> • </sup><sup>[13](https://groups.google.com/g/comp.graphics.algorithms/c/8Ini_oSEPuc)</sup> 扫掠球距离工作由埃里克·拉森、斯特凡·戈特沙尔克、林明和迪内什·马诺查发表，最初以UNC技术报告TR99-018的形式发表，随后发表于2000年IEEE机器人与自动化国际会议上关于使用矩形扫掠球体进行快速距离查询的一篇论文中。<sup>[1](https://github.com/motion-planning/pqp)</sup><sup> • </sup><sup>[3](https://www.researchgate.net/publication/2364364_Fast_Distance_Queries_with_Rectangular_Swept_Sphere_Volumes)</sup> FCL由同一研究社区于2012年发布，通过统一接口将该方法推广到多种查询类型、模型表示和带噪点云。<sup>[14](https://ieeexplore.ieee.org/document/6225337)</sup>

## References

1. [PQP v1.3 README, motion-planning/pqp repository, GitHub](https://github.com/motion-planning/pqp)
2. [S. Gottschalk, M. C. Lin, D. Manocha (1996). OBBTree: A Hierarchical Structure for Rapid Interference Detection. SIGGRAPH '96, pp. 171–180.](https://www.cs.cornell.edu/courses/cs667/2005sp/readings/gottschalk96.pdf)
3. [E. Larsen, S. Gottschalk, M. C. Lin, D. Manocha (2000). Fast Distance Queries with Rectangular Swept Sphere Volumes. IEEE ICRA 2000.](https://www.researchgate.net/publication/2364364_Fast_Distance_Queries_with_Rectangular_Swept_Sphere_Volumes)
4. [The Open Motion Planning Library, Kavraki Lab](https://ompl.kavrakilab.org/core/index.html)
5. [omplapp demo CollisionCheckers.cpp, GitHub](https://github.com/ompl/omplapp/blob/main/demos/SE3RigidBodyPlanning/CollisionCheckers.cpp)
6. [libmove3d documentation: Pqp module, OpenRobots](https://www.openrobots.org/move3d/doc/group__pqp.html)
7. [A Benchmarking Suite for Static Collision Detection Algorithms, University of Bremen](https://cgvr.cs.uni-bremen.de/research/colldet_benchmark/index.shtml)
8. [Best Practice in Robotics (BRICS), comparison of collision detectors](https://citeseerx.ist.psu.edu/document?doi=084d171f63cfcf83845437f68fee309921fcfa65&repid=rep1&type=pdf)
9. [Rigid and Deformable Motion planning dissertation, University of Mainz](https://openscience.ub.uni-mainz.de/bitstreams/46efd957-9f0b-458e-9a37-305d6ce52d96/download)
10. [Siddhartha Srinivasa et al. (2016). A System for Multi-Step Mobile Manipulation, ISER 2016](https://www.andrew.cmu.edu/user/amj1/papers/ISER2016.pdf)
11. [or_fcl announcement, OpenRAVE users mailing list](https://sourceforge.net/p/openrave/mailman/message/34955013/)
12. [An efficient dynamic point algorithm for line-based collision detection in real time virtual environments involving haptics, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC9337716/)
13. [New collision detection package (RAPID announcement), comp.graphics.algorithms, August 1996](https://groups.google.com/g/comp.graphics.algorithms/c/8Ini_oSEPuc)
14. [J. Pan et al. (2012). FCL: A general purpose library for collision and proximity queries. IEEE ICRA 2012.](https://ieeexplore.ieee.org/document/6225337)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 工程与制造 › 机器人技术与自动化 › Robot software, AI, and methods › Motion planning and collision detection

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/proximity-query-package

English original: https://www.edgepedia.org/proximity-query-package
