Skip to content

Commit 0f34eed

Browse files
committed
Merge pull request #187 from yianni/rcc4
Rcc4
2 parents 8154129 + f4c9aa1 commit 0f34eed

19 files changed

+186
-7
lines changed

docs/rsts/handwritten/qsrs/qsrs.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Supported QSRs
1313
qtccs
1414
qtcbcs
1515
rcc2
16-
rcc3
16+
rcc4
1717
rcc5
1818
rcc8
1919

@@ -41,7 +41,7 @@ Currently, the following QSRs are supported:
4141
+----------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------+----------------+
4242
| **rcc2** | Region Connection Calculus 2 | :doc:`descr. <rcc2>` \| :mod:`api <qsrlib_qsrs.qsr_rcc2>` | [2]_ [3]_ |
4343
+----------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------+----------------+
44-
| **rcc3** | Region Connection Calculus 3 | :doc:`descr. <rcc3>` \| :mod:`api <qsrlib_qsrs.qsr_rcc3>` | [2]_ [3]_ |
44+
| **rcc4** | Region Connection Calculus 4 | :doc:`descr. <rcc4>` \| :mod:`api <qsrlib_qsrs.qsr_rcc4>` | [2]_ [3]_ |
4545
+----------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------+----------------+
4646
| **rcc5** | Region Connection Calculus 5 | :doc:`descr. <rcc5>` \| :mod:`api <qsrlib_qsrs.qsr_rcc5>` | [2]_ [3]_ |
4747
+----------------+---------------------------------------------------+---------------------------------------------------------------------------------------------------------+----------------+

docs/rsts/handwritten/qsrs/rcc3.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/rsts/handwritten/qsrs/rcc4.rst

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
Region Connection Calculus 4
3+
============================
4+
5+
The Region Connection Calculus (RCC) [1]_ [2]_ is intended to serve for qualitative spatial representation and reasoning.
6+
RCC abstractly describes regions (in Euclidean space, or in a topological space) by their possible relations to
7+
each other.
8+
9+
RCC4 consists of 4 basic relations that are possible between two regions; it is a stripped down version
10+
of :doc:`RCC8 <rcc8>`. The mapping from RCC8 to RCC4 can be seen below:
11+
12+
13+
+------------+------------+
14+
| RCC8 | RCC4 +
15+
+============+============+
16+
| dc | dc |
17+
+------------+------------+
18+
| ec | po |
19+
+------------+ +
20+
| po | |
21+
+------------+------------+
22+
| tpp | pp |
23+
+------------+ +
24+
| ntpp | |
25+
+------------+ +
26+
| eq | |
27+
+------------+------------+
28+
| tppi | ppi |
29+
+------------+ +
30+
| ntppi | |
31+
+------------+------------+
32+
33+
34+
Relations
35+
---------
36+
37+
All the possible RCC4 relations between a blue object X and a red object Y are:
38+
39+
+-------------------+------------------------------------------------+-------------------------------------------------+
40+
| Relation | Illustration | Interpretation +
41+
+===================+================================================+=================================================+
42+
| X **dc** Y | .. image:: ../images/rcc8_dc.png | X is disconnected from Y. |
43+
+-------------------+------------------------------------------------+-------------------------------------------------+
44+
| X **po** Y | .. image:: ../images/rcc8_ec.png | X is partially overlapping Y. |
45+
+ +------------------------------------------------+ +
46+
| | .. image:: ../images/rcc8_po.png | |
47+
+-------------------+------------------------------------------------+-------------------------------------------------+
48+
| X **pp** Y | .. image:: ../images/rcc8_tpp.png | X is a proper part of Y. |
49+
+ +------------------------------------------------+ +
50+
| | .. image:: ../images/rcc8_ntpp.png | |
51+
+ +------------------------------------------------+ +
52+
| | .. image:: ../images/rcc8_eq.png | |
53+
+-------------------+------------------------------------------------+-------------------------------------------------+
54+
| X **ppi** Y | .. image:: ../images/rcc8_tppi.png | X is a proper part inverse of Y. |
55+
+ +------------------------------------------------+ +
56+
| | .. image:: ../images/rcc8_ntppi.png | |
57+
+-------------------+------------------------------------------------+-------------------------------------------------+
58+
59+
60+
API
61+
---
62+
63+
The API can be found :mod:`here <qsrlib_qsrs.qsr_rcc4>`.
64+
65+
66+
References
67+
----------
68+
.. [1] Randell, D. A., Cui, Z. and Cohn, A. G.: A spatial logic based on regions and connection, Proc. 3rd Int. Conf. on Knowledge Representation and Reasoning, Morgan Kaufmann, San Mateo, pp. 165–176, 1992. `(link) <http://wenxion.net/ac/randell92spatial.pdf>`_
69+
.. [2] Anthony G. Cohn, Brandon Bennett, John Gooday, Micholas Mark Gotts: Qualitative Spatial Representation and Reasoning with the Region Connection Calculus. GeoInformatica, 1, 275–316, 1997.

