diff --git a/CMakeLists.txt b/CMakeLists.txt index 363e0248..e245fdcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ "Codac is a library providing tools for constraint programming over reals and trajectories.") set(PROJECT_LONG_DESCRIPTION "${PROJECT_DESCRIPTION}") - set(PROJECT_HOMEPAGE_URL "http://simon-rohou.fr/research/codac") + set(PROJECT_HOMEPAGE_URL "http://codac.io") message(STATUS "Configuring build for ${PROJECT_NAME} ${PROJECT_VERSION}") if(NOT CMAKE_BUILD_TYPE) @@ -166,7 +166,7 @@ set(CPACK_GENERATOR "TGZ" "ZIP" "DEB") string(TOLOWER "${CMAKE_PROJECT_NAME}" CPACK_PACKAGE_NAME) - set(CPACK_PACKAGE_VENDOR "CodacTeam") + set(CPACK_PACKAGE_VENDOR "Codac Team") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CODAC_DESCRIPTION}) set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) diff --git a/examples/robotics/06_loops_proofs/06_loops_proofs.py b/examples/robotics/06_loops_proofs/06_loops_proofs.py new file mode 100644 index 00000000..882da178 --- /dev/null +++ b/examples/robotics/06_loops_proofs/06_loops_proofs.py @@ -0,0 +1,59 @@ +# Codac - Examples +# Reliable loop detection of a mobile robot +# ---------------------------------------------------------------------------- + +from pyibex import * +from codac import * +import sys # only for checking if this example still works + + +# =================== 0. Parameters, truth and data ==================== + +Tube.enable_syntheses() # faster integral computations + +dt = 0.01 +tdomain = Interval(-1.,10.) + +x_truth = TrajectoryVector(tdomain, TFunction("(10*cos(t)+t;5*sin(2*t)+t)")) +x = TubeVector(tdomain, dt, 2) +v = TubeVector(tdomain, dt, TFunction("(-10*sin(t)+1+[-0.2,0.2];10*cos(2*t)+1+[-0.2,0.2])")) + +x.set(x_truth(tdomain.lb()), tdomain.lb()) + +ctc.deriv.contract(x, v) + + +# =================== 1. Loops detection ==================== + +tplane = TPlane(x.tdomain()) +tplane.compute_detections(dt*2., x, v) +#tplane.compute_proofs(f) + + +# =================== 2. Graphics ==================== + +beginDrawing() + +fig_tplane = VIBesFigPaving("t-plane", tplane) +fig_tplane.set_properties(550, 150, 500, 500) +fig_tplane.show() + +fig_map = VIBesFigMap("Map") +fig_map.set_properties(450, 50, 800, 800) +fig_map.add_tube(x, "x", 0, 1) +fig_map.add_trajectory(x_truth, "x*", 0, 1) +fig_map.show(1.) + +v_loops = tplane.detected_loops() +for loop in v_loops: + fig_tplane.draw_box(loop, "red") + +v_loops = tplane.proven_loops() +for loop in v_loops: + fig_tplane.draw_box(loop, "green") + +endDrawing() + + +# Checking if this example still works: +sys.exit(0 if (tplane.nb_loops_detections() == 5 and tplane.nb_loops_proofs() == 4) else 1) \ No newline at end of file diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5f459e7b..177099f8 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -88,8 +88,12 @@ src/core/graphics/codac_py_VIBesFigTube.cpp src/core/graphics/codac_py_VIBesFigTubeVector.cpp src/core/graphics/codac_py_VIBesFigMap.cpp + src/core/graphics/codac_py_VIBesFigPaving.cpp + + src/core/paving/codac_py_Paving.cpp src/robotics/codac_py_DataLoader.cpp + src/robotics/codac_py_TPlane.cpp ) target_include_directories(tube diff --git a/python/codac_py.cpp b/python/codac_py.cpp index f3e8176e..179da1ae 100644 --- a/python/codac_py.cpp +++ b/python/codac_py.cpp @@ -55,8 +55,12 @@ void export_VIBesFig(py::module& m); void export_VIBesFigTube(py::module& m); void export_VIBesFigTubeVector(py::module& m); void export_VIBesFigMap(py::module& m); +void export_VIBesFigPaving(py::module& m); + +void export_Paving(py::module& m); void export_DataLoader(py::module& m); +void export_TPlane(py::module& m); PYBIND11_MODULE(tube, m) { @@ -93,8 +97,12 @@ PYBIND11_MODULE(tube, m) export_VIBesFigTube(m); export_VIBesFigTubeVector(m); export_VIBesFigMap(m); + export_VIBesFigPaving(m); + + export_Paving(m); export_DataLoader(m); + export_TPlane(m); // m.attr("ibex_version") = _IBEX_VERSION_; // return m.ptr(); diff --git a/python/src/core/domains/tube/codac_py_TubeVector.cpp b/python/src/core/domains/tube/codac_py_TubeVector.cpp index 5cb46c25..573351f2 100644 --- a/python/src/core/domains/tube/codac_py_TubeVector.cpp +++ b/python/src/core/domains/tube/codac_py_TubeVector.cpp @@ -261,6 +261,22 @@ void export_TubeVector(py::module& m) TUBEVECTOR_BOOL_OVERLAPS_TUBEVECTOR_FLOAT, "x"_a, "ratio"_a=1) + .def("set", [](TubeVector& x, const Vector& y) { x.set(y); }, + TUBEVECTOR_VOID_SET_INTERVALVECTOR, + "y"_a) + + .def("set", [](TubeVector& x, const Vector& y, int slice_id) { x.set(y, slice_id); }, + TUBEVECTOR_VOID_SET_INTERVALVECTOR_INT, + "y"_a, "slice_id"_a) + + .def("set", [](TubeVector& x, const Vector& y, double t) { x.set(y, t); }, + TUBEVECTOR_VOID_SET_INTERVALVECTOR_DOUBLE, + "y"_a, "t"_a) + + .def("set", [](TubeVector& x, const Vector& y, const Interval& t) { x.set(y, t); }, + TUBEVECTOR_VOID_SET_INTERVALVECTOR_INTERVAL, + "y"_a, "t"_a) + .def("set", (void (TubeVector::*)(const IntervalVector&))&TubeVector::set, TUBEVECTOR_VOID_SET_INTERVALVECTOR, "y"_a) diff --git a/python/src/core/graphics/codac_py_VIBesFigPaving.cpp b/python/src/core/graphics/codac_py_VIBesFigPaving.cpp new file mode 100644 index 00000000..02822daa --- /dev/null +++ b/python/src/core/graphics/codac_py_VIBesFigPaving.cpp @@ -0,0 +1,42 @@ +/** + * \file + * VIBesFigPaving Python binding + * ---------------------------------------------------------------------------- + * \date 2020 + * \author Simon Rohou, BenoƮt Desrochers + * \copyright Copyright 2021 Codac Team + * \license This program is distributed under the terms of + * the GNU Lesser General Public License (LGPL). + */ + +#include +#include +#include +#include +#include "pyIbex_type_caster.h" + +#include "codac_VIBesFigPaving.h" +// Generated file from Doxygen XML (doxygen2docstring.py): +#include "codac_py_VIBesFigPaving_docs.h" + +using namespace std; +using namespace ibex; +using namespace codac; +namespace py = pybind11; +using namespace pybind11::literals; + + +void export_VIBesFigPaving(py::module& m) +{ + py::class_ fig_map(m, "VIBesFigPaving", VIBESFIGPAVING_MAIN); + fig_map + + .def(py::init(), + VIBESFIGPAVING_CONSTPAVING_M_PAVING, + "fig_name"_a, "paving"_a) + + .def("show", (void (VIBesFigPaving::*)())&VIBesFigPaving::show, + VIBESFIGPAVING_VOID_SHOW) + + ; +} \ No newline at end of file diff --git a/python/src/core/paving/codac_py_Paving.cpp b/python/src/core/paving/codac_py_Paving.cpp new file mode 100644 index 00000000..c03c1464 --- /dev/null +++ b/python/src/core/paving/codac_py_Paving.cpp @@ -0,0 +1,31 @@ +/** + * \file + * Paving Python binding + * ---------------------------------------------------------------------------- + * \date 2021 + * \author Simon Rohou + * \copyright Copyright 2021 Codac Team + * \license This program is distributed under the terms of + * the GNU Lesser General Public License (LGPL). + */ + +#include +#include +#include +#include + +#include "codac_Paving.h" +// Generated file from Doxygen XML (doxygen2docstring.py): +#include "codac_py_Paving_docs.h" + +using namespace std; +using namespace ibex; +using namespace codac; +namespace py = pybind11; +using namespace pybind11::literals; + + +void export_Paving(py::module& m) +{ + py::class_ tplane(m, "Paving", PAVING_MAIN); +} \ No newline at end of file diff --git a/python/src/robotics/codac_py_TPlane.cpp b/python/src/robotics/codac_py_TPlane.cpp new file mode 100644 index 00000000..96490740 --- /dev/null +++ b/python/src/robotics/codac_py_TPlane.cpp @@ -0,0 +1,60 @@ +/** + * \file + * TPlane Python binding + * ---------------------------------------------------------------------------- + * \date 2021 + * \author Simon Rohou + * \copyright Copyright 2021 Codac Team + * \license This program is distributed under the terms of + * the GNU Lesser General Public License (LGPL). + */ + +#include +#include +#include +#include + +#include "codac_Paving.h" +#include "codac_TPlane.h" +// Generated file from Doxygen XML (doxygen2docstring.py): +#include "codac_py_TPlane_docs.h" + +using namespace std; +using namespace ibex; +using namespace codac; +namespace py = pybind11; +using namespace pybind11::literals; + + +void export_TPlane(py::module& m) +{ + py::class_ tplane(m, "TPlane", TPLANE_MAIN); + tplane + + .def(py::init(), + TPLANE_TPLANE_INTERVAL) + + .def("compute_detections", (void (TPlane::*)(float,const TubeVector&,const TubeVector&))&TPlane::compute_detections, + TPLANE_VOID_COMPUTE_DETECTIONS_FLOAT_TUBEVECTOR_TUBEVECTOR, + "precision"_a, "p"_a, "v"_a) + + .def("compute_proofs", &TPlane::compute_proofs, + TPLANE_VOID_COMPUTE_PROOFS_INTERVALVECTORPINTERVALVECTORB, + "f"_a) + + .def("nb_loops_detections", &TPlane::nb_loops_detections, + TPLANE_INT_NB_LOOPS_DETECTIONS) + + .def("nb_loops_proofs", &TPlane::nb_loops_proofs, + TPLANE_INT_NB_LOOPS_PROOFS) + + .def("detected_loops", &TPlane::detected_loops, + TPLANE_CONSTVECTORINTERVALVECTOR_DETECTED_LOOPS) + + .def("proven_loops", &TPlane::proven_loops, + TPLANE_CONSTVECTORINTERVALVECTOR_PROVEN_LOOPS) + + .def("traj_loops_summary", &TPlane::traj_loops_summary, + TPLANE_TRAJECTORY_TRAJ_LOOPS_SUMMARY) + ; +} \ No newline at end of file diff --git a/src/core/paving/codac_ConnectedSubset.cpp b/src/core/paving/codac_ConnectedSubset.cpp index f75a8ab8..b41b3f39 100644 --- a/src/core/paving/codac_ConnectedSubset.cpp +++ b/src/core/paving/codac_ConnectedSubset.cpp @@ -84,4 +84,12 @@ namespace codac return v_boundaries; } + + const vector ConnectedSubset::get_boxed_hulls(const vector v_subsets) + { + vector v_boxes(v_subsets.size()); + for(size_t i = 0 ; i < v_subsets.size() ; i++) + v_boxes[i] = v_subsets[i].box(); + return v_boxes; + } } \ No newline at end of file diff --git a/src/core/paving/codac_ConnectedSubset.h b/src/core/paving/codac_ConnectedSubset.h index 258b4692..69c13248 100644 --- a/src/core/paving/codac_ConnectedSubset.h +++ b/src/core/paving/codac_ConnectedSubset.h @@ -95,6 +95,9 @@ namespace codac */ std::vector get_boundary(SetValue value_boundary = SetValue::MAYBE, SetValue value_out = SetValue::OUT) const; // items of type k-1 + + static const std::vector get_boxed_hulls(const std::vector v_subsets); + /// @} /// \name Methods related to topological degree /// @{