barakugav / FDML

FDML is a CPP software for robot localization processing and queries using few (one or two) distance measurements
2 stars 1 forks source link
computational-geometric cpp geometric-algorithms localization robotics

Build

FDML: Few Distance Measurements robot Localization

drawing

FDML is a software for robot localization processing and queries using few (one or two) distance measurements, written in C++.

Imagine the following situation. A robot is placed in an unknown position and unknown orientation in a known polygon (with holes) environment. The robot has a depth sensor, that is a sensor that can measure the scalar length of a ray from it's position to a wall in a specific direction. The depth sensor is used to measure a single distance measurement with the robot unknown position and orientation, where does the robot can be within the environment given the new information? Same question can be asked when the robot is allowed to make a second distance measurement.

The FDML library support these types of queries. For two distance measurements, the library support two antipodal (180 °) measurements, in other words, the robot measure a distance measurement in some orientation, then rotate in place to the exact opposite direction and measure a second distance measurement. A polygon environment can be preprocessed and support multiple queries efficiently.

The library is written in C++, but bindings exists for Python, and an additional GUI application.

FDML-core

The FDML-core is the C++ heart of the library and contains all the logic. It can be used as a C++ library, from Python using the bindings, or using command line application (basic CLI, daemon with communication through files). It's built on top of CGAL, which depends on boost, gmp and mpfr.

Usage

The library interface is done via Locator object which support three functions:

class Locator {
  Locator();
  void init(const Polygon_with_holes& scene);
  std::vector<Res1d> query(const Kernel::FT& d) const;
  std::vector<Res2d> query(const Kernel::FT& d1, const Kernel::FT& d2) const;
}

A simple square scene example:

Polygon_with_holes scene;
scene.push_back(Point(0, 0));
scene.push_back(Point(0, 10));
scene.push_back(Point(10, 10));
scene.push_back(Point(10, 0));

/* locator is initiated with a polygon scene */
Locator locator;
locator.init(scene);

/* Assuming a robot is within the given scene, in an unknown location and an
 * unknown orientation, after performing a single distance measurement, the
 * locator can be used to calculate all the possible location the robot
 * might be in.
 * Queries of a single measurement result in a collection of areas representing
 * all the possible locations of the robot, each represented as polygon and the
 * measured edge.
 */
double robot_measurement = 5.7;

std::vector<Res1d> single_res = locator.query(robot_measurement);
std::count << "Single measurement possible positions:" << std::endl;
for (const auto& res_area : single_res)
  std::count << "\tPossible positions of measuring edge (" << res_area.edge << "): " << res_area.pos << std::endl;

/* If the robot is able to perform a second distance measurement in the
 * opposite direction of the first measurement, the locator can be used to
 * calculate a more accurate localization result using the two measurements.
 * Queries of double measurements result in a collection of segments
 * representing all the possible locations of the robot.
 */
double second_robot_measurement = 2.4;
std::vector<Res2d> double_res = locator.query(robot_measurement, second_robot_measurement);
std::count << "Double measurements possible positions:" << std::endl;
for (const auto& res_area : double_res)
  std::count << "\tPossible positions of measuring edges (" << res_area.edge1 << "),(" << res_area.edge2
             << "): " << res_area.pos << std::endl;

Installation

The dependencies of the library are Boost, GMP, MPFR and CGAL. If Python bindings are built, also nanobind is required.

Windows

In this guide we will clone the FDML repo into C:\fdml\, install the dependencies into C:\fdml_deps\ and build FDML atrifacts into C:\fdml_build\. You should change these paths according to your needs.

When running cmake, pass -DFDML_WITH_PYBINDINGS:BOOL=ON, and than build normally via cmake --build ..

Linux

In this guide we will clone the FDML repo into ~/fdml/, install the dependencies into ~/fdml_deps/ and build FDML atrifacts into ~/fdml_build/. You should change these paths according to your needs.

Building with Python bindings

The installation follow the same steps as above, with addition dependencies installation before the the building using cmake:

When running cmake, pass -DFDML_WITH_PYBINDINGS:BOOL=ON, and than build normally via make -j.

FDML-GUI

Installation

FDML-core is required, see FDML-core section. In the future, FDML-py, the Python bindings, will be required as well.

Install python dependencies: pip install -r ./fdml-gui/requirements.txt

Usage

TODO

python fdml-gui/fdmlgui/scene_designer.py
python fdml-gui/fdmlgui/locator_gui.py