Skip to content

Commit 14ec085

Browse files
authored
Merge pull request #366 from SimonRohou/codac2_dev
Quentin's PR (visibility contractor) + updates + binding of contractors + Polygon
2 parents 95b37a1 + 14f7727 commit 14ec085

56 files changed

Lines changed: 1054 additions & 85 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
if(WITH_PYTHON)
88

9-
find_package(Doxygen)
9+
find_package(Doxygen 1.16.1 QUIET)
1010

1111
if(NOT DOXYGEN_FOUND)
1212

13-
message(STATUS "Doxygen not found, not able to generate/install the API documentation.")
13+
message(STATUS "The required version of Doxygen has not been found, the API documentation will not be generated.")
1414

1515
else()
1616

doc/manual/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ User manual
248248
* Geometric contractors
249249
* :ref:`sec-ctc-geom-ctcdist`
250250
* :ref:`sec-ctc-geom-ctcpolar`
251+
* :ref:`sec-ctc-geom-ctcvisible`
251252
* CtcSegment
252253
* CtcPolygon
253254
* CtcPointCloud
@@ -286,6 +287,7 @@ User manual
286287
* SepInverse
287288
* SepTransform
288289
* Geometrical separators
290+
* SepVisible
289291
* SepPolarCart or SepCartPolar
290292
* SepPolygon
291293
* SepEllipse
23.6 KB
Loading
28.2 KB
Loading
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
.. _sec-ctc-geom-ctcvisible:
2+
3+
The CtcVisible and CtcNoVisible contractors
4+
===========================================
5+
6+
Main authors: `Quentin Brateau <https://teusner.github.io/>`_
7+
8+
The visibility constraint characterizes the set of points :math:`\mathbf{x} \in \mathbb{R}^2` that are visible from an observation point :math:`\mathbf{a}` given an obstacle segment :math:`[\mathbf{e}_1\mathbf{e}_2]`.
9+
10+
This constraint is based on the work of **Rémy Guyonneau** (see [Guyonneau2013]_). A point :math:`\mathbf{x}` is considered visible if the segment :math:`[\mathbf{a}\mathbf{x}]` does not intersect the obstacle segment :math:`[\mathbf{e}_1\mathbf{e}_2]`. This creates a "shadow cone" originating from :math:`\mathbf{a}`.
11+
12+
.. image:: visibility.png
13+
:alt: Illustration of the visibility constraint from an observation point [Guyonneau2013]_
14+
:width: 250px
15+
16+
.. image:: novisibility.png
17+
:alt: Illustration of the non-visibility constraint from an observation point [Guyonneau2013]_
18+
:width: 250px
19+
20+
.. doxygenclass:: codac2::CtcVisible
21+
:project: codac
22+
23+
.. doxygenclass:: codac2::CtcNoVisible
24+
:project: codac
25+
26+
.. note::
27+
Current implementations assume a thin (degenerated) observation point :math:`\mathbf{a}`. Future versions will support visibility from **observation lines**, set defined by **convex polygons**, and from any **set** defined by a Separator.
28+
29+
Methods
30+
-------
31+
32+
.. doxygenfunction:: codac2::CtcVisible::contract(IntervalVector&) const
33+
:project: codac
34+
35+
.. doxygenfunction:: codac2::CtcNoVisible::contract(IntervalVector&) const
36+
:project: codac
37+
38+
39+
40+
Example of use: Characterizing the set of visible and non-visible points from an observation point
41+
--------------------------------------------------------------------------------------------------
42+
43+
In this example, we characterize the visible and hidden areas from an observer at the origin :math:`\mathbf{a}=(0,0)^\intercal` facing a wall represented by a segment from :math:`(2, -1)` to :math:`(2, 1)`.
44+
45+
.. tabs::
46+
47+
.. group-tab:: Python
48+
49+
.. literalinclude:: src.py
50+
:language: py
51+
:start-after: [ctcvisible-beg]
52+
:end-before: [ctcvisible-end]
53+
:dedent: 4
54+
55+
.. group-tab:: C++
56+
57+
.. literalinclude:: src.cpp
58+
:language: c++
59+
:start-after: [ctcvisible-beg]
60+
:end-before: [ctcvisible-end]
61+
:dedent: 4
62+
63+
.. figure:: ctcvisible.png
64+
:width: 400px
65+
66+
.. tabs::
67+
68+
.. group-tab:: Python
69+
70+
.. literalinclude:: src.py
71+
:language: py
72+
:start-after: [ctcnovisible-beg]
73+
:end-before: [ctcnovisible-end]
74+
:dedent: 4
75+
76+
.. group-tab:: C++
77+
78+
.. literalinclude:: src.cpp
79+
:language: c++
80+
:start-after: [ctcnovisible-beg]
81+
:end-before: [ctcnovisible-end]
82+
:dedent: 4
83+
84+
Characterization of the visibility area. The points that are not visible are out of the visibility region and belongs to the blue area. The uncertain region is represented in yellow.
85+
86+
.. figure:: ctcnovisible.png
87+
:width: 400px
88+
89+
Characterization of the non-visibility area. The points that are visible are out of the non-visibility region and belongs to the blue area. The uncertain region is represented in yellow.
90+
91+
Separator on the Visibility Constraint
92+
---------------------------------------
93+
94+
The visibility constraint can also be applied as a separator, which allows us to characterize the set of points that are visible or not visible from an observation point. This is particularly useful for applications such as path planning, where one needs to determine the regions that are accessible or hidden from a certain viewpoint.
95+
96+
.. tabs::
97+
98+
.. group-tab:: Python
99+
100+
.. literalinclude:: src.py
101+
:language: py
102+
:start-after: [sepvisible_list-begin]
103+
:end-before: [sepvisible_list-end]
104+
:dedent: 4
105+
106+
.. group-tab:: C++
107+
108+
.. literalinclude:: src.cpp
109+
:language: c++
110+
:start-after: [sepvisible_list-begin]
111+
:end-before: [sepvisible_list-end]
112+
:dedent: 4
113+
114+
115+
.. figure:: sepvisible_segments.png
116+
:width: 400px
117+
118+
Characterization of the visibility area relative to a list of obstacle segments. The green area is visible from the observation point, while blue area is not visible. The uncertain region is represented in yellow.
119+
120+
.. tabs::
121+
122+
.. group-tab:: Python
123+
124+
.. literalinclude:: src.py
125+
:language: py
126+
:start-after: [sepvisible_polygon-begin]
127+
:end-before: [sepvisible_polygon-end]
128+
:dedent: 4
129+
130+
.. group-tab:: C++
131+
132+
.. literalinclude:: src.cpp
133+
:language: c++
134+
:start-after: [sepvisible_polygon-begin]
135+
:end-before: [sepvisible_polygon-end]
136+
:dedent: 4
137+
138+
139+
.. figure:: sepvisible_polygon.png
140+
:width: 400px
141+
142+
Characterization of the visibility area relative to a polygon obstacle. The green area is visible from the observation point, while blue area is not visible. The uncertain region is represented in yellow.
143+
144+
.. note::
145+
146+
When implementing visibility over a union of segments, **fake boundaries** are appearing. These occur when the intersection of several visibility contractors creates "uncertain" regions that do not correspond to actual physical visibility limits. This is particularly visible on the two Figures that show a line of yellow boxes in the blue area. For a detailed discussion on handling these in interval analysis, see [Brateau2025]_.
147+
148+
Related content
149+
---------------
150+
151+
.. |visibility-pdf| replace:: **Download the manuscript**
152+
.. _visibility-pdf: https://theses.hal.science/tel-00961501/file/these_remy_guyonneau.pdf
153+
154+
.. |fake_boundaries-pdf| replace:: **Download the paper**
155+
.. _fake_boundaries-pdf: https://cyber.bibl.u-szeged.hu/index.php/actcybern/article/view/4560
156+
157+
.. admonition:: References
158+
159+
.. [Guyonneau2013] \ R. Guyonneau. *Modélisation et exploitation d'incertitudes pour la robotique mobile à l'aide de l'analyse par intervalles*. PhD Thesis, 2013. |visibility-pdf|_
160+
161+
.. [Brateau2025] \ Q. Brateau, et al. *Considering Adjacent Sets for Computing the Visibility Region*. Acta Cybernetica, 2025. |fake_boundaries-pdf|_
162+
163+
.. admonition:: Technical documentation
164+
165+
See the `C++ API documentation of CtcVisible <../../api/html/classcodac2_1_1_ctc_visible.html>`_.

