From cb40f3734727fbb820776b71d373afe9d8c420cc Mon Sep 17 00:00:00 2001 From: ConstantRobotics Date: Sun, 16 Jun 2024 21:09:46 +0200 Subject: [PATCH] Got compiled --- src/CMakeLists.txt | 4 + src/Lrf.cpp | 823 ++++++++------------------------------------ src/Lrf.h | 830 +++++++++------------------------------------ src/LrfVersion.h | 7 + 4 files changed, 307 insertions(+), 1357 deletions(-) create mode 100644 src/LrfVersion.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e7830e4..05a45de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,10 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(BINARY_DIR "${CMAKE_BINARY_DIR}") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BINARY_DIR}/bin") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BINARY_DIR}/lib") +set(CMAKE_PDB_OUTPUT_DIRECTORY "${BINARY_DIR}/") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") +set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") file (GLOB_RECURSE IN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h.in) configure_file(${IN_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Version.h) diff --git a/src/Lrf.cpp b/src/Lrf.cpp index 46bada3..3c1ba87 100644 --- a/src/Lrf.cpp +++ b/src/Lrf.cpp @@ -1,166 +1,80 @@ -#include "Lens.h" -#include "LensVersion.h" +#include "Lrf.h" -cr::lens::FovPoint &cr::lens::FovPoint::operator= (const FovPoint &src) -{ - // Check yourself. - if (this == &src) - return *this; - - // Copy params. - hwZoomPos = src.hwZoomPos; - xFovDeg = src.xFovDeg; - yFovDeg = src.yFovDeg; - - return *this; -} +/// Link namespaces. +using namespace std; +using namespace cr::lrf; -cr::lens::LensParams &cr::lens::LensParams::operator= (const cr::lens::LensParams &src) +LrfParams& LrfParams::operator= (const LrfParams& src) { // Check yourself. if (this == &src) return *this; - // Copy params. initString = src.initString; - zoomPos = src.zoomPos; - zoomHwPos = src.zoomHwPos; - focusPos = src.focusPos; - focusHwPos = src.focusHwPos; - irisPos = src.irisPos; - irisHwPos = src.irisHwPos; - focusMode = src.focusMode; - filterMode = src.filterMode; - afRoiX0 = src.afRoiX0; - afRoiY0 = src.afRoiY0; - afRoiX1 = src.afRoiX1; - afRoiY1 = src.afRoiY1; - zoomSpeed = src.zoomSpeed; - zoomHwSpeed = src.zoomHwSpeed; - zoomHwMaxSpeed = src.zoomHwMaxSpeed; - focusSpeed = src.focusSpeed; - focusHwSpeed = src.focusHwSpeed; - focusHwMaxSpeed = src.focusHwMaxSpeed; - irisSpeed = src.irisSpeed; - irisHwSpeed = src.irisHwSpeed; - irisHwMaxSpeed = src.irisHwMaxSpeed; - zoomHwTeleLimit = src.zoomHwTeleLimit; - zoomHwWideLimit = src.zoomHwWideLimit; - focusHwFarLimit = src.focusHwFarLimit; - focusHwNearLimit = src.focusHwNearLimit; - irisHwOpenLimit = src.irisHwOpenLimit; - irisHwCloseLimit = src.irisHwCloseLimit; - focusFactor = src.focusFactor; - isConnected = src.isConnected; - afHwSpeed = src.afHwSpeed; - focusFactorThreshold = src.focusFactorThreshold; - refocusTimeoutSec = src.refocusTimeoutSec; - afIsActive = src.afIsActive; - irisMode = src.irisMode; - autoAfRoiWidth = src.autoAfRoiWidth; - autoAfRoiHeight = src.autoAfRoiHeight; - autoAfRoiBorder = src.autoAfRoiBorder; - afRoiMode = src.afRoiMode; - extenderMode = src.extenderMode; - stabiliserMode = src.stabiliserMode; - afRange = src.afRange; - xFovDeg = src.xFovDeg; - yFovDeg = src.yFovDeg; + distance = src.distance; + timeFromLastMeasurementUs = src.timeFromLastMeasurementUs; + lowPowerMode = src.lowPowerMode; + pointerMode = src.pointerMode; + pointerModeTimeoutSec = src.pointerModeTimeoutSec; + armMode = src.armMode; + operatingMode = src.operatingMode; + continuousMeasuringMode = src.continuousMeasuringMode; + continuousModeTimeoutSec = src.continuousModeTimeoutSec; logMode = src.logMode; - temperature = src.temperature; isOpen = src.isOpen; - type = src.type; + isConnected = src.isConnected; + minGateDistance = src.minGateDistance; + maxGateDistance = src.maxGateDistance; + temperatureDeg = src.temperatureDeg; custom1 = src.custom1; custom2 = src.custom2; custom3 = src.custom3; - fovPoints = src.fovPoints; return *this; } -bool cr::lens::LensParams::encode(uint8_t* data, int bufferSize, int& size, - cr::lens::LensParamsMask* mask) +bool LrfParams::encode(uint8_t* data, int bufferSize, int& size, LrfParamsMask* mask) { // Check buffer size. - if (bufferSize < 201) + if (bufferSize < 69) return false; // Encode version. int pos = 0; data[pos] = 0x02; pos += 1; - data[pos] = LENS_MAJOR_VERSION; pos += 1; - data[pos] = LENS_MINOR_VERSION; pos += 1; + data[pos] = LRF_MAJOR_VERSION; pos += 1; + data[pos] = LRF_MINOR_VERSION; pos += 1; // Set mask. - cr::lens::LensParamsMask defaultMask; + LrfParamsMask defaultMask; if (mask == nullptr) mask = &defaultMask; - + // Prepare mask. data[pos] = 0; - data[pos] = data[pos] | (mask->zoomPos ? (uint8_t)128 : (uint8_t)0); - data[pos] = data[pos] | (mask->zoomHwPos ? (uint8_t)64 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusPos ? (uint8_t)32 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusHwPos ? (uint8_t)16 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisPos ? (uint8_t)8 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisHwPos ? (uint8_t)4 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusMode ? (uint8_t)2 : (uint8_t)0); - data[pos] = data[pos] | (mask->filterMode ? (uint8_t)1 : (uint8_t)0); + data[pos] = data[pos] | (mask->distance ? (uint8_t)128 : (uint8_t)0); + data[pos] = data[pos] | (mask->timeFromLastMeasurementUs ? (uint8_t)64 : (uint8_t)0); + data[pos] = data[pos] | (mask->lowPowerMode ? (uint8_t)32 : (uint8_t)0); + data[pos] = data[pos] | (mask->pointerMode ? (uint8_t)16 : (uint8_t)0); + data[pos] = data[pos] | (mask->pointerModeTimeoutSec ? (uint8_t)8 : (uint8_t)0); + data[pos] = data[pos] | (mask->armMode ? (uint8_t)4 : (uint8_t)0); + data[pos] = data[pos] | (mask->operatingMode ? (uint8_t)2 : (uint8_t)0); + data[pos] = data[pos] | (mask->continuousMeasuringMode ? (uint8_t)1 : (uint8_t)0); pos += 1; data[pos] = 0; - data[pos] = data[pos] | (mask->afRoiX0 ? (uint8_t)128 : (uint8_t)0); - data[pos] = data[pos] | (mask->afRoiY0 ? (uint8_t)64 : (uint8_t)0); - data[pos] = data[pos] | (mask->afRoiX1 ? (uint8_t)32 : (uint8_t)0); - data[pos] = data[pos] | (mask->afRoiY1 ? (uint8_t)16 : (uint8_t)0); - data[pos] = data[pos] | (mask->zoomSpeed ? (uint8_t)8 : (uint8_t)0); - data[pos] = data[pos] | (mask->zoomHwSpeed ? (uint8_t)4 : (uint8_t)0); - data[pos] = data[pos] | (mask->zoomHwMaxSpeed ? (uint8_t)2 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusSpeed ? (uint8_t)1 : (uint8_t)0); - pos += 1; - data[pos] = 0; - data[pos] = data[pos] | (mask->focusHwSpeed ? (uint8_t)128 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusHwMaxSpeed ? (uint8_t)64 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisSpeed ? (uint8_t)32 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisHwSpeed ? (uint8_t)16 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisHwMaxSpeed ? (uint8_t)8 : (uint8_t)0); - data[pos] = data[pos] | (mask->zoomHwTeleLimit ? (uint8_t)4 : (uint8_t)0); - data[pos] = data[pos] | (mask->zoomHwWideLimit ? (uint8_t)2 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusHwFarLimit ? (uint8_t)1 : (uint8_t)0); - pos += 1; - data[pos] = 0; - data[pos] = data[pos] | (mask->focusHwNearLimit ? (uint8_t)128 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisHwOpenLimit ? (uint8_t)64 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisHwCloseLimit ? (uint8_t)32 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusFactor ? (uint8_t)16 : (uint8_t)0); - data[pos] = data[pos] | (mask->isConnected ? (uint8_t)8 : (uint8_t)0); - data[pos] = data[pos] | (mask->afHwSpeed ? (uint8_t)4 : (uint8_t)0); - data[pos] = data[pos] | (mask->focusFactorThreshold ? (uint8_t)2 : (uint8_t)0); - data[pos] = data[pos] | (mask->refocusTimeoutSec ? (uint8_t)1 : (uint8_t)0); - pos += 1; - data[pos] = 0; - data[pos] = data[pos] | (mask->afIsActive ? (uint8_t)128 : (uint8_t)0); - data[pos] = data[pos] | (mask->irisMode ? (uint8_t)64 : (uint8_t)0); - data[pos] = data[pos] | (mask->autoAfRoiWidth ? (uint8_t)32 : (uint8_t)0); - data[pos] = data[pos] | (mask->autoAfRoiHeight ? (uint8_t)16 : (uint8_t)0); - data[pos] = data[pos] | (mask->autoAfRoiBorder ? (uint8_t)8 : (uint8_t)0); - data[pos] = data[pos] | (mask->afRoiMode ? (uint8_t)4 : (uint8_t)0); - data[pos] = data[pos] | (mask->extenderMode ? (uint8_t)2 : (uint8_t)0); - data[pos] = data[pos] | (mask->stabiliserMode ? (uint8_t)1 : (uint8_t)0); - pos += 1; - data[pos] = 0; - data[pos] = data[pos] | (mask->afRange ? (uint8_t)128 : (uint8_t)0); - data[pos] = data[pos] | (mask->xFovDeg ? (uint8_t)64 : (uint8_t)0); - data[pos] = data[pos] | (mask->yFovDeg ? (uint8_t)32 : (uint8_t)0); - data[pos] = data[pos] | (mask->logMode ? (uint8_t)16 : (uint8_t)0); - data[pos] = data[pos] | (mask->temperature ? (uint8_t)8 : (uint8_t)0); - data[pos] = data[pos] | (mask->isOpen ? (uint8_t)4 : (uint8_t)0); - data[pos] = data[pos] | (mask->type ? (uint8_t)2 : (uint8_t)0); + data[pos] = data[pos] | (mask->continuousModeTimeoutSec ? (uint8_t)128 : (uint8_t)0); + data[pos] = data[pos] | (mask->logMode ? (uint8_t)64 : (uint8_t)0); + data[pos] = data[pos] | (mask->isOpen ? (uint8_t)32 : (uint8_t)0); + data[pos] = data[pos] | (mask->isConnected ? (uint8_t)16 : (uint8_t)0); + data[pos] = data[pos] | (mask->minGateDistance ? (uint8_t)8 : (uint8_t)0); + data[pos] = data[pos] | (mask->maxGateDistance ? (uint8_t)4 : (uint8_t)0); + data[pos] = data[pos] | (mask->temperatureDeg ? (uint8_t)2 : (uint8_t)0); data[pos] = data[pos] | (mask->custom1 ? (uint8_t)1 : (uint8_t)0); pos += 1; data[pos] = 0; @@ -169,198 +83,74 @@ bool cr::lens::LensParams::encode(uint8_t* data, int bufferSize, int& size, pos += 1; // Encode data. - if (mask->zoomPos) - { - memcpy(&data[pos], &zoomPos, 4); pos += 4; - } - if (mask->zoomHwPos) - { - memcpy(&data[pos], &zoomHwPos, 4); pos += 4; - } - if (mask->focusPos) - { - memcpy(&data[pos], &focusPos, 4); pos += 4; - } - if (mask->focusHwPos) - { - memcpy(&data[pos], &focusHwPos, 4); pos += 4; - } - if (mask->irisPos) - { - memcpy(&data[pos], &irisPos, 4); pos += 4; - } - if (mask->irisHwPos) - { - memcpy(&data[pos], &irisHwPos, 4); pos += 4; - } - if (mask->focusMode) - { - memcpy(&data[pos], &focusMode, 4); pos += 4; - } - if (mask->filterMode) - { - memcpy(&data[pos], &filterMode, 4); pos += 4; - } - if (mask->afRoiX0) - { - memcpy(&data[pos], &afRoiX0, 4); pos += 4; - } - if (mask->afRoiY0) - { - memcpy(&data[pos], &afRoiY0, 4); pos += 4; - } - if (mask->afRoiX1) - { - memcpy(&data[pos], &afRoiX1, 4); pos += 4; - } - if (mask->afRoiY1) - { - memcpy(&data[pos], &afRoiY1, 4); pos += 4; - } - if (mask->zoomSpeed) - { - memcpy(&data[pos], &zoomSpeed, 4); pos += 4; - } - if (mask->zoomHwSpeed) - { - memcpy(&data[pos], &zoomHwSpeed, 4); pos += 4; - } - if (mask->zoomHwMaxSpeed) - { - memcpy(&data[pos], &zoomHwMaxSpeed, 4); pos += 4; - } - if (mask->focusSpeed) - { - memcpy(&data[pos], &focusSpeed, 4); pos += 4; - } - if (mask->focusHwSpeed) - { - memcpy(&data[pos], &focusHwSpeed, 4); pos += 4; - } - if (mask->focusHwMaxSpeed) + if (mask->distance) { - memcpy(&data[pos], &focusHwMaxSpeed, 4); pos += 4; + memcpy(&data[pos], &distance, 4); pos += 4; } - if (mask->irisSpeed) + if (mask->timeFromLastMeasurementUs) { - memcpy(&data[pos], &irisSpeed, 4); pos += 4; + memcpy(&data[pos], &timeFromLastMeasurementUs, 4); pos += 4; } - if (mask->irisHwSpeed) + if (mask->lowPowerMode) { - memcpy(&data[pos], &irisHwSpeed, 4); pos += 4; + memcpy(&data[pos], &lowPowerMode, 4); pos += 4; } - if (mask->irisHwMaxSpeed) + if (mask->pointerMode) { - memcpy(&data[pos], &irisHwMaxSpeed, 4); pos += 4; + memcpy(&data[pos], &pointerMode, 4); pos += 4; } - if (mask->zoomHwTeleLimit) + if (mask->pointerModeTimeoutSec) { - memcpy(&data[pos], &zoomHwTeleLimit, 4); pos += 4; + memcpy(&data[pos], &pointerModeTimeoutSec, 4); pos += 4; } - if (mask->zoomHwWideLimit) + if (mask->armMode) { - memcpy(&data[pos], &zoomHwWideLimit, 4); pos += 4; + memcpy(&data[pos], &armMode, 4); pos += 4; } - if (mask->focusHwFarLimit) + if (mask->operatingMode) { - memcpy(&data[pos], &focusHwFarLimit, 4); pos += 4; + memcpy(&data[pos], &operatingMode, 4); pos += 4; } - if (mask->focusHwNearLimit) + if (mask->continuousMeasuringMode) { - memcpy(&data[pos], &focusHwNearLimit, 4); pos += 4; + memcpy(&data[pos], &continuousMeasuringMode, 4); pos += 4; } - if (mask->irisHwOpenLimit) + + + if (mask->continuousModeTimeoutSec) { - memcpy(&data[pos], &irisHwOpenLimit, 4); pos += 4; + memcpy(&data[pos], &continuousModeTimeoutSec, 4); pos += 4; } - if (mask->irisHwCloseLimit) + if (mask->logMode) { - memcpy(&data[pos], &irisHwCloseLimit, 4); pos += 4; + memcpy(&data[pos], &logMode, 4); pos += 4; } - if (mask->focusFactor) + if (mask->isOpen) { - memcpy(&data[pos], &focusFactor, 4); pos += 4; + data[pos] = isOpen ? 0x01 : 0x00; pos += 1; } if (mask->isConnected) { data[pos] = isConnected ? 0x01 : 0x00; pos += 1; } - if (mask->afHwSpeed) - { - memcpy(&data[pos], &afHwSpeed, 4); pos += 4; - } - if (mask->focusFactorThreshold) - { - memcpy(&data[pos], &focusFactorThreshold, 4); pos += 4; - } - if (mask->refocusTimeoutSec) - { - memcpy(&data[pos], &refocusTimeoutSec, 4); pos += 4; - } - if (mask->afIsActive) - { - data[pos] = afIsActive ? 0x01 : 0x00; pos += 1; - } - if (mask->irisMode) + if (mask->minGateDistance) { - memcpy(&data[pos], &irisMode, 4); pos += 4; + memcpy(&data[pos], &minGateDistance, 4); pos += 4; } - if (mask->autoAfRoiWidth) + if (mask->maxGateDistance) { - memcpy(&data[pos], &autoAfRoiWidth, 4); pos += 4; + memcpy(&data[pos], &maxGateDistance, 4); pos += 4; } - if (mask->autoAfRoiHeight) + if (mask->temperatureDeg) { - memcpy(&data[pos], &autoAfRoiHeight, 4); pos += 4; - } - if (mask->autoAfRoiBorder) - { - memcpy(&data[pos], &autoAfRoiBorder, 4); pos += 4; - } - if (mask->afRoiMode) - { - memcpy(&data[pos], &afRoiMode, 4); pos += 4; - } - if (mask->extenderMode) - { - memcpy(&data[pos], &extenderMode, 4); pos += 4; - } - if (mask->stabiliserMode) - { - memcpy(&data[pos], &stabiliserMode, 4); pos += 4; - } - if (mask->afRange) - { - memcpy(&data[pos], &afRange, 4); pos += 4; - } - if (mask->xFovDeg) - { - memcpy(&data[pos], &xFovDeg, 4); pos += 4; - } - if (mask->yFovDeg) - { - memcpy(&data[pos], &yFovDeg, 4); pos += 4; - } - if (mask->logMode) - { - memcpy(&data[pos], &logMode, 4); pos += 4; - } - if (mask->temperature) - { - memcpy(&data[pos], &temperature, 4); pos += 4; - } - if (mask->isOpen) - { - data[pos] = isOpen ? 0x01 : 0x00; pos += 1; - } - if (mask->type) - { - memcpy(&data[pos], &type, 4); pos += 4; + memcpy(&data[pos], &temperatureDeg, 4); pos += 4; } if (mask->custom1) { memcpy(&data[pos], &custom1, 4); pos += 4; } + + if (mask->custom2) { memcpy(&data[pos], &custom2, 4); pos += 4; @@ -377,10 +167,10 @@ bool cr::lens::LensParams::encode(uint8_t* data, int bufferSize, int& size, -bool cr::lens::LensParams::decode(uint8_t* data, int dataSize) +bool LrfParams::decode(uint8_t* data, int dataSize) { // Check data size. - if (dataSize < 11) + if (dataSize < 6) return false; // Check header. @@ -388,8 +178,8 @@ bool cr::lens::LensParams::decode(uint8_t* data, int dataSize) return false; // Check version. - if (data[1] != LENS_MAJOR_VERSION || - data[2] != LENS_MINOR_VERSION) + if (data[1] != LRF_MAJOR_VERSION || + data[2] != LRF_MINOR_VERSION) return false; int pos = 10; @@ -397,81 +187,81 @@ bool cr::lens::LensParams::decode(uint8_t* data, int dataSize) { if (dataSize < pos + 4) return false; - memcpy(&zoomPos, &data[pos], 4); pos += 4; + memcpy(&distance, &data[pos], 4); pos += 4; } else { - zoomPos = 0; + distance = 0.0f; } if ((data[3] & (uint8_t)64) == (uint8_t)64) { if (dataSize < pos + 4) return false; - memcpy(&zoomHwPos, &data[pos], 4); pos += 4; + memcpy(&timeFromLastMeasurementUs, &data[pos], 4); pos += 4; } else { - zoomHwPos = 0; + timeFromLastMeasurementUs = 0; } if ((data[3] & (uint8_t)32) == (uint8_t)32) { if (dataSize < pos + 4) return false; - memcpy(&focusPos, &data[pos], 4); pos += 4; + memcpy(&lowPowerMode, &data[pos], 4); pos += 4; } else { - focusPos = 0; + lowPowerMode = 0; } if ((data[3] & (uint8_t)16) == (uint8_t)16) { if (dataSize < pos + 4) return false; - memcpy(&focusHwPos, &data[pos], 4); pos += 4; + memcpy(&pointerMode, &data[pos], 4); pos += 4; } else { - focusHwPos = 0; + pointerMode = 0; } if ((data[3] & (uint8_t)8) == (uint8_t)8) { if (dataSize < pos + 4) return false; - memcpy(&irisPos, &data[pos], 4); pos += 4; + memcpy(&pointerModeTimeoutSec, &data[pos], 4); pos += 4; } else { - irisPos = 0; + pointerModeTimeoutSec = 0; } if ((data[3] & (uint8_t)4) == (uint8_t)4) { if (dataSize < pos + 4) return false; - memcpy(&irisHwPos, &data[pos], 4); pos += 4; + memcpy(&armMode, &data[pos], 4); pos += 4; } else { - irisHwPos = 0; + armMode = 0; } if ((data[3] & (uint8_t)2) == (uint8_t)2) { if (dataSize < pos + 4) return false; - memcpy(&focusMode, &data[pos], 4); pos += 4; + memcpy(&operatingMode, &data[pos], 4); pos += 4; } else { - focusMode = 0; + operatingMode = 0; } if ((data[3] & (uint8_t)1) == (uint8_t)1) { if (dataSize < pos + 4) return false; - memcpy(&filterMode, &data[pos], 4); pos += 4; + memcpy(&continuousMeasuringMode, &data[pos], 4); pos += 4; } else { - filterMode = 0; + continuousMeasuringMode = 0; } @@ -479,404 +269,73 @@ bool cr::lens::LensParams::decode(uint8_t* data, int dataSize) { if (dataSize < pos + 4) return false; - memcpy(&afRoiX0, &data[pos], 4); pos += 4; + memcpy(&continuousModeTimeoutSec, &data[pos], 4); pos += 4; } else { - afRoiX0 = 0; + continuousModeTimeoutSec = 0; } if ((data[4] & (uint8_t)64) == (uint8_t)64) { if (dataSize < pos + 4) return false; - memcpy(&afRoiY0, &data[pos], 4); pos += 4; + memcpy(&logMode, &data[pos], 4); pos += 4; } else { - afRoiY0 = 0; + logMode = 0; } if ((data[4] & (uint8_t)32) == (uint8_t)32) { - if (dataSize < pos + 4) + if (dataSize < pos + 1) return false; - memcpy(&afRoiX1, &data[pos], 4); pos += 4; + isOpen = data[pos] == 0x00 ? false : true; pos += 1; } else { - afRoiX1 = 0; + isOpen = false; } if ((data[4] & (uint8_t)16) == (uint8_t)16) { - if (dataSize < pos + 4) + if (dataSize < pos + 1) return false; - memcpy(&afRoiY1, &data[pos], 4); pos += 4; + isConnected = data[pos] == 0x00 ? false : true; pos += 1; } else { - afRoiY1 = 0; + isConnected = false; } if ((data[4] & (uint8_t)8) == (uint8_t)8) { if (dataSize < pos + 4) return false; - memcpy(&zoomSpeed, &data[pos], 4); pos += 4; + memcpy(&minGateDistance, &data[pos], 4); pos += 4; } else { - zoomSpeed = 0; + minGateDistance = 0.0f; } if ((data[4] & (uint8_t)4) == (uint8_t)4) { if (dataSize < pos + 4) return false; - memcpy(&zoomHwSpeed, &data[pos], 4); pos += 4; + memcpy(&maxGateDistance, &data[pos], 4); pos += 4; } else { - zoomHwSpeed = 0; + maxGateDistance = 0.0f; } if ((data[4] & (uint8_t)2) == (uint8_t)2) { if (dataSize < pos + 4) return false; - memcpy(&zoomHwMaxSpeed, &data[pos], 4); pos += 4; + memcpy(&temperatureDeg, &data[pos], 4); pos += 4; } else { - zoomHwMaxSpeed = 0; + temperatureDeg = 0.0f; } if ((data[4] & (uint8_t)1) == (uint8_t)1) - { - if (dataSize < pos + 4) - return false; - memcpy(&focusSpeed, &data[pos], 4); pos += 4; - } - else - { - focusSpeed = 0; - } - - - - if ((data[5] & (uint8_t)128) == (uint8_t)128) - { - if (dataSize < pos + 4) - return false; - memcpy(&focusHwSpeed, &data[pos], 4); pos += 4; - } - else - { - focusHwSpeed = 0; - } - if ((data[5] & (uint8_t)64) == (uint8_t)64) - { - if (dataSize < pos + 4) - return false; - memcpy(&focusHwMaxSpeed, &data[pos], 4); pos += 4; - } - else - { - focusHwMaxSpeed = 0; - } - if ((data[5] & (uint8_t)32) == (uint8_t)32) - { - if (dataSize < pos + 4) - return false; - memcpy(&irisSpeed, &data[pos], 4); pos += 4; - } - else - { - irisSpeed = 0; - } - if ((data[5] & (uint8_t)16) == (uint8_t)16) - { - if (dataSize < pos + 4) - return false; - memcpy(&irisHwSpeed, &data[pos], 4); pos += 4; - } - else - { - irisHwSpeed = 0; - } - if ((data[5] & (uint8_t)8) == (uint8_t)8) - { - if (dataSize < pos + 4) - return false; - memcpy(&irisHwMaxSpeed, &data[pos], 4); pos += 4; - } - else - { - irisHwMaxSpeed = 0; - } - if ((data[5] & (uint8_t)4) == (uint8_t)4) - { - if (dataSize < pos + 4) - return false; - memcpy(&zoomHwTeleLimit, &data[pos], 4); pos += 4; - } - else - { - zoomHwTeleLimit = 0; - } - if ((data[5] & (uint8_t)2) == (uint8_t)2) - { - if (dataSize < pos + 4) - return false; - memcpy(&zoomHwWideLimit, &data[pos], 4); pos += 4; - } - else - { - zoomHwWideLimit = 0; - } - if ((data[5] & (uint8_t)1) == (uint8_t)1) - { - if (dataSize < pos + 4) - return false; - memcpy(&focusHwFarLimit, &data[pos], 4); pos += 4; - } - else - { - focusHwFarLimit = 0; - } - - - - if ((data[6] & (uint8_t)128) == (uint8_t)128) - { - if (dataSize < pos + 4) - return false; - memcpy(&focusHwNearLimit, &data[pos], 4); pos += 4; - } - else - { - focusHwNearLimit = 0; - } - if ((data[6] & (uint8_t)64) == (uint8_t)64) - { - if (dataSize < pos + 4) - return false; - memcpy(&irisHwOpenLimit, &data[pos], 4); pos += 4; - } - else - { - irisHwOpenLimit = 0; - } - if ((data[6] & (uint8_t)32) == (uint8_t)32) - { - if (dataSize < pos + 4) - return false; - memcpy(&irisHwCloseLimit, &data[pos], 4); pos += 4; - } - else - { - irisHwCloseLimit = 0; - } - if ((data[6] & (uint8_t)16) == (uint8_t)16) - { - if (dataSize < pos + 4) - return false; - memcpy(&focusFactor, &data[pos], 4); pos += 4; - } - else - { - focusFactor = 0; - } - if ((data[6] & (uint8_t)8) == (uint8_t)8) - { - if (dataSize < pos + 1) - return false; - isConnected = data[pos] == 0x00 ? false : true; pos += 1; - } - else - { - isConnected = false; - } - if ((data[6] & (uint8_t)4) == (uint8_t)4) - { - if (dataSize < pos + 4) - return false; - memcpy(&afHwSpeed, &data[pos], 4); pos += 4; - } - else - { - afHwSpeed = 0; - } - if ((data[6] & (uint8_t)2) == (uint8_t)2) - { - if (dataSize < pos + 4) - return false; - memcpy(&focusFactorThreshold, &data[pos], 4); pos += 4; - } - else - { - focusFactorThreshold = 0; - } - if ((data[6] & (uint8_t)1) == (uint8_t)1) - { - if (dataSize < pos + 4) - return false; - memcpy(&refocusTimeoutSec, &data[pos], 4); pos += 4; - } - else - { - refocusTimeoutSec = 0; - } - - - - if ((data[7] & (uint8_t)128) == (uint8_t)128) - { - if (dataSize < pos + 1) - return false; - afIsActive = data[pos] == 0x00 ? false : true; pos += 1; - } - else - { - afIsActive = false; - } - if ((data[7] & (uint8_t)64) == (uint8_t)64) - { - if (dataSize < pos + 4) - return false; - memcpy(&irisMode, &data[pos], 4); pos += 4; - } - else - { - irisMode = 0; - } - if ((data[7] & (uint8_t)32) == (uint8_t)32) - { - if (dataSize < pos + 4) - return false; - memcpy(&autoAfRoiWidth, &data[pos], 4); pos += 4; - } - else - { - autoAfRoiWidth = 0; - } - if ((data[7] & (uint8_t)16) == (uint8_t)16) - { - if (dataSize < pos + 4) - return false; - memcpy(&autoAfRoiHeight, &data[pos], 4); pos += 4; - } - else - { - autoAfRoiHeight = 0; - } - if ((data[7] & (uint8_t)8) == (uint8_t)8) - { - if (dataSize < pos + 4) - return false; - memcpy(&autoAfRoiBorder, &data[pos], 4); pos += 4; - } - else - { - autoAfRoiBorder = 0; - } - if ((data[7] & (uint8_t)4) == (uint8_t)4) - { - if (dataSize < pos + 4) - return false; - memcpy(&afRoiMode, &data[pos], 4); pos += 4; - } - else - { - afRoiMode = 0; - } - if ((data[7] & (uint8_t)2) == (uint8_t)2) - { - if (dataSize < pos + 4) - return false; - memcpy(&extenderMode, &data[pos], 4); pos += 4; - } - else - { - extenderMode = 0; - } - if ((data[7] & (uint8_t)1) == (uint8_t)1) - { - if (dataSize < pos + 4) - return false; - memcpy(&stabiliserMode, &data[pos], 4); pos += 4; - } - else - { - stabiliserMode = 0; - } - - - if ((data[8] & (uint8_t)128) == (uint8_t)128) - { - if (dataSize < pos + 4) - return false; - memcpy(&afRange, &data[pos], 4); pos += 4; - } - else - { - afRange = 0; - } - if ((data[8] & (uint8_t)64) == (uint8_t)64) - { - if (dataSize < pos + 4) - return false; - memcpy(&xFovDeg, &data[pos], 4); pos += 4; - } - else - { - xFovDeg = 0.0f; - } - if ((data[8] & (uint8_t)32) == (uint8_t)32) - { - if (dataSize < pos + 4) - return false; - memcpy(&yFovDeg, &data[pos], 4); pos += 4; - } - else - { - yFovDeg = 0.0f; - } - if ((data[8] & (uint8_t)16) == (uint8_t)16) - { - if (dataSize < pos + 4) - return false; - memcpy(&logMode, &data[pos], 4); pos += 4; - } - else - { - logMode = 0; - } - if ((data[8] & (uint8_t)8) == (uint8_t)8) - { - if (dataSize < pos + 4) - return false; - memcpy(&temperature, &data[pos], 4); pos += 4; - } - else - { - temperature = 0; - } - if ((data[8] & (uint8_t)4) == (uint8_t)4) - { - if (dataSize < pos + 1) - return false; - isOpen = data[pos] == 0x00 ? false : true; pos += 1; - } - else - { - isOpen = false; - } - if ((data[8] & (uint8_t)2) == (uint8_t)2) - { - if (dataSize < pos + 4) - return false; - memcpy(&type, &data[pos], 4); pos += 4; - } - else - { - type = 0; - } - if ((data[8] & (uint8_t)1) == (uint8_t)1) { if (dataSize < pos + 4) return false; @@ -888,7 +347,8 @@ bool cr::lens::LensParams::decode(uint8_t* data, int dataSize) } - if ((data[9] & (uint8_t)128) == (uint8_t)128) + + if ((data[5] & (uint8_t)128) == (uint8_t)128) { if (dataSize < pos + 4) return false; @@ -898,48 +358,45 @@ bool cr::lens::LensParams::decode(uint8_t* data, int dataSize) { custom2 = 0.0f; } - if ((data[9] & (uint8_t)64) == (uint8_t)64) + if ((data[5] & (uint8_t)64) == (uint8_t)64) { if (dataSize < pos + 4) return false; - memcpy(&custom3, &data[pos], 4); + memcpy(&custom3, &data[pos], 4); pos += 4; } else { custom3 = 0.0f; } + initString = ""; - fovPoints.clear(); return true; } -cr::lens::Lens::~Lens() +Lrf::~Lrf() { } -std::string cr::lens::Lens::getVersion() +std::string Lrf::getVersion() { - return LENS_VERSION; + return LRF_VERSION; } -void cr::lens::Lens::encodeSetParamCommand(uint8_t* data, - int& size, - cr::lens::LensParam id, - float value) +void Lrf::encodeSetParamCommand(uint8_t* data, int& size, LrfParam id, float value) { // Fill header. data[0] = 0x01; - data[1] = LENS_MAJOR_VERSION; - data[2] = LENS_MINOR_VERSION; + data[1] = LRF_MAJOR_VERSION; + data[2] = LRF_MINOR_VERSION; // Fill data. int paramId = (int)id; @@ -950,55 +407,51 @@ void cr::lens::Lens::encodeSetParamCommand(uint8_t* data, -void cr::lens::Lens::encodeCommand(uint8_t* data, - int& size, - cr::lens::LensCommand id, - float arg) +void Lrf::encodeCommand(uint8_t* data, int& size, LrfCommand id) { // Fill header. data[0] = 0x00; - data[1] = LENS_MAJOR_VERSION; - data[2] = LENS_MINOR_VERSION; + data[1] = LRF_MAJOR_VERSION; + data[2] = LRF_MINOR_VERSION; // Fill data. int commandId = (int)id; memcpy(&data[3], &commandId, 4); - memcpy(&data[7], &arg, 4); - size = 11; + size = 7; } -int cr::lens::Lens::decodeCommand(uint8_t* data, - int size, - cr::lens::LensParam& paramId, - cr::lens::LensCommand& commandId, - float& value) +int Lrf::decodeCommand(uint8_t* data, int size, LrfParam& paramId, LrfCommand& commandId, float& value) { // Check size. - if (size != 11) + if (size < 7) return -1; // Check version. - if (data[1] != LENS_MAJOR_VERSION || data[2] != LENS_MINOR_VERSION) + if (data[1] != LRF_MAJOR_VERSION || data[2] != LRF_MINOR_VERSION) return -1; - // Extract data. - int id = 0; - memcpy(&id, &data[3], 4); - memcpy(&value, &data[7], 4); - // Check command type. if (data[0] == 0x00) { - commandId = (LensCommand)id; - return 0; + if (size != 7) + return -1; + int id = 0; + memcpy(&id, &data[3], 4); + paramId = (LrfParam)id; + return 1; } else if (data[0] == 0x01) { - paramId = (LensParam)id; + if (size != 11) + return -1; + int id = 0; + memcpy(&id, &data[3], 4); + paramId = (LrfParam)id; + memcpy(&value, &data[7], 4); return 1; } return -1; -} +} \ No newline at end of file diff --git a/src/Lrf.h b/src/Lrf.h index 12ca267..2218200 100644 --- a/src/Lrf.h +++ b/src/Lrf.h @@ -1,371 +1,171 @@ #pragma once #include #include -#include "Frame.h" #include "ConfigReader.h" +#include "LrfVersion.h" namespace cr { -namespace lens +namespace lrf { +/** + * @brief Enum of laser range finder params. +*/ +enum class LrfParam +{ + /// [Read only] Current measured distance, meters. + DISTANCE = 1, + /// Time from last measurement, us. + TIME_FROM_LAST_MEASUREMENT_US, + /// Low power mode. Values depends on implementation. Default: 0 - OFF. + LOW_POWER_MODE, + /// Laser pointer mode: 0 - OFF, 1 - ON, 2 - ON timeout. + POINTER_MODE, + /// Pointer mode timeout, sec. + POINTER_MODE_TIMEOUT_SEC, + /// Arm mode: 0 - Disarmed, 1 - armed. + ARM_MODE, + /// Operating mode: 0 - OFF, 1 - Stand-by-mode, 2 - Normal mode. + OPERATING_MODE, + /// Continuous measuring mode: 0 - Stop, 1 - 0.5Hz, 2 - 1 - 1Hz, 3 - 3Hz, 4 - 5Hz, 5 - 10Hz. + CONTINUOUS_MEASURING_MODE, + /// Continuous mode timeout, sec. + CONTINUOUS_MODE_TIMEOUT_SEC, + /// Logging mode: 0 - Disabled, 1 - Console, 2 - File, 3 - Console and file. + LOG_MODE, + /// [Read only] Open status. + IS_OPEN, + /// [Read only] Connection status. + IS_CONNECTED, + /// Min gate distance, meters. + MIN_GATE_DISTANCE, + /// Max gate distance, meters. + MAX_GATE_DISTANCE, + /// Temperature, deg. + TEMPERATURE_DEG, + /// Custom parameter 1. Depends on implementation. + CUSTOM_1, + /// Custom parameter 2. Depends on implementation. + CUSTOM_2, + /// Custom parameter 3. Depends on implementation. + CUSTOM_3 +}; -/// Field of view point class. -class FovPoint +/** + * @brief Enum of laser range finder commands. +*/ +enum class LrfCommand { -public: - /// Hardware zoom pos. - int hwZoomPos{0}; - /// Horizontal field of view, degree. - float xFovDeg{0.0f}; - /// Vertical field of view, degree. - float yFovDeg{0.0f}; - - JSON_READABLE(FovPoint, - hwZoomPos, - xFovDeg, - yFovDeg); - - /** - * @brief operator = - * @param src Source object. - * @return FovPoint object. - */ - FovPoint& operator= (const FovPoint& src); + /// Arm. + ARM = 1, + /// Disarm. + DISARM, + /// Measure distance once. + MEASURE_DISTANCE_ONCE }; -/// Lens params mask structure. -typedef struct LensParamsMask +/** + * @brief Laser range finder params class. + */ +typedef struct LrfParamsMask { - bool zoomPos{true}; - bool zoomHwPos{true}; - bool focusPos{true}; - bool focusHwPos{true}; - bool irisPos{true}; - bool irisHwPos{true}; - bool focusMode{true}; - bool filterMode{true}; - bool afRoiX0{true}; - bool afRoiY0{true}; - bool afRoiX1{true}; - bool afRoiY1{true}; - bool zoomSpeed{true}; - bool zoomHwSpeed{true}; - bool zoomHwMaxSpeed{true}; - bool focusSpeed{true}; - bool focusHwSpeed{true}; - bool focusHwMaxSpeed{true}; - bool irisSpeed{true}; - bool irisHwSpeed{true}; - bool irisHwMaxSpeed{true}; - bool zoomHwTeleLimit{true}; - bool zoomHwWideLimit{true}; - bool focusHwFarLimit{true}; - bool focusHwNearLimit{true}; - bool irisHwOpenLimit{true}; - bool irisHwCloseLimit{true}; - bool focusFactor{true}; - bool isConnected{true}; - bool afHwSpeed{true}; - bool focusFactorThreshold{true}; - bool refocusTimeoutSec{true}; - bool afIsActive{true}; - bool irisMode{true}; - bool autoAfRoiWidth{true}; - bool autoAfRoiHeight{true}; - bool autoAfRoiBorder{true}; - bool afRoiMode{true}; - bool extenderMode{true}; - bool stabiliserMode{true}; - bool afRange{true}; - bool xFovDeg{true}; - bool yFovDeg{true}; + bool distance{true}; + bool timeFromLastMeasurementUs{true}; + bool lowPowerMode{true}; + bool pointerMode{true}; + bool pointerModeTimeoutSec{true}; + bool armMode{true}; + bool operatingMode{true}; + bool continuousMeasuringMode{true}; + bool continuousModeTimeoutSec{true}; bool logMode{true}; - bool temperature{true}; bool isOpen{true}; - bool type{true}; + bool isConnected{true}; + bool minGateDistance{true}; + bool maxGateDistance{true}; + bool temperatureDeg{true}; bool custom1{true}; bool custom2{true}; bool custom3{true}; -} LensParamsMask; +} LrfParamsMask; -/// Lens params class. -class LensParams +/** + * @brief Laser range finder params class. + */ +class LrfParams { public: - /// Initialization string. Particular lens controller can have unique init - /// string format. But it is recommended to use '**;**' symbol to divide - /// parts of initialization string. Recommended initialization string format - /// for controllers which uses serial port: "/dev/ttyUSB0;9600;100" - /// ("/dev/ttyUSB0" - serial port name, "9600" - baudrate, "100" - serial - /// port read timeout). - std::string initString{"/dev/ttyUSB0;9600;20"}; - /// Zoom position. Setting a parameter is equivalent to the command - /// ZOOM_TO_POS. Lens controller should have zoom range from 0 (full wide) - /// to 65535 (full tele) regardless of the hardware value of the zoom - /// position. If the minimum and maximum zoom position limits are set by - /// the user in the lens parameters, the range of the hardware zoom position - /// must be scaled to the user space 0-65535 range. Parameter value: zoom - /// position 0-65535. User should be able to set zoom movement speed via - /// lens parameters. - int zoomPos{0}; - /// Hardware zoom position. Parameter value depends on implementation and - /// lens hardware. - int zoomHwPos{0}; - /// Focus position. Setting a parameter is equivalent to the command - /// FOCUS_TO_POS. Lens controller should have focus range from 0 (full near) - /// to 65535 (full far) regardless of the hardware value of the focus - /// position. If the minimum and maximum focus position limits are set by - /// the user in the lens parameters, the range of the hardware focus - /// position must be scaled to the 0-65535 user space range. Parameter - /// value: focus position 0-65535. User should be able to set focus movement - /// speed via lens parameters. - int focusPos{0}; - /// Hardware focus position. Parameter value depends on implementation and - /// lens hardware. - int focusHwPos{0}; - /// Iris position. Setting a parameter is equivalent to the command - /// IRIS_TO_POS. Lens controller should have iris range from 0 (full close) - /// to 65535 (full far) regardless of the hardware value of the iris - /// position. If the minimum and maximum iris position limits are set by the - /// user in the lens parameters, the range of the hardware iris position - /// must be scaled to the 0-65535 user space range. Parameter value: iris - /// position 0-65535. User should be able to set iris movement speed via - /// lens parameters. - int irisPos{0}; - /// Hardware iris position. Parameter value depends on implementation. - int irisHwPos{0}; - /// Focus mode. Parameter value depends on implementation but it is - /// recommended to keep default values: 0 - Manual focus control, - /// 1 - Auto focus control. - int focusMode{0}; - /// Filter mode. Parameter value depends on implementation but it is - /// recommended to keep default values: 0 - Filter on, 1 - Filter off. - int filterMode{0}; - /// Autofocus ROI top-left corner horizontal position in pixels. - /// Autofocus ROI is rectangle. - int afRoiX0{0}; - /// Autofocus ROI top-left corner vertical position in pixels. - /// Autofocus ROI is rectangle. - int afRoiY0{0}; - /// Autofocus ROI bottom-right corner horizontal position in pixels. - /// Autofocus ROI is rectangle. - int afRoiX1{0}; - /// Autofocus ROI bottom-right corner vertical position in pixels. - /// Autofocus ROI is rectangle. - int afRoiY1{0}; - /// Zoom speed. Lens controller should have zoom speed range from 0 to - /// 100% of max hardware zoom speed (parameter ZOOM_HW_MAX_SPEED). If the - /// user sets a new parameter value of the ZOOM_HW_SPEED the parameter - /// ZOOM_SPEED must be updated automatically. Formula for calculating speed: - /// ZOOM_SPEED = ( ZOOM_HW_SPEED / ZOOM_HW_MAX_SPEED) * 100. - int zoomSpeed{50}; - /// Zoom hardware speed. Value depends on implementation and lens hardware. - /// The value of the parameters must be <= ZOOM_HW_MAX_SPEED parameter. - /// If the user sets a new parameter value of the ZOOM_SPEED parameter - /// the parameter ZOOM_HW_SPEED must be updated automatically. Formula for - /// calculating hardware speed: - /// ZOOM_HW_SPEED = ( ZOOM_SPEED / 100 ) * ZOOM_HW_MAX_SPEED. - int zoomHwSpeed{50}; - /// Maximum zoom hardware speed. Value depends on implementation. If user - /// sets new ZOOM_HW_MAX_SPEED value the parameters ZOOM_SPEED must be - /// updated automatically. If new value of ZOOM_HW_MAX_SPEED parameter will - /// be less than ZOOM_HW_SPEED the parameter ZOOM_HW_SPEED must be reduced - /// automatically. - int zoomHwMaxSpeed{50}; - /// Focus speed. Lens controller should have focus speed range from 0 to - /// 100% of max hardware focus speed (parameter FOCUS_HW_MAX_SPEED). If the - /// user sets a new parameter value of the FOCUS_HW_SPEED the parameter - /// FOCUS_SPEED must be updated automatically. Formula for calculating - /// speed: FOCUS_SPEED = ( FOCUS_HW_SPEED / FOCUS_HW_MAX_SPEED) * 100. - int focusSpeed{50}; - /// Focus hardware speed. Value depends on on implementation and lens - /// hardware. The value of the parameters must be <= FOCUS_HW_MAX_SPEED - /// parameter. If the user sets a new parameter value of the FOCUS_SPEED - /// parameter the parameter FOCUS_HW_SPEED must be updated automatically. - /// Formula for calculating hardware speed: - /// FOCUS_HW_SPEED = ( FOCUS_SPEED / 100 ) * FOCUS_HW_MAX_SPEED. - int focusHwSpeed{50}; - /// Maximum focus hardware speed. Value depends on implementation. If user - /// sets new FOCUS_HW_MAX_SPEED value the parameters FOCUS_SPEED and - /// FOCUS_HW_SPEED must be updated by lens controller automatically. - /// If new value of FOCUS_HW_MAX_SPEED parameter will be less than - /// FOCUS_HW_SPEED the parameter FOCUS_HW_SPEED must be reduced - /// automatically. - int focusHwMaxSpeed{50}; - /// Iris speed. Lens controller should have iris speed range from 0 to 100% - /// of max hardware iris speed (parameter IRIS_HW_MAX_SPEED). If the user - /// sets a new parameter value of the IRIS_HW_SPEED the parameter IRIS_SPEED - /// must be updated automatically. Formula for calculating speed: - /// IRIS_SPEED = ( IRIS_HW_SPEED / IRIS_HW_MAX_SPEED) * 100. - int irisSpeed{50}; - /// Iris hardware speed. Value depends on implementation and les hardware. - /// The value of the parameters must be <= IRIS_HW_MAX_SPEED parameter. - /// If the user sets a new parameter value of the IRIS_SPEED parameter the - /// parameter IRIS_HW_SPEED must be updated automatically. Formula for - /// calculating hardware speed: - /// IRIS_HW_SPEED = ( IRIS_SPEED / 100 ) * IRIS_HW_MAX_SPEED. - int irisHwSpeed{50}; - /// Maximum iris hardware speed. Value depends on implementation. If user - /// sets new IRIS_HW_MAX_SPEED value the parameters IRIS_SPEED and - /// IRIS_HW_SPEED must be updated automatically. If new value of - /// IRIS_HW_MAX_SPEED parameter will be less than IRIS_HW_SPEED the - /// parameter IRIS_HW_SPEED must be reduced automatically. - int irisHwMaxSpeed{50}; - /// Zoom hardware tele limit. Value depends on implementation and lens - /// hardware. Lens controller should control zoom position. Lens controller - /// should stop zoom moving if hardware zoom position will be our of limits. - int zoomHwTeleLimit{65535}; - /// Zoom hardware wide limit. Value depends on implementation and lens - /// hardware. Lens controller should control zoom position. Lens controller - /// should stop zoom moving if hardware zoom position will be our of limits. - int zoomHwWideLimit{0}; - /// Focus hardware far limit. Value depends on on implementation and lens - /// hardware. Lens controller should control focus position. Lens controller - /// should stop focus moving if hardware focus position will be our of - /// limits. - int focusHwFarLimit{65535}; - /// Focus hardware near limit. Value depends on implementation and lens - /// hardware. Lens controller should control focus position. Lens controller - /// should stop focus moving if hardware focus position will be our of - /// limits. - int focusHwNearLimit{0}; - /// Iris hardware open limit. Value depends on implementation and lens - /// hardware. Lens controller should control iris position. Lens controller - /// should stop iris moving if hardware iris position will be our of limits. - int irisHwOpenLimit{65535}; - /// Iris hardware close limit. Value depends on implementation and lens - /// hardware. Lens controller should control iris position. Lens controller - /// should stop iris moving if hardware iris position will be our of limits. - int irisHwCloseLimit{0}; - /// Focus factor if it was calculated. If not calculated must be -1. - /// Value depends on particular lens controller. - float focusFactor{0.0f}; - /// Lens connection status. Connection status shows if the lens controller - /// has data exchange with lens equipment. For example, if lens has serial - /// port lens controller connects to serial port (opens serial port file - /// in OS) but lens can be not active (no power). In this case connection - /// status shows that lens controller doesn't have data exchange with lens - /// equipment (methos will return 0). It lens controller has data exchange - /// with lens equipment the method will return 1. If lens controller not - /// initialize the connection status always FALSE. Value: - /// false - not connected. true - connected. - bool isConnected{false}; - /// Focus hardware speed in autofocus mode. Value depends on implementation - /// and lens hardware. - int afHwSpeed{50}; - /// Timeout for automatic refocus in seconds. Value: 0 - no automatic - /// refocus, 100000 - maximum value. - float focusFactorThreshold{0.0f}; - /// Timeout for automatic refocus in seconds. Value: - /// 0 - no automatic refocus, 100000 - maximum value. - int refocusTimeoutSec{0}; - /// Flag about active autofocus algorithm. Value: 0 - autofocus not working, - /// 1 - working. - bool afIsActive{false}; - /// Iris mode. Value depends on implementation but it is recommended to keep - /// default values: 0 - manual iris control, 1 - auto iris control. - int irisMode{0}; - /// ROI width (pixels) for autofocus algorithm when lens controller detects - /// ROI position automatically. Value: from 8 to (video frame width - - /// AUTO_AF_ROI_BORDER * 2). - int autoAfRoiWidth{150}; - /// ROI height (pixels) for autofocus algorithm when lens controller detects - /// ROI position automatically. Value: from 8 to (video frame width - - /// AUTO_AF_ROI_BORDER * 2). - int autoAfRoiHeight{150}; - /// Video frame border size (along vertical and horizontal axes). - /// Value: border size from 0 to video - /// frame min(video frame width/height) / 2. - int autoAfRoiBorder{100}; - /// AF ROI mode (write/read). Value: 0 - Manual position, 1 - Auto position. - int afRoiMode{0}; - /// Lens extender mode. Value depends on implementation but it is - /// recommended to keep default values: 0 - no extender, 1 - x2 extender. - int extenderMode{0}; - /// Lens stabilization mode. Value depends on implementation but it is - /// recommended to keep default values: 0 - no stabilization, - /// 1 - stabilization. - int stabiliserMode{0}; - /// Autofocus range. Value depends on implementation. - int afRange{0}; - /// Current horizontal Field of view, degree. Field of view calculated by - /// lens controller according to initial params or by reading directly from - /// lens hardware. - float xFovDeg{1.0f}; - /// Current vertical Field of view, degree. Field of view calculated by lens - /// controller according to initial params or by reading directly from lens - /// hardware. - float yFovDeg{1.0f}; - /// Logging mode. Values: 0 - Disable, 1 - Only file, 2 - Only terminal, - /// 3 - File and terminal. + + /// Initialization string. Format depends on implementation. + std::string initString; + /// Current measured distance, meters. + float distance{0.0f}; + /// Time from last measurement, us. + int timeFromLastMeasurementUs{0}; + /// Low power mode. Values depends on implementation. Default: 0 - OFF. + int lowPowerMode{0}; + /// Laser pointer mode: 0 - OFF, 1 - ON, 2 - ON timeout. + int pointerMode{0}; + /// Pointer mode timeout, sec. + int pointerModeTimeoutSec{0}; + /// Arm mode: 0 - Disarmed, 1 - armed. + int armMode{0}; + /// Operating mode: 0 - OFF, 1 - Stand-by-mode, 2 - Normal mode. + int operatingMode{0}; + /// Continuous measuring mode: 0 - Stop, 1 - 0.5Hz, 2 - 1 - 1Hz, 3 - 3Hz, 4 - 5Hz, 5 - 10Hz. + int continuousMeasuringMode{0}; + /// Continuous mode timeout, sec. + int continuousModeTimeoutSec{0}; + /// Logging mode: 0 - Disabled, 1 - Console, 2 - File, 3 - Console and file. int logMode{0}; - /// Lens temperature, degree (read only). - float temperature{0.0f}; - /// Lens controller initialization status. Open status shows if the lens - /// controller initialized or not but doesn't show if lens controller has - /// communication with lens equipment. For example, if lens has serial port - /// lens controller connects to serial port (opens serial port file in OS) - /// but lens can be not active (no power). In this case open status just - /// shows that lens controller has opened serial port. - /// Values: false - not open (not initialized), true - open (initialized). + /// Open status. bool isOpen{false}; - /// Lens type. Value depends on implementation. Type allows to lens - /// initialize necessary parameters for particular lens hardware. - int type{0}; - /// Lens custom parameter. Value depends on particular lens controller. - /// Custom parameters used when particular lens equipment has specific - /// unusual parameter. + /// Connection status. + bool isConnected{false}; + /// Min gate distance, meters. + float minGateDistance{0}; + /// Max gate distance, meters. + float maxGateDistance{0}; + /// Temperature, deg. + float temperatureDeg{0.0f}; + /// Custom parameter 1. Depends on implementation. float custom1{0.0f}; - /// Lens custom parameter. Value depends on particular lens controller. - /// Custom parameters used when particular lens equipment has specific - /// unusual parameter. + /// Custom parameter 2. Depends on implementation. float custom2{0.0f}; - /// Lens custom parameter. Value depends on particular lens controller. - /// Custom parameters used when particular lens equipment has specific - /// unusual parameter. + /// Custom parameter 3. Depends on implementation. float custom3{0.0f}; - /// List of points to calculate fiend of view. Lens controller should - /// calculate FOV table according to given list f points using - /// approximation. - std::vector fovPoints{std::vector()}; - - JSON_READABLE(LensParams, initString, focusMode, filterMode, - afRoiX0, afRoiY0, afRoiX1, afRoiY1, zoomHwMaxSpeed, - focusHwMaxSpeed, irisHwMaxSpeed, zoomHwTeleLimit, - zoomHwWideLimit, focusHwFarLimit, focusHwNearLimit, - irisHwOpenLimit, irisHwCloseLimit, afHwSpeed, - focusFactorThreshold, refocusTimeoutSec, irisMode, - autoAfRoiWidth, autoAfRoiHeight, autoAfRoiBorder, - afRoiMode, extenderMode, stabiliserMode, afRange, - logMode, type, custom1, custom2, custom3, fovPoints); + + JSON_READABLE(LrfParams, initString, lowPowerMode, pointerModeTimeoutSec, + operatingMode, continuousModeTimeoutSec, logMode, + minGateDistance, maxGateDistance, custom1, custom2, custom3) /** * @brief operator = * @param src Source object. - * @return LensParams obect. + * @return LrfParams object. */ - LensParams& operator= (const LensParams& src); + LrfParams& operator= (const LrfParams& src); /** - * @brief Encode params. The method doesn't encode initString and fovPoints. + * @brief Encode params. The method doesn't encode initString. * @param data Pointer to data buffer. * @param size Size of data. * @param mask Pointer to params mask. * @return TRUE if params encoded or FALSE if not. */ bool encode(uint8_t* data, int bufferSize, int& size, - LensParamsMask* mask = nullptr); + LrfParamsMask* mask = nullptr); /** - * @brief Decode params. The method doesn't decode initString and fovPoints. + * @brief Decode params. The method doesn't decode initString. * @param data Pointer to data. * @brief dataSize Size of data. * @return TRUE is params decoded or FALSE if not. @@ -375,414 +175,103 @@ class LensParams -/// Lens commands enum. -enum class LensCommand -{ - /// Move zoom tele (in). Command doesn't have arguments. User should be able - /// to set zoom movement speed via lens parameters. - ZOOM_TELE = 1, - /// Move zoom wide (out). Command doesn't have arguments. User should be - /// able to set zoom movement speed via lens parameters. - ZOOM_WIDE, - /// Move zoom to position. Lens controller should have zoom range from - /// 0 (full wide) to 65535 (full tele) regardless of the hardware value of - /// the zoom position. If the minimum and maximum zoom position limits are - /// set by the user in the lens parameters, the range of the hardware zoom - /// position must be scaled to the user space 0-65535 range. - /// Command argument: zoom position 0-65535. User should be able to set zoom - /// movement speed via lens parameters. - ZOOM_TO_POS, - /// Stop zoom moving including stop zoom to position command. - ZOOM_STOP, - /// Move focus far. Command doesn't have arguments. User should be able to - /// set focus movement speed via lens parameters. - FOCUS_FAR, - /// Move focus near. Command doesn't have arguments. User should be able to - /// set focus movement speed via lens parameters. - FOCUS_NEAR, - /// Move focus to position. Lens controller should have focus range from 0 - /// (full near) to 65535 (full far) regardless of the hardware value of the - /// focus position. If the minimum and maximum focus position limits are - /// set by the user in the lens parameters, the range of the hardware focus - /// position must be scaled to the 0-65535 user space range. - /// Command argument: focus position 0-65535. User should be able to set - /// focus movement speed via lens parameters. - FOCUS_TO_POS, - /// Stop focus moving including stop focus to position command. - FOCUS_STOP, - /// Move iris open. Command doesn't have arguments. User should be able to - /// set iris movement speed via lens parameters. - IRIS_OPEN, - /// Move iris close. Command doesn't have arguments. User should be able - /// to set iris movement speed via lens parameters. - IRIS_CLOSE, - /// Move iris to position. Lens controller should have iris range - /// from 0 (full close) to 65535 (full far) regardless of the hardware - /// value of the iris position. If the minimum and maximum iris position - /// limits are set by the user in the lens parameters, the range of the - /// hardware iris position must be scaled to the 0-65535 user space range. - /// Command argument: iris position 0-65535. User should be able to set - /// iris movement speed via lens parameters. - IRIS_TO_POS, - /// Stop iris moving including stop iris to position command. - /// Command doesn't have arguments. - IRIS_STOP, - /// Start autofocus. Command doesn't have arguments. - AF_START, - /// Stop autofocus. Command doesn't have arguments. - AF_STOP, - /// Restart lens controller. - RESTART, - /// Detect zoom and focus hardware ranges. After execution this command the - /// lens controller should automatically set at least parameters - /// (LensParam enum): ZOOM_HW_TELE_LIMIT, ZOOM_HW_WIDE_LIMIT, - /// FOCUS_HW_FAR_LIMIT and FOCUS_HW_NEAR_LIMIT. - DETECT_HW_RANGES -}; - - - -/// Lens params. -enum class LensParam -{ - /// Zoom position. Setting a parameter is equivalent to the command - /// ZOOM_TO_POS. Lens controller should have zoom range from 0 (full wide) - /// to 65535 (full tele) regardless of the hardware value of the zoom - /// position. If the minimum and maximum zoom position limits are set by - /// the user in the lens parameters, the range of the hardware zoom position - /// must be scaled to the user space 0-65535 range. Parameter value: zoom - /// position 0-65535. User should be able to set zoom movement speed via - /// lens parameters. - ZOOM_POS = 1, - /// Hardware zoom position. Parameter value depends on implementation and - /// lens hardware. - ZOOM_HW_POS, - /// Focus position. Setting a parameter is equivalent to the command - /// FOCUS_TO_POS. Lens controller should have focus range from 0 (full near) - /// to 65535 (full far) regardless of the hardware value of the focus - /// position. If the minimum and maximum focus position limits are set by - /// the user in the lens parameters, the range of the hardware focus - /// position must be scaled to the 0-65535 user space range. Parameter - /// value: focus position 0-65535. User should be able to set focus movement - /// speed via lens parameters. - FOCUS_POS, - /// Hardware focus position. Parameter value depends on implementation and - /// lens hardware. - FOCUS_HW_POS, - /// Iris position. Setting a parameter is equivalent to the command - /// IRIS_TO_POS. Lens controller should have iris range from 0 (full close) - /// to 65535 (full far) regardless of the hardware value of the iris - /// position. If the minimum and maximum iris position limits are set by the - /// user in the lens parameters, the range of the hardware iris position - /// must be scaled to the 0-65535 user space range. Parameter value: iris - /// position 0-65535. User should be able to set iris movement speed via - /// lens parameters. - IRIS_POS, - /// Hardware iris position. Parameter value depends on particular lens - /// controller. - IRIS_HW_POS, - /// Focus mode. Parameter value depends on implementation but it is - /// recommended to keep default values: 0 - Manual focus control, - /// 1 - Auto focus control. - FOCUS_MODE, - /// Filter mode. Parameter value depends on implementation but it is - /// recommended to keep default values: 0 - Filter on, 1 - Filter off. - FILTER_MODE, - /// Autofocus ROI top-left corner horizontal position in pixels. - /// Autofocus ROI is rectangle. - AF_ROI_X0, - /// Autofocus ROI top-left corner vertical position in pixels. - /// Autofocus ROI is rectangle. - AF_ROI_Y0, - /// Autofocus ROI bottom-right corner horizontal position in pixels. - /// Autofocus ROI is rectangle. - AF_ROI_X1, - /// Autofocus ROI bottom-right corner vertical position in pixels. - /// Autofocus ROI is rectangle. - AF_ROI_Y1, - /// Zoom speed. Lens controller should have zoom speed range from 0 to - /// 100% of max hardware zoom speed (parameter ZOOM_HW_MAX_SPEED). - /// If the user sets a new parameter value of the ZOOM_HW_SPEED the - /// parameter ZOOM_SPEED must be updated automatically. Formula for - /// calculating speed: - /// ZOOM_SPEED = ( ZOOM_HW_SPEED / ZOOM_HW_MAX_SPEED) * 100. - ZOOM_SPEED, - /// Zoom hardware speed. Value depends on implementation and lens hardware. - /// The value of the parameters must be <= ZOOM_HW_MAX_SPEED parameter. - /// If the user sets a new parameter value of the ZOOM_SPEED parameter - /// the parameter ZOOM_HW_SPEED must be updated automatically. - /// Formula for calculating hardware speed: - /// ZOOM_HW_SPEED = ( ZOOM_SPEED / 100 ) * ZOOM_HW_MAX_SPEED. - ZOOM_HW_SPEED, - /// Maximum zoom hardware speed. Value depends on implementation. - /// If user sets new ZOOM_HW_MAX_SPEED value the parameters - /// ZOOM_SPEED must be updated automatically. If new value of - /// ZOOM_HW_MAX_SPEED parameter will be less than ZOOM_HW_SPEED the - /// parameter ZOOM_HW_SPEED must be reduced automatically. - ZOOM_HW_MAX_SPEED, - /// Focus speed. Lens controller should have focus speed range from 0 to - /// 100% of max hardware focus speed (parameter FOCUS_HW_MAX_SPEED). - /// If the user sets a new parameter value of the FOCUS_HW_SPEED the - /// parameter FOCUS_SPEED must be updated automatically. Formula for - /// calculating speed: FOCUS_SPEED = ( FOCUS_HW_SPEED / FOCUS_HW_MAX_SPEED) - /// * 100. - FOCUS_SPEED, - /// Focus hardware speed. Value depends on on implementation and lens - /// hardware. The value of the parameters must be <= FOCUS_HW_MAX_SPEED - /// parameter. If the user sets a new parameter value of the FOCUS_SPEED - /// parameter the parameter FOCUS_HW_SPEED must be updated automatically. - /// Formula for calculating hardware speed: - /// FOCUS_HW_SPEED = ( FOCUS_SPEED / 100 ) * FOCUS_HW_MAX_SPEED. - FOCUS_HW_SPEED, - /// Maximum focus hardware speed. Value depends on implementation. - /// If user sets new FOCUS_HW_MAX_SPEED value the parameters - /// FOCUS_SPEED and FOCUS_HW_SPEED must be updated by lens controller - /// automatically. If new value of FOCUS_HW_MAX_SPEED parameter will be - /// less than FOCUS_HW_SPEED the parameter FOCUS_HW_SPEED must be reduced - /// automatically. - FOCUS_HW_MAX_SPEED, - /// Iris speed. Lens controller should have iris speed range from 0 to 100% - /// of max hardware iris speed (parameter IRIS_HW_MAX_SPEED). If the user - /// sets a new parameter value of the IRIS_HW_SPEED the parameter IRIS_SPEED - /// must be updated automatically. Formula for calculating speed: - /// IRIS_SPEED = ( IRIS_HW_SPEED / IRIS_HW_MAX_SPEED) * 100. - IRIS_SPEED, - /// Iris hardware speed. Value depends on implementation and les hardware. - /// The value of the parameters must be <= IRIS_HW_MAX_SPEED parameter. - /// If the user sets a new parameter value of the IRIS_SPEED parameter - /// the parameter IRIS_HW_SPEED must be updated automatically. Formula - /// for calculating hardware speed: - /// IRIS_HW_SPEED = ( IRIS_SPEED / 100 ) * IRIS_HW_MAX_SPEED. - IRIS_HW_SPEED, - /// Maximum iris hardware speed. Value depends on implementation. If user - /// sets new IRIS_HW_MAX_SPEED value the parameters IRIS_SPEED and - /// IRIS_HW_SPEED must be updated automatically. If new value of - /// IRIS_HW_MAX_SPEED parameter will be less than IRIS_HW_SPEED the - /// parameter IRIS_HW_SPEED must be reduced automatically. - IRIS_HW_MAX_SPEED, - /// Zoom hardware tele limit. Value depends on implementation and lens - /// hardware. Lens controller should control zoom position. Lens controller - /// should stop zoom moving if hardware zoom position will be our of limits. - ZOOM_HW_TELE_LIMIT, - /// Zoom hardware wide limit. Value depends on implementation and lens - /// hardware. Lens controller should control zoom position. Lens controller - /// should stop zoom moving if hardware zoom position will be our of limits. - ZOOM_HW_WIDE_LIMIT, - /// Focus hardware far limit. Value depends on on implementation and lens - /// hardware. Lens controller should control focus position. Lens controller - /// should stop focus moving if hardware focus position will be our of - /// limits. - FOCUS_HW_FAR_LIMIT, - /// Focus hardware near limit. Value depends on implementation and lens - /// hardware. Lens controller should control focus position. Lens controller - /// should stop focus moving if hardware focus position will be our of - /// limits. - FOCUS_HW_NEAR_LIMIT, - /// Iris hardware open limit. Value depends on implementation and lens - /// hardware. Lens controller should control iris position. Lens controller - /// should stop iris moving if hardware iris position will be our of limits. - IRIS_HW_OPEN_LIMIT, - /// Iris hardware close limit. Value depends on implementation and lens - /// hardware. Lens controller should control iris position. Lens controller - /// should stop iris moving if hardware iris position will be our of limits. - IRIS_HW_CLOSE_LIMIT, - /// Focus factor if it was calculated. If not calculated must be -1. - /// Value depends on particular lens controller. - FOCUS_FACTOR, - /// Lens connection status. Connection status shows if the lens controller - /// has data exchange with lens equipment. For example, if lens has serial - /// port lens controller connects to serial port - /// (opens serial port file in OS) but lens can be not active (no power). - /// In this case connection status shows that lens controller doesn't have - /// data exchange with lens equipment (methos will return 0). It lens - /// controller has data exchange with lens equipment the method will - /// return 1. If lens controller not initialize the connection status always - /// FALSE. Value: 0 - not connected. 1 - connected. - IS_CONNECTED, - /// Focus hardware speed in autofocus mode. Value depends on implementation - /// and lens hardware. - FOCUS_HW_AF_SPEED, - /// Threshold for changes of focus factor to start refocus. Value: - /// 0% - no check, 100% - changing x2. - FOCUS_FACTOR_THRESHOLD, - /// Timeout for automatic refocus in seconds. Value: - /// 0 - no automatic refocus, 100000 - maximum value. - REFOCUS_TIMEOUT_SEC, - /// Flag about active autofocus algorithm. Value: 0 - autofocus not working, - /// 1 - working. - AF_IS_ACTIVE, - /// Iris mode. Value depends on implementation but it is recommended to keep - /// default values: 0 - manual iris control, 1 - auto iris control. - IRIS_MODE, - /// ROI width (pixels) for autofocus algorithm when lens controller detects - /// ROI position automatically. Value: from 8 to (video frame width - - /// AUTO_AF_ROI_BORDER * 2). - AUTO_AF_ROI_WIDTH, - /// ROI height (pixels) for autofocus algorithm when lens controller - /// detects ROI position automatically. Value: from 8 - /// (video frame width - AUTO_AF_ROI_BORDER * 2). - AUTO_AF_ROI_HEIGHT, - /// Video frame border size (along vertical and horizontal axes). - /// Value: border size from 0 to video frame - /// min(video frame width/height) / 2. - AUTO_AF_ROI_BORDER, - /// AF ROI mode (write/read). Value: 0 - Manual position, 1 - Auto position. - AF_ROI_MODE, - /// Lens extender mode. Value depends on implementation but it is - /// recommended to keep default values: 0 - no extender, 1 - x2 extender. - EXTENDER_MODE, - /// Lens stabilization mode. Value depends on implementation but it is - /// recommended to keep default values: 0 - no stabilization, - /// 1 - stabilization. - STABILIZER_MODE, - /// Autofocus range. Value depends on implementation. - AF_RANGE, - /// Current horizontal Field of view, degree. Field of view calculated by - /// lens controller according to initial params or by reading directly from - /// lens hardware. - X_FOV_DEG, - /// Current vertical Field of view, degree. Field of view calculated by lens - /// controller according to initial params or by reading directly from lens - /// hardware. - Y_FOV_DEG, - /// Logging mode. Values: 0 - Disable, 1 - Only file, 2 - Only terminal, - /// 3 - File and terminal. - LOG_MODE, - /// Lens temperature, degree. - TEMPERATURE, - /// Lens controller initialization status. Open status shows if the lens - /// controller initialized or not but doesn't show if lens controller has - /// communication with lens equipment. For example, if lens has serial port - /// lens controller connects to serial port (opens serial port file in OS) - /// but lens can be not active (no power). In this case open status just - /// shows that lens controller has opened serial port. Values: 0 - not open - /// not initialized), 1 - open (initialized). - IS_OPEN, - /// Lens type. Value depends on implementation. Type allows to lens - /// initialize necessary parameters for particular lens hardware. - TYPE, - /// Lens custom parameter. Value depends on particular lens controller. - /// Custom parameters used when particular lens equipment has specific - /// unusual parameter. - CUSTOM_1, - /// Lens custom parameter. Value depends on particular lens controller. - /// Custom parameters used when particular lens equipment has specific - /// unusual parameter. - CUSTOM_2, - /// Lens custom parameter. Value depends on particular lens controller. - /// Custom parameters used when particular lens equipment has specific - /// unusual parameter. - CUSTOM_3 -}; - - - /** - * @brief Lens controller interface class. + * @brief Laser range finder controller interface class. */ -class Lens +class Lrf { public: /** * @brief Class destructor. */ - virtual ~Lens(); + virtual ~Lrf(); /** - * @brief Get lens class version. - * @return Lens class version string in format "Major.Minor.Patch". + * @brief Get class version. + * @return Class version string in format "Major.Minor.Patch". */ static std::string getVersion(); /** - * @brief Open lens controller. Can be used instead initLens(...) method. - * @param initString Init string. Format depends on lens controller. - * @return TRUE if the lens controller is init or FALSE. + * @brief Open lrf controller. Can be used instead initLrf(...) method. + * @param initString Init string. Format depends on lrf controller. + * @return TRUE if the lrf controller is init or FALSE. */ - virtual bool openLens(std::string initString) = 0; + virtual bool openLrf(std::string initString) = 0; /** - * @brief Init lens controller by structure. Can be used instead - * openLens(...) method. - * @param initString Init string. Format depends on lens controller. - * @return TRUE if the lens controller is init or FALSE. + * @brief Init lrf controller by structure. Can be used instead + * openLrf(...) method. + * @param params Lrf params class. + * @return TRUE if the lrf controller is init or FALSE. */ - virtual bool initLens(LensParams& params) = 0; + virtual bool initLrf(LrfParams& params) = 0; /** * @brief Close connection. */ - virtual void closeLens() = 0; + virtual void closeLrf() = 0; /** - * @brief Get lens open status. - * @return TRUE if the lens is open or FALSE. + * @brief Get lrf open status. + * @return TRUE if the lrf is open or FALSE. */ - virtual bool isLensOpen() = 0; + virtual bool isLrfOpen() = 0; /** - * @brief Get lens connection status. Lens can be open but no response from - * lens hardware. - * @return TRUE if the lens is open or FALSE. + * @brief Get lrf connection status. Lrf can be open but no response from + * lrf hardware. + * @return TRUE if the lrf is open or FALSE. */ - virtual bool isLensConnected() = 0; + virtual bool isLrfConnected() = 0; /** - * @brief Set the lens controller param. + * @brief Set the lrf controller param. * @param id Param ID. * @param value Param value. * @return TRUE if the property set or FALSE. */ - virtual bool setParam(LensParam id, float value) = 0; + virtual bool setParam(LrfParam id, float value) = 0; /** - * @brief Get the lens controller param. + * @brief Get the lrf controller param. * @param id Param ID. * @return float Param value or -1 of the param not exists. */ - virtual float getParam(LensParam id) = 0; + virtual float getParam(LrfParam id) = 0; /** - * @brief Get the lens controller params. - * @param params Reference to LensParams object. + * @brief Get the lrf controller params. + * @param params Reference to LrfParams object. */ - virtual void getParams(LensParams& params) = 0; + virtual void getParams(LrfParams& params) = 0; /** - * @brief Execute command. + * @brief Execute lrf command. * @param id Command ID. * @param arg Command argument. * @return TRUE if the command executed or FALSE. */ - virtual bool executeCommand(LensCommand id, float arg = 0) = 0; - - /** - * @brief Add video frame for auto focus purposes. Some lens controllers - * may not support this functions. - * @param frame Video frame object. - */ - virtual void addVideoFrame(cr::video::Frame& frame) = 0; + virtual bool executeCommand(LrfCommand id, float arg = 0) = 0; /** * @brief Encode set param command. * @param data Pointer to data buffer. Must have size >= 11. * @param size Size of encoded data. - * @param id Lens parameter id. - * @param value Lens parameter value. + * @param id Lrf parameter id. + * @param value Lrf parameter value. */ static void encodeSetParamCommand( - uint8_t* data, int& size, LensParam id, float value); + uint8_t* data, int& size, LrfParam id, float value); /** * @brief Encode command. * @param data Pointer to data buffer. Must have size >= 11. * @param size Size of encoded data. - * @param id Lens command ID. - * @param arg Lens command argument. + * @param id Lrf command ID. */ - static void encodeCommand( - uint8_t* data, int& size, LensCommand id, float arg = 0.0f); + static void encodeCommand(uint8_t* data, int& size, LrfCommand id); /** * @brief Decode command. @@ -790,14 +279,11 @@ class Lens * @param size Size of data. * @param paramId Output command ID. * @param commandId Output command ID. - * @param value Param or command value. * @return 0 - command decoded, 1 - set param command decoded, -1 - error. */ - static int decodeCommand(uint8_t* data, - int size, - LensParam& paramId, - LensCommand& commandId, - float& value); + static int decodeCommand( + uint8_t* data, int size, LrfParam& paramId, + LrfCommand& commandId, float& value); /** * @brief Decode and execute command. diff --git a/src/LrfVersion.h b/src/LrfVersion.h new file mode 100644 index 0000000..09045e3 --- /dev/null +++ b/src/LrfVersion.h @@ -0,0 +1,7 @@ +#pragma once + +#define LRF_MAJOR_VERSION 1 +#define LRF_MINOR_VERSION 0 +#define LRF_PATCH_VERSION 0 + +#define LRF_VERSION "1.0.0"