Skip to content

Commit

Permalink
Merge branch 'cn' into dev
Browse files Browse the repository at this point in the history
SimonRohou committed Nov 4, 2021
2 parents 0e87a9c + 4f89893 commit bd8008b
Showing 51 changed files with 1,670 additions and 241 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -107,6 +107,7 @@ jobs:
cd ../../build

# Testing
./tests/core/codac-tests-core
make test
./../examples/tuto/05_dyn_rangebearing/build/05_dyn_rangebearing

@@ -146,5 +147,7 @@ jobs:
cd ../../build

# Testing

./tests/core/codac-tests-core
make test
./../examples/tuto/05_dyn_rangebearing/build/05_dyn_rangebearing
51 changes: 35 additions & 16 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -9,31 +9,50 @@ Changelog
Codac releases
==============

Unreleased yet (in development)
===============================
.. Unreleased yet (in development)
.. ===============================
..
.. This list corresponds to ongoing developments.
..
.. Features added
.. --------------
..
.. Changes
.. -------
..
.. Dependencies
.. ------------
..
.. Bugs fixed
.. ----------
..
.. Deprecated
.. ----------
..
.. Documentation
.. -------------
..
.. Python binding
.. --------------

This list corresponds to ongoing developments.

-----------------------------------------------------------------

Codac release 0.1.7 (released `Nov 4, 2021 <https://github.com/codac-team/codac/releases/tag/v0.1.7>`_)
=======================================================================================================

`Commits since previous release 0.1.6 <https://github.com/codac-team/codac/compare/v0.1.6...v0.1.7>`_

Features added
--------------

Changes
-------

Dependencies
------------
* :commit:`4f273d976005244344081d2feff81653095f5cfd`: towards generation of ``.deb`` and ``.nupkg packages``

Bugs fixed
----------

Deprecated
----------

Documentation
-------------

Python binding
--------------
* :commit:`5cf92232da71aa4bf8e329ac2ceb99bd46969dcf`: corrected recent bug in ``CtcChain``
* :commit:`b4c5a2c35f43c30c9e63918b4b1e917bb955fad3`: corrected recent bug in ``CtcEval``


-----------------------------------------------------------------
4 changes: 2 additions & 2 deletions doc/doc/index.rst
Original file line number Diff line number Diff line change
@@ -182,7 +182,7 @@ The distance function :math:`g(\mathbf{x},\mathbf{b})` between the robot and a l

for i in range (0,len(y)): # we add the observ. constraint for each range-only measurement

p = cn.create_dom(IntervalVector(4)) # intermed. variable (state at t_i)
p = cn.create_interm_var(IntervalVector(4)) # intermed. variable (state at t_i)

# Distance constraint: relation between the state at t_i and the ith beacon position
cn.add(ctc.dist, [cn.subvector(p,0,1), b[i], y[i]])
@@ -197,7 +197,7 @@ The distance function :math:`g(\mathbf{x},\mathbf{b})` between the robot and a l

