Skip to content

Commit e2e794e

Browse files
authored
Merge pull request #388 from SimonRohou/codac2_dev
[sep] SepInter and SepUnion can be built from a list of separators
2 parents 15d8f4b + b7bedd0 commit e2e794e

9 files changed

Lines changed: 67 additions & 7 deletions

File tree

doc/manual/manual/contractors/shape/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Geometric contractors
2-
=====================
1+
Shape contractors
2+
=================
33

44
.. toctree::
55

doc/manual/manual/tools/registration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The following example estimates a transformation between two sampled trajectorie
7272

7373
dst_estim = SampledTraj_Vector()
7474
for ti,src_i in src:
75-
dst_estim.set(ti, tr*src_i)
75+
dst_estim.set(tr*src_i, ti)
7676

7777
.. code-tab:: c++
7878

@@ -108,7 +108,7 @@ The following example estimates a transformation between two sampled trajectorie
108108

109109
SampledTraj<Vector> dst_estim;
110110
for(const auto& [ti,src_i] : src)
111-
dst_estim.set(ti, tr*Eigen::Vector2d(src_i));
111+
dst_estim.set(tr*Eigen::Vector2d(src_i), ti);
112112

113113

114114
.. figure:: registration.png

python/src/core/separators/codac2_py_SepInter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ void export_SepInter(py::module& m, py::class_<SepBase,pySep>& pysep)
2424
py::class_<SepInter> exported(m, "SepInter", pysep, SEPINTER_MAIN);
2525
exported
2626

27+
.def(py::init(
28+
[](const py::list& l)
29+
{
30+
Collection<SepBase> l_copy;
31+
for(const auto& li : l)
32+
l_copy.push_back(li.cast<SepBase&>().copy());
33+
return std::make_unique<SepInter>(l_copy);
34+
}),
35+
SEPINTER_SEPINTER_CONST_COLLECTION_T_REF,
36+
"s"_a)
37+
2738
.def(py::init(
2839
[](const SepBase& s)
2940
{

python/src/core/separators/codac2_py_SepUnion.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ void export_SepUnion(py::module& m, py::class_<SepBase,pySep>& pysep)
2424
py::class_<SepUnion> exported(m, "SepUnion", pysep, SEPUNION_MAIN);
2525
exported
2626

27+
.def(py::init(
28+
[](const py::list& l)
29+
{
30+
Collection<SepBase> l_copy;
31+
for(const auto& li : l)
32+
l_copy.push_back(li.cast<SepBase&>().copy());
33+
return std::make_unique<SepUnion>(l_copy);
34+
}),
35+
SEPUNION_SEPUNION_CONST_COLLECTION_T_REF,
36+
"s"_a)
37+
2738
.def(py::init(
2839
[](const SepBase& s)
2940
{

src/core/paver/codac2_pave.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ namespace codac2
2828

2929
PavingOut pave(const IntervalVector& x0, const CtcBase<IntervalVector>& c, double eps, double& time, bool verbose)
3030
{
31-
assert_release(eps > 0.);
31+
return pave(x0,c,Vector::constant(x0.size(),eps),time,verbose);
32+
}
33+
34+
PavingOut pave(const IntervalVector& x0, const CtcBase<IntervalVector>& c, const Vector& veps, double& time, bool verbose)
35+
{
36+
assert_release(veps.min_coeff() > 0.);
3237
assert_release(!x0.is_empty());
3338

3439
clock_t t_start = clock();
@@ -53,9 +58,11 @@ namespace codac2
5358

5459
if(!get<0>(n->boxes()).is_empty())
5560
{
56-
if(get<0>(n->boxes()).max_diam() > eps)
61+
IntervalVector w = get<0>(n->boxes()).array() / veps.array();
62+
63+
if(w.max_diam() > 1.)
5764
{
58-
n->bisect();
65+
n->bisect([&w](const IntervalVector& x) { return x.bisect(w.max_diam_index()); });
5966
l.push_back(n->left());
6067
l.push_back(n->right());
6168
}

src/core/paver/codac2_pave.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace codac2
2323
PavingOut pave(const IntervalVector& x0, std::shared_ptr<const CtcBase<IntervalVector>> c, double eps, bool verbose = false);
2424
PavingOut pave(const IntervalVector& x0, const CtcBase<IntervalVector>& c, double eps, double& time, bool verbose = false);
2525
PavingOut pave(const IntervalVector& x0, const CtcBase<IntervalVector>& c, double eps, bool verbose = false);
26+
PavingOut pave(const IntervalVector& x0, const CtcBase<IntervalVector>& c, const Vector& v_eps, double& time, bool verbose = false);
2627

2728
PavingInOut pave(const IntervalVector& x0, std::shared_ptr<const SepBase> s, double eps, bool verbose = false);
2829
PavingInOut pave(const IntervalVector& x0, const SepBase& s, double eps, bool verbose = false);

src/core/separators/codac2_SepInter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ namespace codac2
2020
{
2121
public:
2222

23+
template<typename T>
24+
SepInter(const Collection<T>& c)
25+
: Sep<SepInter>([&c]() {
26+
assert_release(!c.empty());
27+
return size_of(c.front());
28+
}()), _seps(c)
29+
{ }
30+
2331
template<typename S>
2432
requires (IsSepBaseOrPtr<S> && !std::is_same_v<SepInter,S>)
2533
SepInter(const S& s)

src/core/separators/codac2_SepUnion.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ namespace codac2
2020
{
2121
public:
2222

23+
template<typename T>
24+
SepUnion(const Collection<T>& c)
25+
: Sep<SepUnion>([&c]() {
26+
assert_release(!c.empty());
27+
return size_of(c.front());
28+
}()), _seps(c)
29+
{ }
30+
2331
template<typename S>
2432
requires (IsSepBaseOrPtr<S> && !std::is_same_v<SepUnion,S>)
2533
SepUnion(const S& s)

src/core/trajectory/codac2_SampledTraj_operations.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ namespace codac2
9393

9494
inline Matrix operator_mul_vec(const Matrix& x1, const Vector& x2) { return x1 * x2; }
9595

96+
inline Vector operator_mul_aff(const Eigen::Affine2d& x1, const Vector& x2)
97+
{
98+
assert(x2.size() == 2);
99+
return x1 * Eigen::Vector2d(x2);
100+
}
101+
96102
template<typename T,typename X1,typename X2>
97103
inline T operator_div(const X1& x1, const X2& x2) { return x1 / x2; }
98104

@@ -266,6 +272,14 @@ namespace codac2
266272
inline SampledTraj<Vector> operator*(const SampledTraj<Matrix>& x1, const SampledTraj<Vector>& x2)
267273
macro_binary_traj_traj(operator_mul_vec);
268274

275+
/** \brief \f$x_1(\cdot)\cdot x_2\f$
276+
* \param x1
277+
* \param x2
278+
* \return trajectory output
279+
*/
280+
inline SampledTraj<Vector> operator*(const Eigen::Affine2d& x1, const SampledTraj<Vector>& x2)
281+
macro_binary_real_traj(operator_mul_aff);
282+
269283
/**
270284
* \brief Operates *=
271285
* \param x1

0 commit comments

Comments
 (0)