docs/rsts/handwritten/qsrs/rcc5.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ of :doc:`RCC8 <rcc8>`. The mapping from RCC8 to RCC5 can be seen below:
1212
+------------+------------+
1313
| RCC8 | RCC5 +
1414
+============+============+
15-
| dc | dr |
15+
| dc | dr |
1616
+------------+ +
1717
| ec | |
1818
+------------+------------+
1919
| po | po |
2020
+------------+------------+
21-
| tpp | pp |
21+
| tpp | pp |
2222
+------------+ +
2323
| ntpp | |
2424
+------------+------------+
2525
| eq | eq |
2626
+------------+------------+
27-
| tppi | ppi |
27+
| tppi | ppi |
2828
+------------+ +
2929
| ntppi | |
3030
+------------+------------+

qsr_lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ if (CATKIN_ENABLE_TESTING)
5151
add_rostest(tests/ra_tester.test)
5252
add_rostest(tests/rcc2_tester.test)
5353
add_rostest(tests/rcc3_tester.test)
54+
add_rostest(tests/rcc4_tester.test)
5455
add_rostest(tests/rcc5_tester.test)
5556
add_rostest(tests/rcc8_tester.test)
5657
# add_rostest(tests/multiple_tester.test)

qsr_lib/src/qsrlib_qsrs/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from qsr_rcc2 import QSR_RCC2
22
from qsr_rcc3_rectangle_bounding_boxes_2d import QSR_RCC3_Rectangle_Bounding_Boxes_2D
3+
from qsr_rcc4 import QSR_RCC4
34
from qsr_rcc5 import QSR_RCC5
45
from qsr_rcc8 import QSR_RCC8
56
from qsr_cardinal_direction import QSR_Cardinal_Direction
@@ -15,6 +16,7 @@
1516
# register new qsrs by class name below
1617
qsrs_registry = (QSR_RCC2,
1718
QSR_RCC3_Rectangle_Bounding_Boxes_2D,
19+
QSR_RCC4,
1820
QSR_RCC5,
1921
QSR_RCC8,
2022
QSR_Cardinal_Direction,

qsr_lib/src/qsrlib_qsrs/qsr_rcc3_rectangle_bounding_boxes_2d.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
class QSR_RCC3_Rectangle_Bounding_Boxes_2D(QSR_RCC_Abstractclass):
77
"""RCC3 relations.
88
9+
.. warning::
10+
RCC3 is deprecated. Use RCC4 instead.
11+
912
Values of the abstract properties
1013
* **_unique_id** = "rcc3"
1114
* **_all_possible_relations** = ("dc", "po", "o")

qsr_lib/src/qsrlib_qsrs/qsr_rcc4.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import print_function, division
3+
from qsrlib_qsrs.qsr_rcc_abstractclass import QSR_RCC_Abstractclass
4+
5+
6+
class QSR_RCC4(QSR_RCC_Abstractclass):
7+
"""Computes symmetrical RCC4 relations"""
8+
9+
_unique_id = "rcc4"
10+
11+
_all_possible_relations = ("dc", "po", "pp", "ppi")
12+
13+
__mapping_from_rcc8 = {"dc": "dc",
14+
"ec": "po",
15+
"po": "po",
16+
"tpp": "pp",
17+
"ntpp": "pp",
18+
"eq": "pp",
19+
"tppi": "ppi",
20+
"ntppi": "ppi"}
21+
22+
def __init__(self):
23+
super(QSR_RCC4, self).__init__()
24+
25+
def _convert_to_requested_rcc_type(self, qsr):
26+
return self.__mapping_from_rcc8[qsr]

qsr_lib/tests/data/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,23 @@ and random float width and length (`random.randint(3, 6)`) (i.e. bounding boxes
88
but no width and length are given (i.e. no bounding boxes are provided).
99
* `data4.csv`: A set of 10K random float 2D-points (`random.uniform(0, 50)`) for 3 objects ("o1", "o2", "o3")
1010
and random float width and length (`random.randint(3, 6)`) (i.e. bounding boxes are provided).
11+
12+
### Running the tests
13+
14+
```bash
15+
rosrun qsr_lib unittests_generate_ground_truth.py -i <world name> -o <output filename> <qsr>
16+
```
17+
18+
E.g.
19+
```bash
20+
rosrun qsr_lib unittests_generate_ground_truth.py -i data1 -o qsr_lib/tests/data/data1_rcc4_defaults.txt rcc4
21+
```
22+
23+
`-i` options: data1 | data2 | data3 | data4
24+
25+
#### Types of generated data
26+
27+
* Defaults. E.g.
28+
```bash
29+
rosrun qsr_lib unittests_generate_ground_truth.py -i data1 -o qsr_lib/tests/data/data1_rcc4_defaults.txt rcc4
30+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["1.0,o1,o2,{'rcc4': 'po'}", "2.0,o1,o2,{'rcc4': 'po'}", "3.0,o1,o2,{'rcc4': 'po'}", "4.0,o1,o2,{'rcc4': 'po'}", "5.0,o1,o2,{'rcc4': 'po'}", "6.0,o1,o2,{'rcc4': 'po'}", "7.0,o1,o2,{'rcc4': 'po'}", "8.0,o1,o2,{'rcc4': 'po'}", "9.0,o1,o2,{'rcc4': 'po'}", "10.0,o1,o2,{'rcc4': 'po'}", "11.0,o1,o2,{'rcc4': 'po'}", "12.0,o1,o2,{'rcc4': 'po'}", "13.0,o1,o2,{'rcc4': 'po'}", "14.0,o1,o2,{'rcc4': 'po'}", "15.0,o1,o2,{'rcc4': 'po'}", "16.0,o1,o2,{'rcc4': 'po'}", "17.0,o1,o2,{'rcc4': 'po'}", "18.0,o1,o2,{'rcc4': 'po'}", "19.0,o1,o2,{'rcc4': 'po'}", "20.0,o1,o2,{'rcc4': 'po'}", "21.0,o1,o2,{'rcc4': 'po'}", "22.0,o1,o2,{'rcc4': 'po'}", "23.0,o1,o2,{'rcc4': 'po'}", "24.0,o1,o2,{'rcc4': 'po'}", "25.0,o1,o2,{'rcc4': 'pp'}", "26.0,o1,o2,{'rcc4': 'po'}", "27.0,o1,o2,{'rcc4': 'po'}", "28.0,o1,o2,{'rcc4': 'po'}", "29.0,o1,o2,{'rcc4': 'po'}", "30.0,o1,o2,{'rcc4': 'po'}", "31.0,o1,o2,{'rcc4': 'po'}", "32.0,o1,o2,{'rcc4': 'po'}", "33.0,o1,o2,{'rcc4': 'po'}", "34.0,o1,o2,{'rcc4': 'po'}", "35.0,o1,o2,{'rcc4': 'po'}", "36.0,o1,o2,{'rcc4': 'po'}", "37.0,o1,o2,{'rcc4': 'po'}", "38.0,o1,o2,{'rcc4': 'po'}", "39.0,o1,o2,{'rcc4': 'po'}", "40.0,o1,o2,{'rcc4': 'po'}", "41.0,o1,o2,{'rcc4': 'po'}", "42.0,o1,o2,{'rcc4': 'po'}", "43.0,o1,o2,{'rcc4': 'po'}", "44.0,o1,o2,{'rcc4': 'po'}", "45.0,o1,o2,{'rcc4': 'po'}", "46.0,o1,o2,{'rcc4': 'po'}", "47.0,o1,o2,{'rcc4': 'po'}", "48.0,o1,o2,{'rcc4': 'po'}", "49.0,o1,o2,{'rcc4': 'po'}"]

0 commit comments

Comments
 (0)