doc/manual/manual/contractors/geometric/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Geometric contractors
55

66
ctcdist.rst
77
ctcpolar.rst
8+
ctcvisible.rst
89
CtcSegment <http://codac.io>
910
CtcPolygon <http://codac.io>
1011
CtcEllipse <http://codac.io>
8.85 KB
Loading
8.04 KB
Loading
8.76 KB
Loading

doc/manual/manual/contractors/geometric/src.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <codac2_CtcDist.h>
1212
#include <codac2_CtcPolar.h>
1313
#include <codac2_CtcProj.h>
14+
#include <codac2_CtcVisible.h>
15+
#include <codac2_SepVisible.h>
1416
#include <codac2_Approx.h>
1517
#include <codac2_cart_prod.h>
1618
#include <codac2_CtcInter.h>
@@ -86,4 +88,59 @@ TEST_CASE("CtcPolar - manual")
8688
// x = [1.5, 2.5] ; y = [6.53834, 7.85812] ; rho = [7, 8] ; theta = [1.20558, 1.38218]
8789
// [ctcpolar-2-end]
8890
}
91+
}
92+
93+
TEST_CASE("CtcVisible - manual")
94+
{
95+
{
96+
// [ctcvisible-beg]
97+
Vector a({1, 1});
98+
Segment s({1, 4}, {3, 2});
99+
CtcVisible ctc(a, s);
100+
DefaultFigure::pave(
101+
{{-1,6},{-1,6}},
102+
ctc,
103+
0.1
104+
);
105+
// [ctcvisible-end]
106+
}
107+
108+
{
109+
// [ctcnovisible-beg]
110+
Vector a({1, 1});
111+
Segment s({1, 4}, {3, 2});
112+
CtcNoVisible ctc(a, s);
113+
DefaultFigure::pave(
114+
{{-1,6},{-1,6}},
115+
ctc,
116+
0.1
117+
);
118+
// [ctcnovisible-end]
119+
}
120+
121+
{
122+
// [sepvisible_list-begin]
123+
Vector a({1, 1});
124+
std::vector<Segment> l = {{{1,4}, {2, 3}}, {{2, 3}, {2.5,1}}, {{4, 0.5}, {3.5, -0.5}}};
125+
SepVisible sep(a, l);
126+
DefaultFigure::pave(
127+
{{-1,6},{-1,6}},
128+
sep,
129+
1e-1
130+
);
131+
// [sepvisible_list-end]
132+
}
133+
134+
{
135+
// [sepvisible_polygon-begin]
136+
Vector a({1, 1});
137+
Polygon p({{2.5,3}, {2, 2}, {3,1}, {4, 1.5}, {4, 3}});
138+
SepVisible sep(a, p);
139+
DefaultFigure::pave(
140+
{{-1,6},{-1,6}},
141+
sep,
142+
1e-1
143+
);
144+
// [sepvisible_polygon-end]
145+
}
89146
}

0 commit comments

Comments
 (0)