76 {
"LocResultPort", 2201},
78 {
"LocResultState", 1},
79 {
"LocResultEndianness", 0},
81 {
"LocRequestResultData", 1}
105 return s_controller_settings[
"LocState"] == 2;
114 return LocalizationEnabled() && s_controller_settings[
"LocResultState"] > 0;
123 sick_scan::SickLocResultPortTestcaseMsg testcase;
127 testcase.header.frame_id =
"sick_localization_testcase";
130 testcase.binary_data = {
131 0x53, 0x49, 0x43, 0x4B, 0x00, 0x00, 0x00, 0x6A, 0x06, 0x42, 0x00, 0x01, 0x00, 0x10, 0xC0, 0x58, 0x01, 0x22, 0xA2, 0x72,
132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x4C, 0x53, 0x20, 0x56, 0x30, 0x2E, 0x31, 0x2E, 0x39, 0x2E, 0x78, 0x42,
133 0x00, 0x00, 0x02, 0x6D, 0x83, 0xAA, 0x8C, 0x0C, 0x8E, 0x14, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x6F, 0x00, 0x34,
134 0xEC, 0xF3, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x45, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
135 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x80, 0x89, 0x00, 0x00, 0x99, 0x93, 0x00, 0x12, 0x78, 0x9F, 0x00, 0x00, 0x00, 0x00,
136 0x00, 0x00, 0x00, 0x00, 0x62, 0x11 };
140 std::vector<uint8_t> recoded_telegram;
141 if(!result_port_parser.
decode(testcase.binary_data) || (recoded_telegram = result_port_parser.
encode()) != testcase.binary_data)
143 ROS_ERROR_STREAM(
"## ERROR TestcaseGenerator::createDefaultResultPortTestcase: sick_scan::ResultPortParser::decode() failed. " << testcase.binary_data.size() <<
" byte input (hex):");
169 static ROS::Time start_time =
ROS::now();
170 static sick_scan::SickLocResultPortTestcaseMsg default_testcase = createDefaultResultPortTestcase();
171 sick_scan::SickLocResultPortTestcaseMsg testcase = default_testcase;
172 sick_scan::SickLocResultPortTelegramMsg & telegram_msg = testcase.telegram_msg;
175 telegram_msg.telegram_header.payloadtype = ((random1_generator.
generate() > 0) ? 0x06c2 : 0x0642);
176 telegram_msg.telegram_header.ordernumber = (uint32_t)random32_generator.
generate();
177 telegram_msg.telegram_header.serialnumber = (uint32_t)random32_generator.
generate();
178 for(
size_t n = 0; n < telegram_msg.telegram_header.fw_version.size(); n++)
179 telegram_msg.telegram_header.fw_version[n] = (uint8_t)random8_generator.
generate();
180 telegram_msg.telegram_payload.posex = random32_generator.
generate();
181 telegram_msg.telegram_payload.posey = random32_generator.
generate();
182 telegram_msg.telegram_payload.poseyaw = random_yaw_generator.
generate();
183 telegram_msg.telegram_payload.reserved1 = (uint32_t)random32_generator.
generate();
184 telegram_msg.telegram_payload.reserved2 = random32_generator.
generate();
185 telegram_msg.telegram_payload.quality = (uint8_t)random_quality_generator.
generate();
186 telegram_msg.telegram_payload.outliersratio = (uint8_t)random_quality_generator.
generate();
187 telegram_msg.telegram_payload.covariancex = random_covariance_generator.
generate();
188 telegram_msg.telegram_payload.covariancey = random_covariance_generator.
generate();
189 telegram_msg.telegram_payload.covarianceyaw = random_covariance_generator.
generate();
190 telegram_msg.telegram_payload.reserved3 = (((uint64_t)random32_generator.
generate() << 32) | (uint64_t)random32_generator.
generate());
194 telegram_msg.telegram_payload.timestamp = createTimestampTicksMilliSec();
195 telegram_msg.telegram_header.systemtime += (uint64_t)(delta_time_seconds);
200 testcase.binary_data = result_port_parser.
encode();
204 default_testcase.telegram_msg.telegram_header.telegramcounter += 1;
205 default_testcase.telegram_msg.telegram_payload.scancounter += 1;
223 static ROS::Time start_time =
ROS::now();
224 static sick_scan::SickLocResultPortTestcaseMsg default_testcase = createDefaultResultPortTestcase();
225 sick_scan::SickLocResultPortTestcaseMsg testcase = default_testcase;
226 sick_scan::SickLocResultPortTelegramMsg & telegram_msg = testcase.telegram_msg;
229 telegram_msg.telegram_payload.posex = (int32_t)(1000.0 * circle_radius * std::cos(circle_yaw));
230 telegram_msg.telegram_payload.posey = (int32_t)(1000.0 * circle_radius * std::sin(circle_yaw));
232 telegram_msg.telegram_payload.poseyaw = (int32_t)(1000.0 * orientation * 180.0 / M_PI);
236 telegram_msg.telegram_payload.timestamp = createTimestampTicksMilliSec();
237 telegram_msg.telegram_header.systemtime += (uint64_t)(delta_time_seconds);
242 testcase.binary_data = result_port_parser.
encode();
246 default_testcase.telegram_msg.telegram_header.telegramcounter += 1;
247 default_testcase.telegram_msg.telegram_payload.scancounter += 1;
263 static std::map<sick_scan::ColaParser::COLA_SOPAS_COMMAND, std::map<std::string, sick_scan::SickLocColaTelegramMsg>> s_mapped_responses;
264 static bool s_mapped_responses_initialized =
false;
265 if(!s_mapped_responses_initialized)
344 if(scanner_type ==
"sick_lms_5xx")
397 if(scanner_type ==
"sick_lms_1xx")
399 s_mapped_responses[
sick_scan::ColaParser::sRN][
"field000"] =
sick_scan::ColaParser::createColaTelegram(
sick_scan::ColaParser::convertSopasCommand(
"sRA"),
"field000", {
"3f8000000000000000001388fff92230020100010029019affff0176019bffff0175019cffff0171019dffff015f019effff0154019fffff015101a0ffff015101a1ffff015101a2ffff015101a3ffff015101a4ffff015101a5ffff015101a6ffff015201a7ffff015301a8ffff014601a9ffff014601aaffff014601abffff014901acffff014901adffff014b01aeffff014901afffff014901b0ffff014901b1ffff014a01b2ffff014301b3ffff014301b4ffff014301b5ffff014801b6ffff014801b7ffff014801b8ffff014d01b9ffff014e01baffff014c01bbffff014a01bcffff014701bdffff014701beffff014701bfffff014a01c0ffff014601c1ffff014601c2ffff0146000000000000000100064649454c44310000"});
451 s_mapped_responses_initialized =
true;
455 for(std::map<
sick_scan::ColaParser::COLA_SOPAS_COMMAND, std::map<std::string, sick_scan::SickLocColaTelegramMsg>>::iterator iter_cmd = s_mapped_responses.begin(); iter_cmd != s_mapped_responses.end(); iter_cmd++)
457 if(cola_request.command_type == iter_cmd->first)
459 std::map<std::string, sick_scan::SickLocColaTelegramMsg>& mapped_response = iter_cmd->second;
460 if(mapped_response.find(cola_request.command_name) != mapped_response.end())
462 return mapped_response[cola_request.command_name];
474 uint32_t ticks_ms = createTimestampTicksMilliSec();
483 s_controller_settings[
"LMCstartmeas"] = 1;
488 s_controller_settings[
"LMCstartmeas"] = 0;
493 s_controller_settings[
"LocState"] = 2;
498 s_controller_settings[
"LocState"] = 1;
503 s_controller_settings[
"LocState"] = 1;
506 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultPort" && cola_request.parameter.size() == 1)
508 s_controller_settings[
"LocResultPort"] = std::strtol(cola_request.parameter[0].c_str(), 0, 0);
511 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultMode" && cola_request.parameter.size() == 1)
513 s_controller_settings[
"LocResultMode"] = std::strtol(cola_request.parameter[0].c_str(), 0, 0);
516 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultPoseEnabled" && cola_request.parameter.size() == 1)
518 s_controller_settings[
"LocResultState"] = std::strtol(cola_request.parameter[0].c_str(), 0, 0);
521 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultEndianness" && cola_request.parameter.size() == 1)
523 s_controller_settings[
"LocResultEndianness"] = std::strtol(cola_request.parameter[0].c_str(), 0, 0);;
527 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetPose" && cola_request.parameter.size() == 4)
529 int32_t posex_mm = std::strtol(cola_request.parameter[0].c_str(), 0, 0);
530 int32_t posey_mm = std::strtol(cola_request.parameter[1].c_str(), 0, 0);
531 int32_t yaw_mdeg = std::strtol(cola_request.parameter[2].c_str(), 0, 0);
532 int32_t uncertainty = std::strtol(cola_request.parameter[3].c_str(), 0, 0);
533 bool success = (posex_mm >= -300000 && posex_mm <= +300000 && posey_mm >= -300000 && posey_mm <= +300000
534 && yaw_mdeg >= -180000 && yaw_mdeg <= +180000 && uncertainty >= 0 && uncertainty < 300000);
538 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultPoseInterval" && cola_request.parameter.size() == 1)
540 s_u32ResultPoseInterval = std::strtoul(cola_request.parameter[0].c_str(), 0, 0);
546 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"DevSetLidarConfig" && cola_request.parameter.size() == 15)
548 for(
size_t n = 0; n < cola_request.parameter.size(); n++)
549 s_controller_settings_str[
"DevSetLidarConfig_"+std::to_string(n)] = cola_request.parameter[n];
553 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"DevGetLidarConfig" && cola_request.parameter.size() == 1)
555 std::vector<std::string> config_parameter;
556 for(
size_t n = 1; n < 15; n++)
558 config_parameter.push_back(s_controller_settings_str[
"DevSetLidarConfig_"+std::to_string(n)]);
562 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetMap" && cola_request.parameter.size() == 2)
564 s_controller_settings_str[
"LocSetMap"] = cola_request.parameter[1];
568 if(cola_request.command_name ==
"LocMap")
573 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocMapState" && cola_request.parameter.size() == 0)
578 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocInitializePose" && cola_request.parameter.size() == 4)
580 for(
size_t n = 0; n < cola_request.parameter.size(); n++)
581 s_controller_settings_str[
"LocInitializePose_"+std::to_string(n)] = cola_request.parameter[n];
585 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocInitialPose" && cola_request.parameter.size() == 0)
587 std::vector<std::string> parameter;
588 for(
size_t n = 0; n < 4; n++)
589 parameter.push_back(s_controller_settings_str[
"LocInitializePose_"+std::to_string(n)]);
593 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetPoseQualityCovWeight" && cola_request.parameter.size() == 1)
595 s_controller_settings_str[
"LocSetPoseQualityCovWeight"] = cola_request.parameter[0];
599 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocPoseQualityCovWeight" && cola_request.parameter.size() == 0)
604 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetPoseQualityMeanDistWeight" && cola_request.parameter.size() == 1)
606 s_controller_settings_str[
"LocSetPoseQualityMeanDistWeight"] = cola_request.parameter[0];
610 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocPoseQualityMeanDistWeight" && cola_request.parameter.size() == 0)
615 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetReflectorsForSupportActive" && cola_request.parameter.size() == 1)
617 s_controller_settings_str[
"LocSetReflectorsForSupportActive"] = cola_request.parameter[0];
621 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocReflectorsForSupportActive" && cola_request.parameter.size() == 0)
626 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetOdometryActive" && cola_request.parameter.size() == 1)
628 s_controller_settings_str[
"LocSetOdometryActive"] = cola_request.parameter[0];
632 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocOdometryActive" && cola_request.parameter.size() == 0)
637 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetOdometryPort" && cola_request.parameter.size() == 1)
639 s_controller_settings_str[
"LocSetOdometryPort"] = cola_request.parameter[0];
643 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocOdometryPort" && cola_request.parameter.size() == 0)
648 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetOdometryRestrictYMotion" && cola_request.parameter.size() == 1)
650 s_controller_settings_str[
"LocSetOdometryRestrictYMotion"] = cola_request.parameter[0];
654 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocOdometryRestrictYMotion" && cola_request.parameter.size() == 0)
659 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetAutoStartActive" && cola_request.parameter.size() == 1)
661 s_controller_settings_str[
"LocSetAutoStartActive"] = cola_request.parameter[0];
665 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocAutoStartActive" && cola_request.parameter.size() == 0)
670 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetAutoStartSavePoseInterval" && cola_request.parameter.size() == 1)
672 s_controller_settings_str[
"LocSetAutoStartSavePoseInterval"] = cola_request.parameter[0];
676 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocAutoStartSavePoseInterval" && cola_request.parameter.size() == 0)
681 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetRingBufferRecordingActive" && cola_request.parameter.size() == 1)
683 s_controller_settings_str[
"LocSetRingBufferRecordingActive"] = cola_request.parameter[0];
687 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocRingBufferRecordingActive" && cola_request.parameter.size() == 0)
692 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"DevGetLidarIdent" && cola_request.parameter.size() == 1)
697 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"DevGetLidarState" && cola_request.parameter.size() == 1)
702 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"GetSoftwareVersion" && cola_request.parameter.size() == 0)
707 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocAutoStartSavePose" && cola_request.parameter.size() == 0)
712 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocForceUpdate" && cola_request.parameter.size() == 0)
717 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSaveRingBufferRecording" && cola_request.parameter.size() == 2)
722 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocStartDemoMapping" && cola_request.parameter.size() == 0)
727 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"ReportUserMessage" && cola_request.parameter.size() == 2)
732 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"SavePermanent" && cola_request.parameter.size() == 0)
737 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocResultPort" && cola_request.parameter.size() == 0)
739 int32_t port = ((s_controller_settings[
"LocResultPort"]) > 0 ? s_controller_settings[
"LocResultPort"] : 2201);
743 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocResultMode" && cola_request.parameter.size() == 0)
748 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocResultEndianness" && cola_request.parameter.size() == 0)
753 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocResultState" && cola_request.parameter.size() == 0)
758 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"LocResultPoseInterval" && cola_request.parameter.size() == 0)
763 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"DevSetIMUActive" && cola_request.parameter.size() == 1)
765 s_controller_settings_str[
"DevSetIMUActive"] = cola_request.parameter[0];
769 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"DevIMUActive" && cola_request.parameter.size() == 0)
784 for(std::map<std::string, int32_t>::iterator iter_settings = s_controller_settings.begin(); iter_settings != s_controller_settings.end(); iter_settings++)
786 if(cola_request.command_name == iter_settings->first)
809 uint32_t
seconds = 0, nanoseconds = 0;
811 uint32_t ticks_ms = (((uint64_t)
seconds * 1000 + (uint64_t)nanoseconds/1000000 + 1000) & 0xFFFFFFFF);
813 ticks_ms += time_jitter_ticks_ms.
generate();