-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb3d64c
commit d0351fb
Showing
10 changed files
with
233 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/operators.h> | ||
#include <pybind11/functional.h> | ||
#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_<VIBesFigPaving,VIBesFig> fig_map(m, "VIBesFigPaving", VIBESFIGPAVING_MAIN); | ||
fig_map | ||
|
||
.def(py::init<const string&, const Paving*>(), | ||
VIBESFIGPAVING_CONSTPAVING_M_PAVING, | ||
"fig_name"_a, "paving"_a) | ||
|
||
.def("show", (void (VIBesFigPaving::*)())&VIBesFigPaving::show, | ||
VIBESFIGPAVING_VOID_SHOW) | ||
|
||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/operators.h> | ||
#include <pybind11/functional.h> | ||
|
||
#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_<Paving> tplane(m, "Paving", PAVING_MAIN); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/operators.h> | ||
#include <pybind11/functional.h> | ||
|
||
#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, Paving> tplane(m, "TPlane", TPLANE_MAIN); | ||
tplane | ||
|
||
.def(py::init<const Interval&>(), | ||
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) | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters