Go to the documentation of this file.
51 #include <glog/logging.h>
68 std::shared_ptr<aditof::DepthSensorInterface> depthSensor,
71 : m_depthSensor(depthSensor), m_devStarted(
false), m_devStreaming(
false),
72 m_adsd3500Enabled(
false), m_loadedConfigData(
false), m_xyzEnabled(
true),
73 m_xyzSetViaApi(
false), m_cameraFps(0), m_fsyncMode(-1),
74 m_mipiOutputSpeed(-1), m_enableTempCompenstation(-1),
75 m_enableMetaDatainAB(-1), m_enableEdgeConfidence(-1), m_modesVersion(0),
76 m_xyzTable({
nullptr,
nullptr,
nullptr}),
78 m_dropFrameOnce(
true), m_isOffline(
false) {
81 memset(&m_xyzTable, 0,
sizeof(m_xyzTable));
83 m_details.uBootVersion = ubootVersion;
84 m_details.kernelVersion = kernelVersion;
85 m_details.sdCardImageVersion = sdCardImageVersion;
86 m_netLinkTest = netLinkTest;
94 LOG(
WARNING) <<
"Invalid instance of a depth sensor";
99 m_depthSensor->getDetails(sDetails);
100 m_details.cameraId = sDetails.
id;
104 m_depthSensor->getName(sensorName);
105 LOG(
INFO) <<
"Sensor name = " << sensorName;
106 if (sensorName ==
"adsd3500") {
107 m_adsd3500Enabled =
true;
108 }
else if (sensorName ==
"offline") {
112 m_adsd3500_master =
true;
125 LOG(
INFO) <<
"Initializing camera";
128 LOG(
ERROR) <<
"This usecase is no longer supported.";
151 status =
m_depthSensor->getControl(
"imagerType", controlValue);
153 if (controlValue ==
ControlValue.at(ImagerType::ADSD3100)) {
155 }
else if (controlValue ==
ControlValue.at(ImagerType::ADSD3030)) {
157 }
else if (controlValue ==
ControlValue.at(ImagerType::ADTF3080)) {
161 LOG(
ERROR) <<
"Unkown imager type: " << controlValue;
167 LOG(
ERROR) <<
"Failed to get available frame types name!";
173 status =
m_depthSensor->getModeDetails(availablemodes, modeDetails);
175 LOG(
ERROR) <<
"Failed to get available frame types details!";
180 uint8_t intrinsics[56] = {0};
181 uint8_t dealiasParams[32] = {0};
187 intrinsics[0] =
mode;
188 dealiasParams[0] =
mode;
191 m_depthSensor->adsd3500_read_payload_cmd(0x01, intrinsics, 56);
193 LOG(
ERROR) <<
"Failed to read intrinsics for adsd3500!";
199 0x02, dealiasParams, 32);
201 LOG(
ERROR) <<
"Failed to read dealias parameters for adsd3500!";
205 memcpy(&dealiasStruct, dealiasParams,
222 LOG(
INFO) <<
"Current adsd3500 firmware version is: "
224 LOG(
INFO) <<
"Current adsd3500 firmware git hash is: "
235 LOG(
ERROR) <<
"loadConfigData failed";
236 return Status::GENERIC_ERROR;
241 LOG(
ERROR) <<
"Failed to load process parameters!";
248 LOG(
ERROR) <<
"Failed to set fsyncMode.";
252 LOG(
WARNING) <<
"fsyncMode is not being set by SDK.";
258 LOG(
ERROR) <<
"Failed to set mipiOutputSpeed.";
262 LOG(
WARNING) <<
"mipiSpeed is not being set by SDK.";
269 LOG(
ERROR) <<
"Failed to set enableTempCompenstation.";
273 LOG(
WARNING) <<
"enableTempCompenstation is not being set by SDK.";
279 LOG(
ERROR) <<
"Failed to set enableEdgeConfidence.";
283 LOG(
WARNING) <<
"enableEdgeConfidence is not being set by SDK.";
289 LOG(
INFO) <<
"Module serial number: " << serialNumber;
291 LOG(
INFO) <<
"Serial read is not supported in this firmware!";
293 LOG(
ERROR) <<
"Failed to read serial number!";
297 LOG(
INFO) <<
"Camera initialized";
307 LOG(
ERROR) <<
"Error starting adsd3500.";
320 LOG(
INFO) <<
"Failed to stop camera!";
335 return (d.modeNumber == mode);
339 LOG(
WARNING) <<
"Mode: " << (int)
mode <<
" not supported by camera";
346 LOG(
WARNING) <<
"Failed to reset the camera!";
361 LOG(
ERROR) <<
"Failed to get frame type details!";
367 uint16_t chipCmd = 0xDA00;
369 status =
m_depthSensor->adsd3500_write_cmd(chipCmd, 0x280F, 200000);
371 LOG(
ERROR) <<
"Failed to switch mode in chip using host commands!";
379 LOG(
INFO) <<
"Using the following configuration parameters for mode "
389 LOG(
ERROR) <<
"Failed to set enableMetaDatainAB.";
392 LOG(
INFO) <<
"Metadata in AB is enabled and it is stored in the "
398 LOG(
ERROR) <<
"Failed to disable enableMetaDatainAB.";
401 LOG(
INFO) <<
"Metadata in AB is disabled for this frame type.";
407 LOG(
ERROR) <<
"Failed to set enableMetaDatainAB.";
411 LOG(
WARNING) <<
"Metadata in AB is disabled.";
420 for (
const auto &
item : (*modeIt).frameContent) {
437 }
else if (
item ==
"raw") {
442 }
else if (
item ==
"metadata") {
444 fDataDetails.
width = 128;
446 }
else if (
item ==
"conf") {
459 unsigned char *pData =
nullptr;
466 std::string s(
reinterpret_cast<const char *
>(pData), dataSize);
473 LOG(
ERROR) <<
"Failed to initialize depth compute on target!";
479 localStatus =
m_depthSensor->getControl(
"depthComputeOpenSource",
482 if (depthComputeStatus ==
"0") {
483 LOG(
INFO) <<
"Using closed source depth compute library.";
485 LOG(
INFO) <<
"Using open source depth compute library.";
489 <<
"Failed to get depth compute version from target!";
511 LOG(
ERROR) <<
"Failed to generate the XYZ tables";
512 return Status::GENERIC_ERROR;
520 LOG(
WARNING) <<
"Could not enable 'Dynamic Mode Switching.";
529 <<
"Could not set a sequence for the 'Dynamic Mode Switching'.";
542 LOG(
ERROR) <<
"get ini parameters failed.";
551 LOG(
WARNING) <<
"Setting camera parameters while streaming is one is "
555 LOG(
ERROR) <<
"Failed to set ini parameters on ADSD3500";
559 LOG(
ERROR) <<
"set ini parameters failed in depth-compute.";
572 availableModes.clear();
575 availableModes.emplace_back(
mode);
585 if (frame ==
nullptr) {
596 uint16_t *frameDataLocation =
nullptr;
598 frame->
getData(
"frameData", &frameDataLocation);
600 frame->
getData(
"ab", &frameDataLocation);
603 if (!frameDataLocation) {
604 LOG(
WARNING) <<
"getframe failed to allocated valid frame";
612 LOG(
INFO) <<
"Failed to drop first frame!";
615 LOG(
INFO) <<
"Dropped first frame";
620 LOG(
WARNING) <<
"Failed to get frame from device";
626 uint16_t *depthFrame;
629 frame->
getData(
"depth", &depthFrame);
630 frame->
getData(
"xyz", &xyzFrame);
641 LOG(
ERROR) <<
"Could not get frame metadata!";
645 uint16_t *metadataLocation;
646 status = frame->
getData(
"metadata", &metadataLocation);
648 LOG(
ERROR) <<
"Failed to get metadata location";
654 frame->
getData(
"ab", &abFrame);
655 memcpy(
reinterpret_cast<uint8_t *
>(&
metadata), abFrame,
657 memset(abFrame, 0,
sizeof(
metadata));
675 memcpy(
reinterpret_cast<uint8_t *
>(metadataLocation),
682 uint16_t abHeight,
bool advanceScaling,
683 bool useLogScaling) {
687 uint32_t min_value_of_AB_pixel = 0xFFFF;
688 uint32_t max_value_of_AB_pixel = 1;
690 if (advanceScaling) {
692 for (
size_t dummyCtr = 0; dummyCtr <
imageSize; ++dummyCtr) {
693 if (abBuffer[dummyCtr] > max_value_of_AB_pixel) {
694 max_value_of_AB_pixel = abBuffer[dummyCtr];
696 if (abBuffer[dummyCtr] < min_value_of_AB_pixel) {
697 min_value_of_AB_pixel = abBuffer[dummyCtr];
700 max_value_of_AB_pixel -= min_value_of_AB_pixel;
705 uint32_t m_maxABPixelValue = (1 << 13) - 1;
706 max_value_of_AB_pixel = m_maxABPixelValue;
707 min_value_of_AB_pixel = 0;
710 uint32_t new_max_value_of_AB_pixel = 1;
711 uint32_t new_min_value_of_AB_pixel = 0xFFFF;
713 #pragma omp parallel for
714 for (
size_t dummyCtr = 0; dummyCtr <
imageSize; ++dummyCtr) {
716 abBuffer[dummyCtr] -= min_value_of_AB_pixel;
717 double pix = abBuffer[dummyCtr] * (255.0 / max_value_of_AB_pixel);
725 abBuffer[dummyCtr] =
static_cast<uint8_t
>(pix);
727 if (abBuffer[dummyCtr] > new_max_value_of_AB_pixel) {
728 new_max_value_of_AB_pixel = abBuffer[dummyCtr];
730 if (abBuffer[dummyCtr] < new_min_value_of_AB_pixel) {
731 new_min_value_of_AB_pixel = abBuffer[dummyCtr];
737 max_value_of_AB_pixel = new_max_value_of_AB_pixel;
738 min_value_of_AB_pixel = new_min_value_of_AB_pixel;
741 log10(1.0 +
static_cast<double>(max_value_of_AB_pixel -
742 min_value_of_AB_pixel));
744 #pragma omp parallel for
745 for (
size_t dummyCtr = 0; dummyCtr <
imageSize; ++dummyCtr) {
748 static_cast<double>(abBuffer[dummyCtr] - min_value_of_AB_pixel);
749 double logPix = log10(1.0 + pix);
750 pix = (logPix / maxLogVal) * 255.0;
758 abBuffer[dummyCtr] = (uint8_t)(pix);
765 bool useLogScaling) {
769 uint16_t *abVideoData;
771 status = frame->
getData(
"ab", &abVideoData);
774 LOG(
ERROR) <<
"Could not get frame data!";
779 LOG(
ERROR) <<
"no memory allocated in frame";
784 frameAbDetails.
height = 0;
785 frameAbDetails.
width = 0;
789 advanceScaling, useLogScaling);
815 controls.emplace_back(
item.first);
827 if (
value ==
"call") {
868 unsigned char *
p =
NULL;
869 p = (
unsigned char *)malloc(iniArray.size());
870 memcpy(
p, iniArray.c_str(), iniArray.size());
872 FileData fval = {(
unsigned char *)
p, iniArray.size()};
894 free((
void *)(
it->second.p_data));
906 bool useCacheValue) {
911 LOG(
WARNING) <<
"Serial read is not supported in this firmware!";
921 <<
"No serial number stored in cache. Reading from memory.";
925 uint8_t serial[32] = {0};
927 status =
m_depthSensor->adsd3500_read_payload_cmd(0x19, serial, 32);
929 LOG(
ERROR) <<
"Failed to read serial number!";
943 if (filepath.empty()) {
944 LOG(
ERROR) <<
"File path where CCB should be written is empty.";
951 LOG(
INFO) <<
"readAdsd3500CCB read attempt nr :" <<
i;
956 LOG(
ERROR) <<
"Failed to read CCB from adsd3500 module after "
962 destination << ccbContent;
968 if (filepath.empty()) {
969 LOG(
ERROR) <<
"File path where CFG should be written is empty.";
973 LOG(
ERROR) <<
"CFG files is unavailable";
988 #pragma pack(push, 1)
990 uint8_t cmd_header_byte[16];
1013 status =
m_depthSensor->adsd3500_register_interrupt_callback(cb);
1014 bool interruptsAvailable = (status ==
Status::OK);
1020 LOG(
ERROR) <<
"Failed to read adsd3500 chip id!";
1029 LOG(
ERROR) <<
"Failed to switch to burst mode!";
1034 const int flashPageSize = 256;
1039 std::vector<uint8_t>
buffer(std::istreambuf_iterator<char>(fw_file), {});
1041 uint32_t fw_len =
buffer.size();
1042 uint8_t *fw_content =
buffer.data();
1044 fw_upgrade_header.
id8 = 0xAD;
1046 fw_upgrade_header.
cmd8 = 0x04;
1050 for (
int i = 1;
i < 8;
i++) {
1055 uint32_t res =
crcFast(fw_content, fw_len,
true) ^ 0xFFFFFFFF;
1061 LOG(
ERROR) <<
"Failed to send fw upgrade header";
1066 if ((fw_len % flashPageSize) != 0) {
1067 packetsToSend = (fw_len / flashPageSize + 1);
1069 packetsToSend = (fw_len / flashPageSize);
1072 uint8_t data_out[flashPageSize];
1074 for (
int i = 0;
i < packetsToSend;
i++) {
1075 int start = flashPageSize *
i;
1076 int end = flashPageSize * (
i + 1);
1078 for (
int j =
start; j <
end; j++) {
1079 if (j <
static_cast<int>(fw_len)) {
1080 data_out[j -
start] = fw_content[j];
1083 data_out[j -
start] = 0x00;
1086 status =
m_depthSensor->adsd3500_write_payload(data_out, flashPageSize);
1088 LOG(
ERROR) <<
"Failed to send packet number " <<
i <<
" out of "
1089 << packetsToSend <<
" packets!";
1094 LOG(
INFO) <<
"Succesfully sent " <<
i <<
" out of " << packetsToSend
1100 uint8_t switchBuf[] = {0xAD, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
1101 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1103 switchBuf,
sizeof(switchBuf) /
sizeof(switchBuf[0]));
1105 LOG(
ERROR) <<
"Failed to switch adsd3500 to standard mode!";
1109 if (interruptsAvailable) {
1110 LOG(
INFO) <<
"Waiting for ADSD3500 to update itself";
1111 int secondsTimeout = 60;
1112 int secondsWaited = 0;
1113 int secondsWaitingStep = 1;
1114 while (!
m_fwUpdated && secondsWaited < secondsTimeout) {
1116 std::this_thread::sleep_for(
1117 std::chrono::seconds(secondsWaitingStep));
1118 secondsWaited += secondsWaitingStep;
1120 LOG(
INFO) <<
"Waited: " << secondsWaited <<
" seconds";
1122 if (!
m_fwUpdated && secondsWaited >= secondsTimeout) {
1123 LOG(
WARNING) <<
"Adsd3500 firmware updated has timeout after: "
1124 << secondsWaited <<
"seconds";
1130 LOG(
INFO) <<
"Adsd3500 firmware updated succesfully!";
1132 LOG(
ERROR) <<
"Adsd3500 firmware updated but with error: "
1136 LOG(
INFO) <<
"Adsd3500 firmware updated succesfully! Waiting 60 "
1137 "seconds since interrupts support was not detected.";
1138 std::this_thread::sleep_for(std::chrono::seconds(60));
1148 uint8_t ccbHeader[16] = {0};
1153 status =
m_depthSensor->adsd3500_read_payload_cmd(0x13, ccbHeader, 16);
1155 LOG(
ERROR) <<
"Failed to get ccb command header";
1160 uint32_t ccbFileSize;
1162 uint16_t numOfChunks;
1164 memcpy(&chunkSize, ccbHeader + 1, 2);
1165 memcpy(&ccbFileSize, ccbHeader + 4, 4);
1166 memcpy(&crcOfCCB, ccbHeader + 12, 4);
1168 numOfChunks = ccbFileSize / chunkSize;
1169 uint8_t *ccbContent =
new uint8_t[ccbFileSize];
1171 for (
int i = 0;
i < numOfChunks;
i++) {
1173 ccbContent +
i * chunkSize, chunkSize);
1175 LOG(
ERROR) <<
"Failed to read chunk number " <<
i <<
" out of "
1176 << numOfChunks + 1 <<
" chunks for adsd3500!";
1181 LOG(
INFO) <<
"Succesfully read chunk number " <<
i <<
" out of "
1182 << numOfChunks + 1 <<
" chunks for adsd3500!";
1187 if (ccbFileSize % chunkSize != 0) {
1189 ccbContent + numOfChunks * chunkSize, ccbFileSize % chunkSize);
1191 LOG(
ERROR) <<
"Failed to read chunk number " << numOfChunks + 1
1192 <<
" out of " << numOfChunks + 1
1193 <<
" chunks for adsd3500!";
1199 uint8_t switchBuf[] = {0xAD, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
1200 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1202 switchBuf,
sizeof(switchBuf) /
sizeof(switchBuf[0]));
1204 LOG(
ERROR) <<
"Failed to switch adsd3500 to standard mode!";
1208 LOG(
INFO) <<
"Succesfully read ccb from adsd3500. Checking crc...";
1210 uint32_t computedCrc =
1211 crcFast(ccbContent, ccbFileSize - 4,
true) ^ 0xFFFFFFFF;
1213 if (crcOfCCB != ~computedCrc) {
1214 LOG(
ERROR) <<
"Invalid crc for ccb read from memory!";
1215 return Status::GENERIC_ERROR;
1217 LOG(
INFO) <<
"Crc of ccb is valid.";
1220 std::ofstream tempFile;
1224 ccb =
std::string((
char *)ccbContent, ccbFileSize - 4);
1226 delete[] ccbContent;
1240 else if (
value ==
"14")
1242 else if (
value ==
"12")
1244 else if (
value ==
"10")
1246 else if (
value ==
"8")
1252 LOG(
WARNING) <<
"bitsInPhaseOrDepth was not found in parameter list";
1261 else if (
value ==
"4")
1267 LOG(
WARNING) <<
"bitsInConf was not found in parameter list";
1277 else if (
value ==
"14")
1279 else if (
value ==
"12")
1281 else if (
value ==
"10")
1283 else if (
value ==
"8")
1291 LOG(
WARNING) <<
"bitsInAB was not found in parameter list";
1300 LOG(
WARNING) <<
"partialDepthEnable was not found in parameter list";
1308 LOG(
WARNING) <<
"inputFormat was not found in parameter list";
1317 LOG(
WARNING) <<
"xyzEnable was not found in parameter list";
1325 if (std::stoi(
value) == 128) {
1331 LOG(
WARNING) <<
"headerSize was not found in parameter list";
1337 const cJSON *json_value =
1339 if (cJSON_IsString(json_value) && (json_value->
valuestring !=
NULL)) {
1356 std::map<std::string, std::string> paramsMap;
1357 UtilsIni::getKeyValuePairsFromString(iniArray, paramsMap);
1371 cJSON *rootjson = cJSON_CreateObject();
1382 std::list<std::string> depth_compute_keys_list = {
1383 "abThreshMin",
"radialThreshMax",
1384 "radialThreshMin",
"depthComputeIspEnable",
1385 "partialDepthEnable",
"interleavingEnable",
1386 "bitsInPhaseOrDepth",
"bitsInAB",
1387 "bitsInConf",
"confThresh",
1388 "phaseInvalid",
"inputFormat",
1389 "jblfABThreshold",
"jblfApplyFlag",
1390 "jblfExponentialTerm",
"jblfGaussianSigma",
1391 "jblfMaxEdge",
"jblfWindowSize"};
1396 std::map<std::string, std::string> iniKeyValPairs = pfile->second;
1399 cJSON *json = cJSON_CreateObject();
1400 cJSON *dept_compute_group_keys = cJSON_CreateObject();
1401 cJSON *configuration_param_keys = cJSON_CreateObject();
1403 for (
auto item = iniKeyValPairs.begin();
1404 item != iniKeyValPairs.end();
item++) {
1405 double valued = strtod(
item->second.c_str(),
NULL);
1407 auto it = std::find_if(
1411 if (depth_compute_keys_list.end() !=
it) {
1414 item->first.c_str(), valued);
1417 item->first.c_str(),
1418 item->second.c_str());
1423 item->first.c_str(), valued);
1426 item->first.c_str(),
1427 item->second.c_str());
1432 dept_compute_group_keys);
1434 configuration_param_keys);
1436 std::to_string(pfile->first).c_str(), json);
1440 char *json_str = cJSON_Print(rootjson);
1442 FILE *fp = fopen(savePathFile.c_str(),
"w");
1444 LOG(
WARNING) <<
" Unable to open the file. " << savePathFile.c_str();
1445 return Status::GENERIC_ERROR;
1447 fputs(json_str, fp);
1450 cJSON_free(json_str);
1451 cJSON_Delete(rootjson);
1458 const int16_t mode_in_use) {
1465 std::ifstream ifs(pathFile.c_str());
1466 std::string content((std::istreambuf_iterator<char>(ifs)),
1467 (std::istreambuf_iterator<char>()));
1469 cJSON *config_json = cJSON_Parse(content.c_str());
1470 if (config_json !=
NULL) {
1474 double errata1val = 1;
1475 if (cJSON_IsNumber(errata1)) {
1478 if (errata1val == 1) {
1486 if (cJSON_IsNumber(fsyncMode)) {
1490 cJSON *mipiOutputSpeed =
1492 if (cJSON_IsNumber(mipiOutputSpeed)) {
1497 config_json,
"enableTempCompensation");
1498 if (cJSON_IsNumber(enableTempCompensation)) {
1503 config_json,
"enableEdgeConfidence");
1504 if (cJSON_IsNumber(enableEdgeConfidence)) {
1509 config_json,
"dynamicModeSwitching");
1510 if (cJSON_IsArray(dmsSequence)) {
1521 if (cJSON_IsNumber(dmsMode) && cJSON_IsNumber(dmsRepeat)) {
1530 if (mode_in_use >= 0 &&
mode != mode_in_use) {
1536 cJSON *depthframeType =
1540 depthframeType,
"depth-compute");
1542 std::map<std::string, std::string> iniKeyValPairs;
1544 if (dept_compute_group_keys) {
1554 std::ostringstream
stream;
1555 stream << std::fixed << std::setprecision(1)
1559 if (
found != std::string::npos) {
1568 depthframeType,
"configuration-parameters");
1570 if (configuration_param_keys) {
1579 std::ostringstream
stream;
1580 stream << std::fixed << std::setprecision(1)
1584 if (
found != std::string::npos) {
1598 bool result =
false;
1625 LOG(
ERROR) <<
"Unable to set FSYNC Toggle mode!";
1641 LOG(
ERROR) <<
"ADSD3500 not set as master - cannot toggle FSYNC";
1646 LOG(
ERROR) <<
"Unable to Toggle FSYNC!";
1658 uint8_t fwData[44] = {0};
1659 fwData[0] = uint8_t(1);
1661 status =
m_depthSensor->adsd3500_read_payload_cmd(0x05, fwData, 44);
1663 LOG(
INFO) <<
"Failed to retrieve fw version and git hash for "
1670 fwv = std::to_string(fwData[0]) +
'.' + std::to_string(fwData[1]) +
'.' +
1671 std::to_string(fwData[2]) +
'.' + std::to_string(fwData[3]);
1674 std::make_pair(fwv,
std::string((
char *)(fwData + 4), 40));
1677 for (
int i = 0;
i < 4;
i++) {
1688 return m_depthSensor->adsd3500_write_cmd(0x0010, threshold);
1694 0x0015,
reinterpret_cast<uint16_t *
>(&threshold));
1698 return m_depthSensor->adsd3500_write_cmd(0x0011, threshold);
1703 0x0016,
reinterpret_cast<uint16_t *
>(&threshold));
1707 return m_depthSensor->adsd3500_write_cmd(0x0013, enable ? 1 : 0);
1712 0x0017,
reinterpret_cast<uint16_t *
>(&intEnabled));
1723 0x0018,
reinterpret_cast<uint16_t *
>(&
size));
1727 return m_depthSensor->adsd3500_write_cmd(0x0027, threshold);
1732 0x0028,
reinterpret_cast<uint16_t *
>(&threshold));
1736 return m_depthSensor->adsd3500_write_cmd(0x0029, threshold);
1742 0x0030,
reinterpret_cast<uint16_t *
>(&threshold));
1751 0x0034,
reinterpret_cast<uint16_t *
>(&speed));
1756 0x0038,
reinterpret_cast<uint16_t *
>(&errcode));
1765 0x0068,
reinterpret_cast<uint16_t *
>(&delay));
1769 return m_depthSensor->adsd3500_write_cmd(0x0074, threshold);
1773 return m_depthSensor->adsd3500_write_cmd(0x0075, threshold);
1783 0x0069,
reinterpret_cast<uint16_t *
>(&
value));
1792 0x006A,
reinterpret_cast<uint16_t *
>(&
value));
1797 reinterpret_cast<uint16_t *
>(&fps));
1803 LOG(
WARNING) <<
"Using a default frame rate of " << fps;
1809 LOG(
ERROR) <<
"Failed to set fps at: " << fps <<
"!";
1824 0x0076,
reinterpret_cast<uint16_t *
>(&
value));
1842 0x0037,
reinterpret_cast<uint16_t *
>(&
value));
1853 reg,
reinterpret_cast<uint16_t *
>(&
value));
1857 return m_depthSensor->setControl(
"disableCCBM", std::to_string(disable));
1864 status =
m_depthSensor->getControl(
"availableCCBM", availableCCMB);
1866 if (availableCCMB ==
"1") {
1868 }
else if (availableCCMB ==
"0") {
1871 LOG(
ERROR) <<
"Invalid value for control availableCCBM: "
1881 int &imagerStatus) {
1884 status =
m_depthSensor->adsd3500_get_status(chipStatus, imagerStatus);
1886 LOG(
ERROR) <<
"Failed to read chip/imager status!";
1890 if (chipStatus != 0) {
1891 LOG(
ERROR) <<
"ADSD3500 error detected: "
1896 LOG(
ERROR) <<
"ADSD3100 imager error detected: "
1899 LOG(
ERROR) <<
"ADSD3030 imager error detected: "
1902 LOG(
ERROR) <<
"ADSD3030 imager error detected: "
1905 LOG(
ERROR) <<
"Imager error detected. Cannot be displayed "
1906 "because imager type is unknown";
1910 LOG(
INFO) <<
"No chip/imager errors detected.";
1920 unsigned int usDelay = 0;
1923 static_cast<unsigned int>((1 / (double)
m_cameraFps) * 1000000);
1925 status =
m_depthSensor->adsd3500_read_cmd(0x0054, &tmpValue, usDelay);
1927 LOG(
ERROR) <<
"Can not read sensor temperature";
1928 return Status::GENERIC_ERROR;
1937 unsigned int usDelay = 0;
1940 static_cast<unsigned int>((1 / (double)
m_cameraFps) * 1000000);
1942 status =
m_depthSensor->adsd3500_read_cmd(0x0055, &tmpValue, usDelay);
1944 LOG(
ERROR) <<
"Can not read laser temperature";
1945 return Status::GENERIC_ERROR;
1952 const std::map<std::string, std::string> &iniKeyValPairs) {
1956 auto it = iniKeyValPairs.find(
"abThreshMin");
1957 if (
it != iniKeyValPairs.end()) {
1963 <<
"abThreshMin was not found in parameter list, not setting.";
1966 it = iniKeyValPairs.find(
"confThresh");
1967 if (
it != iniKeyValPairs.end()) {
1973 <<
"confThresh was not found in parameter list, not setting.";
1976 it = iniKeyValPairs.find(
"radialThreshMin");
1977 if (
it != iniKeyValPairs.end()) {
1980 LOG(
WARNING) <<
"Could not set radialThreshMin";
1983 <<
"radialThreshMin was not found in parameter list, not setting.";
1986 it = iniKeyValPairs.find(
"radialThreshMax");
1987 if (
it != iniKeyValPairs.end()) {
1990 LOG(
WARNING) <<
"Could not set radialThreshMax";
1993 <<
"radialThreshMax was not found in parameter list, not setting.";
1996 it = iniKeyValPairs.find(
"jblfWindowSize");
1997 if (
it != iniKeyValPairs.end()) {
2000 LOG(
WARNING) <<
"Could not set jblfWindowSize";
2003 <<
"jblfWindowSize was not found in parameter list, not setting.";
2006 it = iniKeyValPairs.find(
"jblfApplyFlag");
2007 if (
it != iniKeyValPairs.end()) {
2008 bool en = !(
it->second ==
"0");
2011 LOG(
WARNING) <<
"Could not set jblfApplyFlag";
2014 <<
"jblfApplyFlag was not found in parameter list, not setting.";
2017 it = iniKeyValPairs.find(
"fps");
2018 if (
it != iniKeyValPairs.end()) {
2023 LOG(
WARNING) <<
"fps was not found in parameter list, not setting.";
2026 it = iniKeyValPairs.find(
"vcselDelay");
2027 if (
it != iniKeyValPairs.end()) {
2033 <<
"vcselDelay was not found in parameter list, not setting.";
2036 it = iniKeyValPairs.find(
"jblfMaxEdge");
2037 if (
it != iniKeyValPairs.end()) {
2043 LOG(
WARNING) <<
"jblfMaxEdge was not found in parameter list, "
2047 it = iniKeyValPairs.find(
"jblfABThreshold");
2048 if (
it != iniKeyValPairs.end()) {
2051 LOG(
WARNING) <<
"Could not set jblfABThreshold";
2053 LOG(
WARNING) <<
"jblfABThreshold was not found in parameter list";
2056 it = iniKeyValPairs.find(
"jblfGaussianSigma");
2057 if (
it != iniKeyValPairs.end()) {
2061 LOG(
WARNING) <<
"Could not set jblfGaussianSigma";
2063 LOG(
WARNING) <<
"jblfGaussianSigma was not found in parameter list, "
2067 it = iniKeyValPairs.find(
"jblfExponentialTerm");
2068 if (
it != iniKeyValPairs.end()) {
2072 LOG(
WARNING) <<
"Could not set jblfExponentialTerm";
2074 LOG(
WARNING) <<
"jblfExponentialTerm was not found in parameter list, "
2078 it = iniKeyValPairs.find(
"enablePhaseInvalidation");
2079 if (
it != iniKeyValPairs.end()) {
2082 LOG(
WARNING) <<
"Could not set enablePhaseInvalidation";
2085 <<
"enablePhaseInvalidation was not found in parameter list, "
2114 return m_depthSensor->adsd3500_write_cmd(0x0080, en ? 0x0001 : 0x0000);
2118 const std::vector<std::pair<uint8_t, uint8_t>> &sequence) {
2122 uint32_t entireSequence = 0xFFFFFFFF;
2123 uint32_t entireRepCount = 0x00000000;
2124 uint8_t *bytePtrSq =
reinterpret_cast<uint8_t *
>(&entireSequence);
2125 uint8_t *bytePtrRc =
reinterpret_cast<uint8_t *
>(&entireRepCount);
2127 for (
size_t i = 0;
i < sequence.size(); ++
i) {
2130 *bytePtrSq = (*bytePtrSq & 0x0F) | (sequence[
i].
first << 4);
2131 *bytePtrRc = (*bytePtrRc & 0x0F) | (sequence[
i].second << 4);
2133 *bytePtrSq = (*bytePtrSq & 0xF0) | (sequence[
i].
first << 0);
2134 *bytePtrRc = (*bytePtrRc & 0xF0) | (sequence[
i].second << 0);
2139 LOG(
WARNING) <<
"More than 8 entries have been provided. Ignoring "
2140 "all entries starting from the 9th.";
2145 uint16_t *sequence0 =
reinterpret_cast<uint16_t *
>(&entireSequence);
2146 uint16_t *sequence1 =
reinterpret_cast<uint16_t *
>(&entireSequence) + 1;
2147 status =
m_depthSensor->adsd3500_write_cmd(0x0081, *sequence0);
2149 LOG(
ERROR) <<
"Failed to set sequence 0 for the Dynamic Mode Switching";
2152 status =
m_depthSensor->adsd3500_write_cmd(0x0082, *sequence1);
2154 LOG(
ERROR) <<
"Failed to set sequence 1 for the Dynamic Mode Switching";
2158 uint16_t *repCount0 =
reinterpret_cast<uint16_t *
>(&entireRepCount);
2159 uint16_t *repCount1 =
reinterpret_cast<uint16_t *
>(&entireRepCount) + 1;
2160 status =
m_depthSensor->adsd3500_write_cmd(0x0083, *repCount0);
2162 LOG(
ERROR) <<
"Failed to set mode repeat count 0 for the Dynamic Mode "
2166 status =
m_depthSensor->adsd3500_write_cmd(0x0084, *repCount1);
2168 LOG(
ERROR) <<
"Failed to set mode repeat count 0 for the Dynamic Mode "
aditof::DepthSensorModeDetails m_modeDetailsCache
int isPCM
set to true if the mode is PCM
aditof::Status saveModuleCCB(const std::string &filepath) override
Save the CCB content which is obtained from module memory to a given file path.
unsigned int subelementsPerElement
The number of sub-elements that an element has. An element is the smallest part of the image (a....
aditof::Status enableXYZframe(bool enable) override
Enable the generation of a XYZ frame. The XYZ frame can be enabled or disabled through ....
aditof::Status loadDepthParamsFromJsonFile(const std::string &pathFile, const int16_t mode_in_use=-1) override
Load adsd parameters from json file. Need setMode to apply.
aditof::Status adsd3500SetConfidenceThreshold(int threshold) override
Set the confidence threshold.
aditof::Status getDetails(aditof::CameraDetails &details) const override
Gets the current details of the camera.
aditof::Status adsd3500SetToggleMode(int mode) override
Enables or disables FSYNC toggle for ADSD3500.
uint8_t modeNumber
Number associated with the mode.
std::vector< uint8_t > m_availableModes
aditof::Status setAdsd3500IniParams(const std::map< std::string, std::string > &iniKeyValPairs)
std::string GetStringADSD3030(uint16_t value)
Returns a string for a given target (adsdType) and error code for the ADSD3030.
int frameHeightInBytes
Driver height, can be used for both chipRaw and imagerRaw.
std::uint8_t mode
The mode in which the camera operates.
aditof::Status setControl(const std::string &control, const std::string &value) override
Sets a specific camera control.
aditof::ImagerType m_imagerType
int16_t m_enableMetaDatainAB
int baseResolutionHeight
Processed data height.
Provides details about the device.
aditof::Status requestFrame(aditof::Frame *frame) override
Captures data from the camera and assigns it to the given frame.
std::unordered_map< std::string, std::string > m_controls
void freeConfigData(void)
Frees the calibration member variables created while loading the CCB contents.
static int16_t getValueFromJSON(cJSON *config_json, std::string key)
aditof::Status readAdsd3500CCB(std::string &ccb)
Read the CCB from adsd3500 memory and store in output variable ccb.
aditof::Status adsd3500SetEnableMetadatainAB(uint16_t value) override
Set Enable Metadata in the AB frame.
@ GENERIC_ERROR
An error occured but there are no details available.
aditof::Status getImagerType(aditof::ImagerType &imagerType) const override
Provides the type of the imager.
aditof::Status adsd3500GetJBLFGaussianSigma(uint16_t &value) override
Get JBLF Gaussian Sigma.
aditof::Status adsd3500IsCCBMsupported(bool &supported) override
Check whether CCB as master is supported or not.
aditof::CameraDetails m_details
aditof::Status adsd3500GetSensorTemperature(uint16_t &tmpValue) override
Get the sensor temperature.
aditof::Status adsd3500SetEnableTemperatureCompensation(uint16_t value) override
Set Enable Temperature Compensation.
aditof::Status readSerialNumber(std::string &serialNumber, bool useCacheValue=false) override
Read serial number from camera and update cache.
void configureSensorModeDetails()
aditof::Status setSensorConfiguration(const std::string &sensorConf) override
Set sensor configutation table.
aditof::Status adsd3500GetEnableMetadatainAB(uint16_t &value) override
Get state of Enable Metadata in the AB frame.
std::string m_netLinkTest
#define NR_READADSD3500CCB
std::string type
The type of data that can be found in a frame. For example it could be depth data or IR data,...
std::vector< aditof::DepthSensorModeDetails > m_availableSensorModeDetails
CameraIntrinsics camera_intrinsics
aditof::Status setFrameProcessParams(std::map< std::string, std::string > ¶ms) override
Set the Depth Compute Library ini parameters.
GLsizei const GLchar *const * string
uint32_t crcFast(uint8_t const message[], int nBytes, bool isMirrored)
unsigned int width
The width of the frame data.
@ UNAVAILABLE
The requested action or resource is unavailable.
Adsd3500Status
Status of the ADSD3500 sensor.
aditof::Status adsd3500SetRadialThresholdMin(int threshold) override
Set the radial threshold min.
aditof::Status adsd3500SetJBLFfilterEnableState(bool enable) override
Enable/disable the JBLF filter.
aditof::Status adsd3500SetJBLFABThreshold(uint16_t threshold) override
Get JBLF Max Edge Threshold.
int16_t m_mipiOutputSpeed
#define cJSON_ArrayForEach(element, array)
aditof::Status adsd3500GetStatus(int &chipStatus, int &imagerStatus) override
Returns the chip status.
std::string GetStringADSD3100(uint16_t value)
Returns a string for a given target (adsdType) and error code for the ADSD3100.
FileData LoadFileContents(char *filename)
std::map< int, std::map< std::string, std::string > > m_depth_params_map
aditof::Status enableDepthCompute(bool enable) override
Enable or disable the depth processing on the frames received from the sensor Must be called after ge...
aditof::Status adsd3500ToggleFsync() override
Toggles ADSD3500 FSYNC once if automated FSYNC is disabled.
aditof::Status normalizeABFrame(aditof::Frame *frame, bool advanceScaling, bool useLogScaling) override
Scale AB image with logarithmic base 10 in a Frame instance.
unsigned int width
The width of the frame.
cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
std::string serialNumber
The serial number of camera.
std::map< std::string, noArgCallable > m_noArgCallables
GLenum GLenum GLsizei const GLuint GLboolean enabled
#define GEN_XYZ_ITERATIONS
aditof::Status adsd3500SetFrameRate(uint16_t fps) override
Set Frame Rate.
static size_t begin(const upb_table *t)
uint8_t m_depthBitsPerPixel
std::string GetStringADSD3500(uint16_t value)
Returns a string for a given target (adsdType) and error code for the ADSD3500.
cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string)
std::shared_ptr< aditof::DepthSensorInterface > m_depthSensor
aditof::Status adsd3500GetGenericTemplate(uint16_t reg, uint16_t &value) override
Generic ADSD3500 function for commands not defined in the SDK (yet)
aditof::Status adsd3500GetImagerErrorCode(uint16_t &errcode) override
Get error code from the imager.
std::map< std::string, FileData > m_depthINIDataMap
@ UNSET
Value for when the type is unset.
aditof::Status adsd3500SetGenericTemplate(uint16_t reg, uint16_t value) override
Generic ADSD3500 function for commands not defined in the SDK (yet)
std::vector< FrameDataDetails > dataDetails
A frame can have multiple types of data. For example it could hold data about depth and/or data about...
Describes the properties of a frame.
aditof::Status retrieveDepthProcessParams()
unsigned int height
The height of the frame.
std::string id
The sensor identification data to be used to differentiate between sensors. When on target,...
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei imageSize
unsigned int subelementSize
The size in bytes of a sub-element. A sub-element is a sub-component of an element....
aditof::Status adsd3500setEnableDynamicModeSwitching(bool en) override
Allows enabling or disabling the Dynamic Mode Switching. NOTE: This must be enabled before configurin...
std::pair< std::string, std::string > m_adsd3500FwGitHash
ImagerType
Types of imagers.
aditof::Status adsd3500SetVCSELDelay(uint16_t delay) override
Set the delay for VCSEL - ADSD3100 imager only.
int16_t m_enableEdgeConfidence
aditof::Status initialize(const std::string &configFilepath={}) override
Initialize the camera. This is required before performing any operation on the camera.
aditof::Status adsd3500GetJBLFfilterSize(int &size) override
Get the JBLF filter size.
int m_adsd3500FwVersionInt
SDK_API Status setDetails(const FrameDetails &details)
Configures the frame with the given details.
Describes the properties of a data that embedded within the frame.
aditof::Status getAvailableControls(std::vector< std::string > &controls) const override
Gets the camera's list of controls.
GLenum const GLfloat * params
aditof::Status getControl(const std::string &control, std::string &value) const override
Gets the value of a specific camera control.
aditof::Status saveModuleCFG(const std::string &filepath) const override
Save the CFG content which is obtained from module memory to a given file path.
SDK_API Status getData(const std::string &dataType, uint16_t **dataPtr)
Gets the address where the specified data is being stored.
aditof::Status adsd3500SetEnablePhaseInvalidation(uint16_t value) override
Set Enable Phase Invalidation.
Describes the properties of a camera.
aditof::Status getFrameProcessParams(std::map< std::string, std::string > ¶ms) override
Get the Depth Compute Library ini parameters.
aditof::Status adsd3500SetJBLFGaussianSigma(uint16_t value) override
Set JBLF Gaussian Sigma.
const SETUP_TEARDOWN_TESTCONTEXT char * key
aditof::Status adsd3500ResetIniParamsForMode(const uint16_t mode) override
Reset the ini parameters from the chip and sets the ones stored in CCB.
aditof::Status adsd3500GetFirmwareVersion(std::string &fwVersion, std::string &fwHash) override
aditof::Status adsd3500GetConfidenceThreshold(int &threshold) override
Get the confidence threshold.
uint8_t totalCaptures
totalCaptures or subframes in a frame
aditof::Status adsd3500GetVCSELDelay(uint16_t &delay) override
Get the delay for VCSEL - ADSD3100 imager only.
SDK_API Status getDataDetails(const std::string &dataType, FrameDataDetails &details) const
Gets details of a type of data within the frame.
int16_t m_enableTempCompenstation
@ INVALID_ARGUMENT
Invalid arguments provided.
const uint16_t ADSD3500_STATUS_IMAGER_ERROR
The imager reported an error.
Status
Status of any operation that the TOF sdk performs.
std::string m_initConfigFilePath
aditof::Adsd3500Status m_adsd3500Status
aditof::Status adsd3500GetRadialThresholdMin(int &threshold) override
Get the radial threshold min.
aditof::Status adsd3500GetLaserTemperature(uint16_t &tmpValue) override
Get the laser temperature.
std::shared_ptr< aditof::DepthSensorInterface > getSensor() override
Gets the sensor of the camera. This gives direct access to low level configuration of the camera sens...
SDK_API Status getDetails(FrameDetails &details) const
Gets the current details of the frame.
uint8_t m_confBitsPerPixel
int baseResolutionWidth
Processed data witdh.
static uint32_t GenerateXYZTables(const float **pp_x_table, const float **pp_y_table, const float **pp_z_table, CameraIntrinsics *p_intr_data, uint32_t n_sensor_rows, uint32_t n_sensor_cols, uint32_t n_out_rows, uint32_t n_out_cols, uint32_t n_offset_rows, uint32_t n_offset_cols, uint8_t row_bin_factor, uint8_t col_bin_factor, uint8_t iter)
void FloatToLinGenerateTable()
aditof::Status adsd3500SetMIPIOutputSpeed(uint16_t speed) override
Set ADSD3500 MIPI output speed.
const float * p_y_table
Pointer to the radial correction Y Table.
aditof::Status adsd3500GetMIPIOutputSpeed(uint16_t &speed) override
Get ADSD3500 MIPI output speed.
aditof::Status adsd3500GetRadialThresholdMax(int &threshold) override
Get the radial threshold max.
aditof::Status adsd3500GetTemperatureCompensationStatus(uint16_t &value) override
Get Temperature Compensation Status.
aditof::ADSDErrors m_adsdErrors
aditof::Status adsd3500SetEnableEdgeConfidence(uint16_t value) override
Set Enable Edge Confidence.
static const int skMetaDataBytesCount
static uint32_t ComputeXYZ(const uint16_t *p_depth, XYZTable *p_xyz_data, int16_t *p_xyz_image, uint32_t n_rows, uint32_t n_cols)
aditof::Status getAvailableModes(std::vector< uint8_t > &availableModes) const override
Returns all the modes that are supported by the camera.
std::string m_ccb_calibrationFile
Describes the type of entire frame that a depth sensor can capture and transmit.
virtual SDK_API Status getMetadataStruct(Metadata &metadata) const
Extracts the metadata content and returns a struct with values.
FrameDetails frameType
Details about the frames that camera is capturing.
cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string)
aditof::Status start() override
Start the camera. This starts the streaming of data from the camera.
TofiXYZDealiasData m_xyz_dealias_data[MAX_N_MODES+1]
int frameWidthInBytes
Driver width, can be used for both chipRaw and imagerRaw.
aditof::Status adsd3500GetJBLFfilterEnableState(bool &enabled) override
Get the JBLF enabled state.
const float * p_x_table
Pointer to the radial correction X Table.
CameraItof(std::shared_ptr< aditof::DepthSensorInterface > depthSensor, const std::string &ubootVersion, const std::string &kernelVersion, const std::string &sdCardImageVersion, const std::string &netLinkTest)
aditof::Status setMode(const uint8_t &mode) override
Puts the camera into the given mode.
aditof::Status adsd3500SetJBLFfilterSize(int size) override
Set the JBLF filter size.
void dropFirstFrame(bool dropFrame) override
Allow drop first frame.
ConnectionType connectionType
The type of connection with the sensor.
aditof::Status adsd3500GetFrameRate(uint16_t &fps) override
Get Frame Rate.
void normalizeABBuffer(uint16_t *abBuffer, uint16_t abWidth, uint16_t abHeight, bool advanceScaling, bool useLogScaling) override
Scale AB image with logarithmic base 10.
aditof::Status stop() override
Stop the camera. This makes the camera to stop streaming.
GLsizei const GLfloat * value
unsigned int bytesCount
The total number of bytes that the data has. This can be useful when copying data to another location...
aditof::Status saveDepthParamsToJsonFile(const std::string &savePathFile) override
Save ini file to json format.
const std::map< ImagerType, std::string > ControlValue
Types of imagers based on ControlValue.
void cleanupXYZtables()
Delete allocated tables for X, Y, Z.
const GLuint GLenum const GLvoid * binary
aditof::Status adsd3500SetRadialThresholdMax(int threshold) override
Set the radial threshold max.
aditof::Status adsd3500GetABinvalidationThreshold(int &threshold) override
Get the AB invalidation threshold.
const std::map< ImagerType, std::string > imagerType
Types of imagers.
ConnectionType connection
The type of connection with the camera.
bool isConvertibleToDouble(const std::string &str)
Check if string can convert to double.
aditof::Status adsd3500SetABinvalidationThreshold(int threshold) override
Set the AB invalidation threshold.
cJSON_AddNumberToObject(cJSON *const object, const char *const name, const double number)
unsigned int height
The height of the frame data.
std::map< std::string, std::string > m_iniKeyValPairs
aditof::Status adsd3500DisableCCBM(bool disable) override
Enable/disable ccb as master.
aditof::Status adsd3500SetJBLFExponentialTerm(uint16_t value) override
Set JBLF Exponential Term.
aditof::Status adsd3500SetJBLFMaxEdgeThreshold(uint16_t threshold) override
Set JBLF Max Edge Threshold.
std::vector< std::pair< uint8_t, uint8_t > > m_configDmsSequence
const float * p_z_table
Pointer to the radial correction Z Table.
aditof::Status adsd3500UpdateFirmware(const std::string &filePath) override
Update the firmware of ADSD3500 with the content found in the specified file.
aditof::Status adsd3500GetJBLFExponentialTerm(uint16_t &value) override
Get JBLF Exponential Term.
aditof::Status adsds3500setDynamicModeSwitchingSequence(const std::vector< std::pair< uint8_t, uint8_t >> &sequence) override
Configures the sequence to be captured.
IntrinsicParameters intrinsics
Details about the intrinsic parameters of the camera.
std::function< void(Adsd3500Status)> SensorInterruptCallback
Callback for sensor interrupts.
aditof::Status loadConfigData(void)
Opens the CCB file passed in as part of Json file using initialize(), and loads the calibration block...
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:48