|
| 1 | +#ifndef I_TERARANGER_EVO_15M_HPP |
| 2 | +#define I_TERARANGER_EVO_15M_HPP |
| 3 | + |
| 4 | +/** |
| 5 | + * @Author Marcin Pilch |
| 6 | + * |
| 7 | + * @Copyright Terabee 2021 |
| 8 | + * |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * \example ExampleReadEvo15m.cpp |
| 13 | + */ |
| 14 | + |
| 15 | +#include "terabee/DistanceData.hpp" |
| 16 | + |
| 17 | +namespace terabee |
| 18 | +{ |
| 19 | + |
| 20 | +/** |
| 21 | + * Interface to <a href="https://www.terabee.com/shop/lidar-tof-range-finders/teraranger-evo-15m/">TeraRanger Evo 15m</a> sensor. |
| 22 | + * \see |
| 23 | + * - \ref ITerarangerFactory::createTerarangerEvo15m |
| 24 | + * - \ref ExampleReadEvo15m.cpp |
| 25 | + */ |
| 26 | +class ITerarangerEvo15m |
| 27 | +{ |
| 28 | +public: |
| 29 | + virtual ~ITerarangerEvo15m() = default; |
| 30 | + /** |
| 31 | + * Performs initialization of the device. |
| 32 | + * \return |
| 33 | + * - true on success |
| 34 | + * - false on failure, e.g. device disconnected, communication failure, |
| 35 | + * device already initialized |
| 36 | + */ |
| 37 | + virtual bool initialize() = 0; |
| 38 | + /** |
| 39 | + * Disconnects the device |
| 40 | + * \return |
| 41 | + * - true on success |
| 42 | + * - false on failure, e.g. device busy |
| 43 | + */ |
| 44 | + virtual bool shutDown() = 0; |
| 45 | + /** |
| 46 | + * Method for obtaining sensor measurement in a synchronous way. |
| 47 | + * \return |
| 48 | + * - returns measured distance in [m] |
| 49 | + * - If fails to communicate with sensor (e.g. device not initialized) returns `std::nan("")` |
| 50 | + * - If measurement cannot be done (e.g. sensor malfunction) returns -1 |
| 51 | + * - If object is too close returns `-std::numeric_limits<float>::infinity()` |
| 52 | + * - If measured value is out of range returns `std::numeric_limits<float>::infinity()` |
| 53 | + */ |
| 54 | + virtual DistanceData getDistance() = 0; |
| 55 | + /** |
| 56 | + * Method for obtaining sensor measurement in an asynchronous way. |
| 57 | + * Registers a callback to be invoked every time new data from the sensor is received; |
| 58 | + * \param cb |
| 59 | + * - The callback function must return `void` and accept one argument: const reference to DistanceData |
| 60 | + * - Callback registration must be done before sensor initialization |
| 61 | + * - Callbacks are invoked after sensor initialization when new data is constantly received |
| 62 | + * - Callback can be set to `nullptr`; In this case no callback will be invoked when new data is received |
| 63 | + * - Callback function should be short, heavy computations should be avoided, because it blocks asynchronous data capture routine; |
| 64 | + * |
| 65 | + * \return |
| 66 | + * - true on success |
| 67 | + * - false on failure (e.g. sensor already initialized) |
| 68 | + */ |
| 69 | + virtual bool registerOnDistanceDataCaptureCallback(OnDistanceDataCaptureCallback cb) = 0; |
| 70 | +}; |
| 71 | + |
| 72 | +} // namespace terabee |
| 73 | + |
| 74 | +#endif // I_TERARANGER_EVO_15M_HPP |
0 commit comments