Skip to content

Commit fd4398b

Browse files
authored
Merge pull request #186 from SimonRohou/codac2_dev
Trajectories + proj
2 parents 90d48ff + acfb48a commit fd4398b

File tree

12 files changed

+120
-47
lines changed

12 files changed

+120
-47
lines changed

doc/manual/development/info_dev.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ If you simply want to use the latest Codac release in Python, you can download t
3535

3636
1. **Ensure the following prerequisites are met**:
3737

38-
- the prerequisites for the :ref:`C++ installation of Codac <sec-install-cpp-prerequisites>`.
38+
- the prerequisites for the :ref:`C++ installation of Codac <sec-install-cpp-prerequisites>`. On Linux systems, you can simply:
39+
40+
.. code-block:: bash
41+
42+
sudo apt-get install -y g++ gcc cmake git flex bison
43+
3944
- a supported version of Python (>=3.6).
4045
- a recent `Doxygen <https://www.doxygen.nl>`_ version (for instance, release 1.13.0 or newest). On Linux systems, latest releases are not available as Debian packages, so we advice to install Doxygen from the sources:
4146

@@ -60,13 +65,14 @@ If you simply want to use the latest Codac release in Python, you can download t
6065

6166
.. code-block:: bash
6267
63-
git clone -b master https://github.com/lebarsfa/ibex-lib.git $HOME/ibex-lib
68+
git clone https://github.com/lebarsfa/ibex-lib.git $HOME/ibex-lib
69+
cd $HOME/ibex-lib
6470
6571
You will need to compile both IBEX and Codac using the ``-fPIC`` options. This can be done with the following CMake configuration:
6672

6773
.. code-block:: bash
6874
69-
cd $HOME/ibex-lib/build
75+
mkdir build ; cd build
7076
cmake -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_INSTALL_PREFIX=$HOME/ibex-lib/build_install -DCMAKE_BUILD_TYPE=Release ..
7177
make ; make install
7278
@@ -77,16 +83,27 @@ If you simply want to use the latest Codac release in Python, you can download t
7783
.. code-block:: bash
7884
7985
git clone https://github.com/codac-team/codac $HOME/codac
86+
cd $HOME/codac
87+
88+
.. admonition:: Using Codac v2 simultaneously with Codac v1
89+
90+
In case you want to use the two versions of Codac in the same Python script, you will have to compile the binaries of Codac v2 under a different name in order to avoid ``import`` conflicts. Things are already prepared in the branch ``codac2_renamed``, you can therefore:
91+
92+
.. code-block:: bash
93+
94+
git checkout codac2_renamed
95+
96+
Note that you will then have to ``import codac2`` instead of ``import codac`` in your Python scripts.
8097

8198
In addition to the ``-fPIC`` options, you will have to configure ``WITH_PYTHON=ON``. Note that the ``git submodule`` commands will automatically get the `pybind11 <https://pybind11.readthedocs.io>`_ files required for the binding.
8299

83100
.. code-block:: bash
84101
85-
cd $HOME/codac/build
86102
# Get automatically pybind11 and eigen submodules:
87103
git submodule init ; git submodule update
88104
# Configure CMake
89-
cmake -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_C_FLAGS="-fPIC" -DWITH_PYTHON=ON -DCMAKE_INSTALL_PREFIX=$HOME/codac/build_install -DCMAKE_PREFIX_PATH=$HOME/ibex-lib/build_install -DCMAKE_BUILD_TYPE=Release ..
105+
mkdir build ; cd build
106+
cmake -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_C_FLAGS="-fPIC" -DWITH_PYTHON=ON -DCMAKE_INSTALL_PREFIX=$HOME/codac/build_install -DCMAKE_PREFIX_PATH="$HOME/ibex-lib/build_install;$HOME/doxygen/build_install" -DCMAKE_BUILD_TYPE=Release ..
90107
make ; make install
91108
92109
4. **Configure your Python environment**:

doc/manual/manual/installation/cpp.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ Troubleshooting
263263
----------------
264264
If you encounter issues during the installation process, consider the following:
265265

