76 {
"LocResultPort", 2201},
78 {
"LocResultState", 1},
79 {
"LocResultEndianness", 0},
81 {
"LocRequestResultData", 1}
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):");
146 ROS_ERROR_STREAM(
"## recoded:");
169 static ROS::Time start_time =
ROS::now();
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());
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();
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);
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];
506 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultPort" && cola_request.parameter.size() == 1)
511 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultMode" && cola_request.parameter.size() == 1)
516 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetResultPoseEnabled" && cola_request.parameter.size() == 1)
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)
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++)
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++)
562 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetMap" && cola_request.parameter.size() == 2)
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++)
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++)
593 if(cola_request.command_type ==
sick_scan::ColaParser::sMN && cola_request.command_name ==
"LocSetPoseQualityCovWeight" && cola_request.parameter.size() == 1)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
769 if(cola_request.command_type ==
sick_scan::ColaParser::sRN && cola_request.command_name ==
"DevIMUActive" && cola_request.parameter.size() == 0)
786 if(cola_request.command_name == iter_settings->first)
805 static ROS::Time start =
ROS::now();
808 ROS::Duration timestamp = (
ROS::now() - start);
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();
static double normalizeAngle(double angle)
virtual sick_scan::SickLocResultPortTelegramMsg & getTelegramMsg(void)
static std::string flattenToString(const T &x)
static bool ResultTelegramsEnabled(void)
static std::map< std::string, int32_t > s_controller_settings
test server int32 settings, set by sMN or sRN requests
static sick_scan::SickLocColaTelegramMsg createColaResponse(const sick_scan::SickLocColaTelegramMsg &cola_request, const std::string &scanner_type)
static uint32_t s_u32ResultPoseInterval
result pose interval, i.e. the interval in number of scans (default: 1, i.e. result telegram with eac...
static std::string toHexString(const std::vector< uint8_t > &binary_data)
static uint32_t createTimestampTicksMilliSec(void)
static bool SendScandataEnabled(void)
enum sick_scan::ColaParser::COLA_SOPAS_COMMAND_ENUM COLA_SOPAS_COMMAND
Enumeration of SOPAS commands in cola telegrams: The command_type in SickLocColaTelegramMsg is one of...
uninitialized, command_type should never have this value)
void splitTime(ROS::Duration time, uint32_t &seconds, uint32_t &nanoseconds)
static sick_scan::SickLocResultPortTestcaseMsg createDefaultResultPortTestcase(void)
static std::string convertSopasCommand(COLA_SOPAS_COMMAND command_type)
Converts and returns a COLA_SOPAS_COMMAND to string. Example: convertSopasCommand(sMN) returns "sMN"...
static sick_scan::SickLocColaTelegramMsg createColaTelegram(const COLA_SOPAS_COMMAND &command_type, const std::string &command_name, const std::vector< std::string > ¶meter=std::vector< std::string >())
Creates and returns a Cola telegram (type SickLocColaTelegramMsg).
static std::map< std::string, std::string > s_controller_settings_str
test server string settings, set by sMN or sRN requests
static bool LocalizationEnabled(void)
virtual std::vector< uint8_t > encode(void)
virtual bool decode(const std::vector< uint8_t > &binary_data)
#define ROS_ERROR_STREAM(args)
static sick_scan::SickLocResultPortTestcaseMsg createRandomResultPortTestcase(void)
void sleep(double seconds)
double seconds(ROS::Duration duration)
static sick_scan::SickLocResultPortTestcaseMsg createResultPortCircles(double circle_radius, double circle_yaw)