for(int i = 0 ; i < 3 ; i++) // we add the observ. constraint for each range-only measurement
{
IntervalVector& p = cn.create_dom(IntervalVector(4)); // intermed. variable (state at t_i)
IntervalVector& p = cn.create_interm_var(IntervalVector(4)); // intermed. variable (state at t_i)

// Distance constraint: relation between the state at t_i and the ith beacon position
cn.add(ctc::dist, {cn.subvector(p,0,1), b[i], y[i]});
8 changes: 4 additions & 4 deletions doc/doc/tutorial/04-own-contractor/index.rst
Original file line number Diff line number Diff line change
@@ -548,7 +548,7 @@ Appendix
cn.contract(); // segmentation fault here
Instead, we must create the domains inside the CN object in order to keep it alive outside the block. This can be done with the method ``.create_dom()``:
Instead, we must create the domains inside the CN object in order to keep it alive outside the block. This can be done with the method ``.create_interm_var()``:

.. code:: cpp
@@ -558,7 +558,7 @@ Appendix
if(/* some condition */)
{
Interval& a = cn.create_dom(Interval(1,20));
Interval& a = cn.create_interm_var(Interval(1,20));
cn.add(ctc_plus, {x, y, a});
} // 'a' is not lost
@@ -568,8 +568,8 @@ Appendix

.. code:: cpp
IntervalVector& d = cn.create_dom(IntervalVector(2));
IntervalVector& d = cn.create_interm_var(IntervalVector(2));
creates for instance an intermediate 2d variable with a 2d box domain: :math:`[\mathbf{d}]=[-\infty,\infty]^2`. Its argument defines the type of domain to be created (``Interval``, ``IntervalVector``, *etc.*).

Technically, ``create_dom()`` returns a C++ *reference* (in the above example, of type ``IntervalVector&``). The reference is an alias on the intermediate variable, that is now inside the Contractor Network. It can be used in the same way as other variables involved in the CN.
Technically, ``create_interm_var()`` returns a C++ *reference* (in the above example, of type ``IntervalVector&``). The reference is an alias on the intermediate variable, that is now inside the Contractor Network. It can be used in the same way as other variables involved in the CN.
6 changes: 3 additions & 3 deletions doc/doc/tutorial/07-data-association/solution.py
Original file line number Diff line number Diff line change
@@ -103,9 +103,9 @@ def contract(self, x):
y2 = Interval(v_obs[i][2]) # bearing

# Intermediate variables:
a = cn.create_dom(Interval())
d = cn.create_dom(IntervalVector(2))
p = cn.create_dom(IntervalVector(4))
a = cn.create_interm_var(Interval())
d = cn.create_interm_var(IntervalVector(2))
p = cn.create_interm_var(IntervalVector(4))

cn.add(ctc_constell, [m[i]])
cn.add(ctc_minus, [d, m[i], cn.subvector(p,0,1)])
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -89,6 +89,8 @@ if(BUILD_TESTS AND TEST_EXAMPLES)
endif()
add_test(NAME basics_08
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/basics/08_tube_paving/build/codac_basics_08 0)
add_test(NAME basics_09
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/basics/09_cn_paving/build/codac_basics_09 0)

# Robotics
add_test(NAME rob_01
42 changes: 42 additions & 0 deletions examples/basics/09_cn_paving/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ==================================================================
# codac / basics example - cmake configuration file
# ==================================================================

cmake_minimum_required(VERSION 3.0.2)
project(codac_basics_09 LANGUAGES CXX)

# Adding IBEX

# In case you installed IBEX in a local directory, you need
# to specify its path with the CMAKE_PREFIX_PATH option.
# set(CMAKE_PREFIX_PATH "~/ibex-lib/build_install")

find_package(IBEX REQUIRED)
ibex_init_common() # IBEX should have installed this function
message(STATUS "Found IBEX version ${IBEX_VERSION}")

# Adding Eigen3

# In case you installed Eigen3 in a local directory, you need
# to specify its path with the CMAKE_PREFIX_PATH option, e.g.
# set(CMAKE_PREFIX_PATH "~/eigen/build_install")

find_package(Eigen3 REQUIRED NO_MODULE)
message(STATUS "Found Eigen3 version ${EIGEN3_VERSION}")

# Adding Codac

# In case you installed Codac in a local directory, you need
# to specify its path with the CMAKE_PREFIX_PATH option.
# set(CMAKE_PREFIX_PATH "~/codac/build_install")

find_package(CODAC REQUIRED)
message(STATUS "Found Codac version ${CODAC_VERSION}")

# Compilation

set(CMAKE_BUILD_TYPE Debug)
add_executable(${PROJECT_NAME} main.cpp)
target_compile_options(${PROJECT_NAME} PUBLIC ${CODAC_CXX_FLAGS})
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CODAC_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${CODAC_LIBRARIES} Ibex::ibex ${CODAC_LIBRARIES})
11 changes: 11 additions & 0 deletions examples/basics/09_cn_paving/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ==================================================================
# tubex-lib - build script
# ==================================================================

#!/bin/bash

mkdir build -p
cd build
cmake ..
make
cd ..
86 changes: 86 additions & 0 deletions examples/basics/09_cn_paving/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Codac - Examples
* Using CN for paving
* ----------------------------------------------------------------------------
*
* \brief Using CN for paving
* \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 <codac.h>

using namespace std;
using namespace codac;

class FunctionPaving : public Paving
{
public:

FunctionPaving(const IntervalVector& init_box) : Paving(init_box, SetValue::UNKNOWN)
{

}

void compute(ContractorNetwork& cn, IntervalVectorVar& var_x, IntervalVar& var_y, float precision)
{
assert(precision > 0.);

Interval y;
// Abstract variables replaced by actual domains
// related to the current paving box
cn.contract({
{var_x, box()},
{var_y, y}
});

Interval zero(-0.5,0.5);

if(y.is_subset(zero))
set_value(SetValue::IN);

else if(!y.intersects(zero))
set_value(SetValue::OUT);

else if(box().max_diam() < precision)
set_value(SetValue::UNKNOWN);

else
{
bisect();
((FunctionPaving*)m_first_subpaving)->compute(cn, var_x, var_y, precision);
((FunctionPaving*)m_second_subpaving)->compute(cn, var_x, var_y, precision);
}
}
};

int main()
{
CtcFunction ctc_f(Function("x[2]", "y", "x[0]*cos(x[0]-x[1])*sin(x[0])+x[1]-y"));

ContractorNetwork cn;

// Abstract variables are created,
// they will be replaced afterwards by the values
// corresponding to each box of the paving
IntervalVar y;
IntervalVectorVar x(2);

// The CN is built only once, outside the Paving class
cn.add(ctc_f, {x, y});

FunctionPaving paving(IntervalVector({{-3,3},{-3,3}}));
paving.compute(cn, x, y, 0.05);

vibes::beginDrawing();
VIBesFigPaving fig_paving("Paving", &paving);
fig_paving.set_properties(100, 100, 400, 400);
fig_paving.show();
vibes::endDrawing();

return EXIT_SUCCESS;
}
8 changes: 4 additions & 4 deletions examples/brunovsky/main.cpp
Original file line number Diff line number Diff line change
@@ -109,10 +109,10 @@ int main()
{
// New domains and intermediate variables:
Vector& landmark((i%2 == 0) ? m_a : m_b); // selecting landmark
IntervalVector& b = cn.create_dom(IntervalVector(landmark));
Interval& t = cn.create_dom((i+1)*tdomain.diam()/nb_obs+tdomain.lb());
Interval& d = cn.create_dom(sqrt(sqr(b[0]-x_truth(t)[0])+sqr(b[1]-x_truth(t)[1])));
IntervalVector& p = cn.create_dom(IntervalVector(4)); // state at time t
IntervalVector& b = cn.create_interm_var(IntervalVector(landmark));
Interval& t = cn.create_interm_var((i+1)*tdomain.diam()/nb_obs+tdomain.lb());
Interval& d = cn.create_interm_var(sqrt(sqr(b[0]-x_truth(t)[0])+sqr(b[1]-x_truth(t)[1])));
IntervalVector& p = cn.create_interm_var(IntervalVector(4)); // state at time t

d.inflate(0.025); // bounded measurement
cout << i << "\t" << ((i%2 == 0) ? "m_a" : "m_b") << "\t" << t.mid() << "\t" << d << endl;
6 changes: 3 additions & 3 deletions examples/robotics/10_datasso/datasso.py
Original file line number Diff line number Diff line change
@@ -98,9 +98,9 @@ def contract(self, x):
y2 = Interval(v_obs[i][2]) # bearing

# Intermediate variables:
a = cn.create_dom(Interval())
d = cn.create_dom(IntervalVector(2))
p = cn.create_dom(IntervalVector(3))
a = cn.create_interm_var(Interval())
d = cn.create_interm_var(IntervalVector(2))
p = cn.create_interm_var(IntervalVector(3))

cn.add(ctc_constell, [m[i]])
cn.add(ctc_minus, [d, m[i], cn.subvector(p,0,1)])
6 changes: 3 additions & 3 deletions examples/robotics/10_datasso/main.cpp
Original file line number Diff line number Diff line change
@@ -96,9 +96,9 @@ int main()
Interval &y2 = v_obs[i][2]; // bearing

// Intermediate variables:
Interval& a = cn.create_dom(Interval());
IntervalVector& d = cn.create_dom(IntervalVector(2));
IntervalVector& p = cn.create_dom(IntervalVector(3));
Interval& a = cn.create_interm_var(Interval());
IntervalVector& d = cn.create_interm_var(IntervalVector(2));
IntervalVector& p = cn.create_interm_var(IntervalVector(3));

cn.add(ctc_constell, {m[i]});
cn.add(ctc_minus, {d, m[i], cn.subvector(p,0,1)});
2 changes: 1 addition & 1 deletion examples/tuto/01_getting_started/01_getting_started.cpp
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ int main()

for(int i = 0 ; i < 3 ; i++) // we add the observ. constraint for each range-only measurement
{
IntervalVector& p = cn.create_dom(IntervalVector(4)); // intermed. variable (state at t_i)
IntervalVector& p = cn.create_interm_var(IntervalVector(4)); // intermed. variable (state at t_i)

// Distance constraint: relation between the state at t_i and the ith beacon position
cn.add(ctc::dist, {cn.subvector(p,0,1), b[i], y[i]});
2 changes: 1 addition & 1 deletion examples/tuto/01_getting_started/01_getting_started.py
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@

for i in range (0,len(y)): # we add the observ. constraint for each range-only measurement

p = cn.create_dom(IntervalVector(4)) # intermed. variable (state at t_i)
p = cn.create_interm_var(IntervalVector(4)) # intermed. variable (state at t_i)

# Distance constraint: relation between the state at t_i and the ith beacon position
cn.add(ctc.dist, [cn.subvector(p,0,1), b[i], y[i]])
Original file line number Diff line number Diff line change
@@ -60,8 +60,8 @@ int main()
for(int i = 0 ; i < v_obs.size() ; i++)
{
// Intermediate variables
Interval& alpha = cn.create_dom(Interval());
IntervalVector& d = cn.create_dom(IntervalVector(2));
Interval& alpha = cn.create_interm_var(Interval());
IntervalVector& d = cn.create_interm_var(IntervalVector(2));

cn.add(ctc_plus, {v_obs[i][1], heading, alpha});
cn.add(ctc_minus, {v_map[i], x, d});
Original file line number Diff line number Diff line change
@@ -46,8 +46,8 @@
for i in range(0,len(v_obs)):

# Intermediate variables
alpha = cn.create_dom(Interval())
d = cn.create_dom(IntervalVector(2))
alpha = cn.create_interm_var(Interval())
d = cn.create_interm_var(IntervalVector(2))

cn.add(ctc_plus, [v_obs[i][1], heading, alpha])
cn.add(ctc_minus, [v_map[i], x, d])
2 changes: 1 addition & 1 deletion examples/tuto/04_dyn_rangeonly/04_dyn_rangeonly.cpp
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ int main()

for(int i = 0 ; i < 3 ; i++) // we add the observ. constraint for each range-only measurement
{
IntervalVector& p = cn.create_dom(IntervalVector(4)); // intermed. variable (state at t_i)
IntervalVector& p = cn.create_interm_var(IntervalVector(4)); // intermed. variable (state at t_i)

// Distance constraint: relation between the state at t_i and the ith beacon position
cn.add(ctc::dist, {cn.subvector(p,0,1), b[i], y[i]});
2 changes: 1 addition & 1 deletion examples/tuto/04_dyn_rangeonly/04_dyn_rangeonly.py
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@

for i in range (0,len(y)): # we add the observ. constraint for each range-only measurement

p = cn.create_dom(IntervalVector(4)) # intermed. variable (state at t_i)
p = cn.create_interm_var(IntervalVector(4)) # intermed. variable (state at t_i)

# Distance constraint: relation between the state at t_i and the ith beacon position
cn.add(ctc.dist, [cn.subvector(p,0,1), b[i], y[i]])
Loading

0 comments on commit bd8008b

Please sign in to comment.