266-
- Ensure all prerequisites are installed and up to date.
267-
- Check `the GitHub issues <https://github.com/codac-team/codac/issues>`_ page for known problems.
266+
- ensure all prerequisites are installed and up to date.
267+
- check `the GitHub issues <https://github.com/codac-team/codac/issues>`_ page for known problems.
268268

269269
If you need further assistance, reach out to the library maintainers via the GitHub repository's issue tracker or email support at `simon.rohou [at] ensta.fr`.
270270

examples/00_graphics/graphic_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@
8484
t=ScalarVar()
8585
# Fermat's spiral
8686
f1=AnalyticFunction([t], [a*sqrt(t)*cos(t),a*sqrt(t)*sin(t)])
87-
traj3=AnalyticTrajectory(f1, [0,100])
87+
traj3=AnalyticTraj(f1, [0,100])
8888
fig3.draw_trajectory(traj3, ColorMap.rainbow())

examples/04_explored_area/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main()
1919

2020
Interval tdomain(0,5);
2121
auto sampled_f = AnalyticTraj(f,tdomain).sampled(0.8);
22-
sampled_f[6] = {0,-1}; // appending the position (0,-1) at t=6
22+
sampled_f.set(6., {0,-1}); // appending the position (0,-1) at t=6
2323

2424
VectorVar w(3);
2525
auto g = sampled_f.as_function();

examples/04_explored_area/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
tdomain = [0,5]
1717
sampled_f = AnalyticTraj(f,tdomain).sampled(0.8)
18-
sampled_f[6] = [0,-1] # appending the position (0,-1) at t=6
18+
sampled_f.set(6, [0,-1]) # appending the position (0,-1) at t=6
1919

2020
w = VectorVar(3)
2121
g = sampled_f.as_function()

python/src/core/trajectory/codac2_py_AnalyticTraj.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ void _export_AnalyticTraj(py::module& m, const string& class_name)
3636
ANALYTICTRAJ_OS_ANALYTICTRAJ_CONST_ANALYTICFUNCTION_O_REF_CONST_INTERVAL_REF,
3737
"f"_a, "tdomain"_a)
3838

39+
.def("__call__", [](const AnalyticTraj<O>& x, double t)
40+
{
41+
return x(t);
42+
},
43+
VIRTUAL_S_ANALYTICTRAJ_OS_OPERATORCALL_DOUBLE_CONST,
44+
"t"_a)
45+
46+
.def("__call__", [](const AnalyticTraj<O>& x, const Interval& t)
47+
{
48+
return x(t);
49+
},
50+
VIRTUAL_WRAPPER_S_DOMAIN_ANALYTICTRAJ_OS_OPERATORCALL_CONST_INTERVAL_REF_CONST,
51+
"t"_a)
52+
3953
;
4054
}
4155

python/src/core/trajectory/codac2_py_SampledTraj.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ py::class_<SampledTraj<T>> _export_SampledTraj(py::module& m, const string& clas
5050
else if constexpr(std::is_same_v<T,Vector>)
5151
{
5252
exported_class
53+
5354
.def(py::init(
5455
[](const py::array_t<double>& l_t, const py::array_t<double>& l_x)
5556
{
@@ -85,6 +86,18 @@ py::class_<SampledTraj<T>> _export_SampledTraj(py::module& m, const string& clas
8586
}),
8687
SAMPLEDTRAJ_T_SAMPLEDTRAJ_CONST_LIST_DOUBLE_REF_CONST_LIST_T_REF,
8788
"l_t"_a, "l_x"_a)
89+
90+
.def("__getitem__", [](const SampledTraj<T>& x, Index_type i) -> SampledTraj<double>
91+
{
92+
matlab::test_integer(i);
93+
return x[matlab::input_index(i)];
94+
}, py::return_value_policy::reference_internal)
95+
96+
.def("subvector", [](const SampledTraj<T>& x, Index_type i, Index_type j) -> SampledTraj<Vector>
97+
{
98+
matlab::test_integer(i,j);
99+
return x.subvector(matlab::input_index(i),matlab::input_index(j));
100+
}, py::return_value_policy::reference_internal)
88101
;
89102
}
90103

@@ -104,17 +117,26 @@ py::class_<SampledTraj<T>> _export_SampledTraj(py::module& m, const string& clas
104117
SAMPLEDTRAJ_T_SAMPLEDTRAJ_T_SAMPLED_DOUBLE_BOOL_CONST,
105118
"dt"_a, "keep_original_values"_a)
106119

107-
.def("__getitem__", [](const SampledTraj<T>& x, Index_type index) -> const T&
120+
.def("__call__", [](const SampledTraj<T>& x, double t) -> T
108121
{
109-
matlab::test_integer(index);
110-
return x.at(matlab::input_index(index));
111-
}, py::return_value_policy::reference_internal)
122+
return x(t);
123+
},
124+
VIRTUAL_T_SAMPLEDTRAJ_T_OPERATORCALL_DOUBLE_CONST,
125+
"t"_a)
126+
127+
.def("__call__", [](const SampledTraj<T>& x, const Interval& t) -> typename Wrapper<T>::Domain
128+
{
129+
return x(t);
130+
},
131+
VIRTUAL_WRAPPER_T_DOMAIN_SAMPLEDTRAJ_T_OPERATORCALL_CONST_INTERVAL_REF_CONST,
132+
"t"_a)
112133

113-
.def("__setitem__", [](SampledTraj<T>& x, Index_type index, const T& a)
134+
.def("set", [](SampledTraj<T>& x, double ti, const T& xi)
114135
{
115-
matlab::test_integer(index);
116-
x[matlab::input_index(index)] = a;
117-
})
136+
return x.set(ti,xi);
137+
},
138+
VOID_SAMPLEDTRAJ_T_SET_DOUBLE_CONST_T_REF,
139+
"ti"_a, "xi"_a)
118140

119141
.def("__repr__", [](const SampledTraj<T>& x) {
120142
std::ostringstream stream;

python/src/core/trajectory/codac2_py_TrajBase.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,6 @@ void export_TrajBase(py::class_<S>& pyclass)
5757
},
5858
VIRTUAL_WRAPPER_T_DOMAIN_TRAJBASE_T_CODOMAIN_CONST)
5959

60-
.def("__call__", [](const S& x, double t)
61-
{
62-
return x(t);
63-
},
64-
VIRTUAL_T_TRAJBASE_T_OPERATORCALL_DOUBLE_CONST,
65-
"t"_a)
66-
67-
.def("__call__", [](const S& x, const Interval& t)
68-
{
69-
return x(t);
70-
},
71-
VIRTUAL_WRAPPER_T_DOMAIN_TRAJBASE_T_OPERATORCALL_CONST_INTERVAL_REF_CONST,
72-
"t"_a)
73-
7460
.def("nan_value", [](const S& x)
7561
{
7662
return x.nan_value();

src/core/contractors/codac2_CtcProj.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ namespace codac2
3535
assert_release(*min_element(_xi.begin(),_xi.end()) >= 0);
3636
assert_release(*max_element(_xi.begin(),_xi.end()) < size_of(c));
3737
assert_release(size_of(c) >= (Index)_xi.size() && "cannot compute a projection of a set into a superset");
38-
assert_release(y.is_bisectable());
3938
assert_release(default_eps > 0.);
4039
}
4140

src/core/domains/ellipsoid/codac2_Ellipsoid.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,10 @@ namespace codac2 {
167167
return e_res + elli_error;
168168
}
169169

170-
Matrix nonlinear_mapping_base(const Matrix &G, const Matrix &J, const IntervalMatrix &J_box, const Vector& trig, const Vector& q) {
171-
172-
Index n = G.cols();
173-
170+
Matrix nonlinear_mapping_base(const Matrix &G, const Matrix &J, const IntervalMatrix &J_box, const Vector& trig, const Vector& q)
171+
{
174172
assert(G.is_squared() && J.is_squared() && J_box.is_squared());
175-
assert(n == J.cols() && n == J_box.cols() && n == q.size());
173+
assert(G.cols() == J.cols() && G.cols() == J_box.cols() && G.cols() == q.size());
176174

177175
auto JG = J * G; // note: reliability may be lost here!
178176
auto G_ = G.template cast<Interval>();

0 commit comments

Comments
 (0)