46 #define _WIN32_WINNT 0x0501 47 #pragma warning(disable: 4996) 48 #pragma warning(disable: 4267) 59 #include <sick_scan/RadarScan.h> 62 #include "sick_scan/rosconsole_simu.hpp" 64 #define _USE_MATH_DEFINES 102 if (1 == sscanf(str.c_str(),
"%x", &val))
108 ROS_WARN(
"Problems parsing %s\n", str.c_str());
117 if (1 == sscanf(str.c_str(),
"%x", &val))
123 ROS_WARN(
"Problems parsing %s\n", str.c_str());
133 val = (float) (value * scale + offset);
141 ptr = (
unsigned char *) (&tmpVal);
142 int strLen = str.length();
148 for (
int i = 0; i < 4; i++)
150 std::string dummyStr =
"";
151 dummyStr += str[i * 2];
152 dummyStr += str[i * 2 + 1];
154 unsigned char ch = (0xFF & val);
182 sick_scan::RadarScan *msgPtr,
183 std::vector<SickScanRadarObject> &objectList,
184 std::vector<SickScanRadarRawTarget> &rawTargetList)
188 bool dumpData =
false;
189 int verboseLevel = 0;
190 tmpParam.
getParam(
"verboseLevel", verboseLevel);
194 int HEADER_FIELDS = 32;
199 std::vector<char *> fields;
200 fields.reserve(datagram_length / 2);
203 std::vector<char> datagram_copy_vec;
204 datagram_copy_vec.resize(datagram_length + 1);
205 char *datagram_copy = &(datagram_copy_vec[0]);
207 if (verboseLevel > 0)
209 ROS_WARN(
"Verbose LEVEL activated. Only for DEBUG.");
212 if (verboseLevel > 0)
215 char szDumpFileName[255] = {0};
216 char szDir[255] = {0};
218 strcpy(szDir,
"C:\\temp\\");
220 strcpy(szDir,
"/tmp/");
222 sprintf(szDumpFileName,
"%stmp%06d.bin", szDir, cnt);
224 ftmp = fopen(szDumpFileName,
"wb");
227 fwrite(datagram, datagram_length, 1, ftmp);
232 strncpy(datagram_copy, datagram, datagram_length);
233 datagram_copy[datagram_length] = 0;
237 cur_field = strtok(datagram,
" ");
239 while (cur_field != NULL)
241 fields.push_back(cur_field);
243 cur_field = strtok(NULL,
" ");
248 count = fields.size();
251 if (verboseLevel > 0)
254 char szDumpFileName[255] = {0};
255 char szDir[255] = {0};
257 strcpy(szDir,
"C:\\temp\\");
259 strcpy(szDir,
"/tmp/");
261 sprintf(szDumpFileName,
"%stmp%06d.txt", szDir, cnt);
262 ROS_WARN(
"Verbose LEVEL activated. Only for DEBUG.");
264 ftmp = fopen(szDumpFileName,
"w");
268 for (i = 0; i < count; i++)
270 fprintf(ftmp,
"%3d: %s\n", i, fields[i]);
278 enum PREHEADER_TOKEN_SEQ
281 PREHEADER_TOKEN_LMDRADARDATA,
282 PREHEADER_TOKEN_UI_VERSION_NO,
283 PREHEADER_TOKEN_UI_IDENT,
284 PREHEADER_TOKEN_UDI_SERIAL_NO,
285 PREHEADER_TOKEN_XB_STATE_0,
286 PREHEADER_TOKEN_XB_STATE_1,
287 PREHEADER_TOKEN_TELEGRAM_COUNT,
288 PREHEADER_TOKEN_CYCLE_COUNT,
289 PREHEADER_TOKEN_SYSTEM_COUNT_SCAN,
290 PREHEADER_TOKEN_SYSTEM_COUNT_TRANSMIT,
291 PREHEADER_TOKEN_XB_INPUTS_0,
292 PREHEADER_TOKEN_XB_INPUTS_1,
293 PREHEADER_TOKEN_XB_OUTPUTS_0,
294 PREHEADER_TOKEN_XB_OUTPUTS_1,
295 PREHEADER_TOKEN_CYCLE_DURATION,
296 PREHEADER_TOKEN_NOISE_LEVEL,
297 PREHEADER_NUM_ENCODER_BLOCKS,
298 PREHADERR_TOKEN_FIX_NUM
337 for (
int i = 0; i < PREHADERR_TOKEN_FIX_NUM; i++)
341 unsigned long int uliDummy;
342 uliDummy = strtoul(fields[i], NULL, 16);
345 case PREHEADER_TOKEN_UI_VERSION_NO:
346 msgPtr->radarPreHeader.uiVersionNo = (
UINT16) (uliDummy & 0xFFFF);
348 case PREHEADER_TOKEN_UI_IDENT:
349 msgPtr->radarPreHeader.radarPreHeaderDeviceBlock.uiIdent = (
UINT16) (uliDummy & 0xFFFF);
351 case PREHEADER_TOKEN_UDI_SERIAL_NO:
352 msgPtr->radarPreHeader.radarPreHeaderDeviceBlock.udiSerialNo = (
UINT32) (uliDummy & 0xFFFFFFFF);
354 case PREHEADER_TOKEN_XB_STATE_0:
355 for (
int j = 0; j < 3; j++)
358 if (0 != (uliDummy & (1 << j)))
365 msgPtr->radarPreHeader.radarPreHeaderDeviceBlock.bDeviceError = flag;
368 msgPtr->radarPreHeader.radarPreHeaderDeviceBlock.bContaminationWarning = flag;
371 msgPtr->radarPreHeader.radarPreHeaderDeviceBlock.bContaminationError = flag;
374 ROS_WARN(
"Flag parsing for this PREHEADER-Flag not implemented");
378 case PREHEADER_TOKEN_XB_STATE_1:
381 case PREHEADER_TOKEN_TELEGRAM_COUNT:
382 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiTelegramCount = (
UINT16) (uliDummy & 0xFFFF);
384 case PREHEADER_TOKEN_CYCLE_COUNT:
385 sscanf(fields[i],
"%hu", &uiValue);
386 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiCycleCount = (
UINT16) (uliDummy & 0xFFFF);
388 case PREHEADER_TOKEN_SYSTEM_COUNT_SCAN:
389 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.udiSystemCountScan = (
UINT32) (uliDummy & 0xFFFFFFFF);
391 case PREHEADER_TOKEN_SYSTEM_COUNT_TRANSMIT:
392 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.udiSystemCountTransmit = (
UINT32) (uliDummy & 0xFFFFFFFF);
394 case PREHEADER_TOKEN_XB_INPUTS_0:
395 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiInputs = (
UINT8) (uliDummy & 0xFF);;
396 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiInputs <<= 8;
398 case PREHEADER_TOKEN_XB_INPUTS_1:
399 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiInputs |= (
UINT8) (uliDummy & 0xFF);;
401 case PREHEADER_TOKEN_XB_OUTPUTS_0:
402 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiOutputs = (
UINT8) (uliDummy & 0xFF);;
403 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiOutputs <<= 8;
405 case PREHEADER_TOKEN_XB_OUTPUTS_1:
406 msgPtr->radarPreHeader.radarPreHeaderStatusBlock.uiOutputs |= (
UINT8) (uliDummy & 0xFF);;
408 case PREHEADER_TOKEN_CYCLE_DURATION:
409 msgPtr->radarPreHeader.radarPreHeaderMeasurementParam1Block.uiCycleDuration = (
UINT16) (uliDummy & 0xFFFF);
411 case PREHEADER_TOKEN_NOISE_LEVEL:
412 msgPtr->radarPreHeader.radarPreHeaderMeasurementParam1Block.uiNoiseLevel = (
UINT16) (uliDummy & 0xFFFF);
414 case PREHEADER_NUM_ENCODER_BLOCKS:
418 if (u16NumberOfBlock > 0)
420 msgPtr->radarPreHeader.radarPreHeaderArrayEncoderBlock.resize(u16NumberOfBlock);
422 for (
int j = 0; j < u16NumberOfBlock; j++)
425 int rowIndex = PREHEADER_NUM_ENCODER_BLOCKS + j * 2 + 1;
426 udiValue = strtoul(fields[rowIndex], NULL, 16);
427 msgPtr->radarPreHeader.radarPreHeaderArrayEncoderBlock[j].udiEncoderPos = udiValue;
428 udiValue = strtoul(fields[rowIndex + 1], NULL, 16);
429 iEncoderSpeed = (int) udiValue;
430 msgPtr->radarPreHeader.radarPreHeaderArrayEncoderBlock[j].iEncoderSpeed = iEncoderSpeed;
446 std::vector<std::string> keyWordList;
447 #define DIST1_KEYWORD "DIST1" 448 #define AZMT1_KEYWORD "AZMT1" 449 #define VRAD1_KEYWORD "VRAD1" 450 #define AMPL1_KEYWORD "AMPL1" 451 #define MODE1_KEYWORD "MODE1" 453 #define P3DX1_KEYWORD "P3DX1" 454 #define P3DY1_KEYWORD "P3DY1" 455 #define V3DX1_KEYWORD "V3DX1" 456 #define V3DY1_KEYWORD "V3DY1" 457 #define OBJLEN_KEYWORD "OBLE1" 458 #define OBJID_KEYWORD "OBID1" 460 const int RAWTARGET_LOOP = 0;
461 const int OBJECT_LOOP = 1;
466 for (
int iLoop = 0; iLoop < 2; iLoop++)
487 std::vector<int> keyWordPos;
488 std::vector<float> keyWordScale;
489 std::vector<float> keyWordScaleOffset;
490 keyWordPos.resize(keyWordList.size());
491 keyWordScale.resize(keyWordList.size());
492 keyWordScaleOffset.resize(keyWordList.size());
493 for (
int i = 0; i < keyWordPos.size(); i++)
497 int numKeyWords = keyWordPos.size();
498 for (
int i = 0; i < fields.size(); i++)
500 for (
int j = 0; j < keyWordList.size(); j++)
502 if (strcmp(fields[i], keyWordList[j].c_str()) == 0)
509 bool entriesNumOk =
true;
511 if (keyWordPos[0] == -1)
513 entriesNumOk =
false;
518 entriesNum =
getHexValue(fields[keyWordPos[0] + 3]);
519 for (
int i = 0; i < numKeyWords; i++)
521 if (keyWordPos[i] == -1)
523 entriesNumOk =
false;
524 ROS_WARN(
"Missing keyword %s but first keyword found.\n", keyWordList[i].c_str());
525 entriesNumOk =
false;
529 int entriesNumTmp =
getHexValue(fields[keyWordPos[i] + 3]);
530 if (entriesNumTmp != entriesNum)
532 ROS_WARN(
"Number of items for keyword %s differs from number of items for %s\n.",
533 keyWordList[i].c_str(), keyWordList[0].c_str());
534 entriesNumOk =
false;
540 if (
true == entriesNumOk)
544 for (
int i = 0; i < numKeyWords; i++)
546 int scaleLineIdx = keyWordPos[i] + 1;
547 int scaleOffsetLineIdx = keyWordPos[i] + 2;
548 std::string token = fields[scaleLineIdx];
550 token = fields[scaleOffsetLineIdx];
559 rawTargetList.resize(entriesNum);
564 objectList.resize(entriesNum);
568 for (
int i = 0; i < entriesNum; i++)
579 for (
int j = 0; j < numKeyWords; j++)
581 int dataRowIdx = keyWordPos[j] + 4 + i;
582 std::string token = keyWordList[j];
609 rawTargetList[i].Dist(dist);
610 rawTargetList[i].Ampl(ampl);
611 rawTargetList[i].Azimuth(azimuth);
612 rawTargetList[i].Mode(mode);
613 rawTargetList[i].Vrad(vrad);
626 for (
int j = 0; j < numKeyWords; j++)
628 int dataRowIdx = keyWordPos[j] + 4 + i;
629 std::string token = keyWordList[j];
657 objId = (int) (objIdRaw * keyWordScale[j] + 0.5);
661 objectList[i].ObjId(objId);
662 objectList[i].ObjLength(objLen);
663 objectList[i].P3Dx(px);
664 objectList[i].P3Dy(py);
665 objectList[i].V3Dx(vx);
666 objectList[i].V3Dy(vy);
680 static int callCnt = 0;
685 std::string header =
"\x2sSN LMDradardata 1 1 112F6E9 0 0 DFB6 B055 6E596002 6E5AE0E5 0 0 0 0 0 0 1 0 0 ";
687 int channel16BitCnt = 4;
689 float rawTargetFactorList[] = {40.0f, 0.16f, 0.04f, 1.00f, 1.00f};
690 float objectFactorList[] = {64.0f, 64.0f, 0.1f, 0.1f, 0.75f, 1.0f};
692 std::string dist1_intro =
"DIST1 42200000 00000000";
693 std::string azmt1_intro =
"AZMT1 3E23D70A 00000000";
694 std::string vrad1_intro =
"VRAD1 3D23D70A 00000000";
695 std::string ampl1_intro =
"AMPL1 3F800000 00000000";
697 std::string pdx1_intro =
"P3DX1 42800000 00000000";
698 std::string pdy1_intro =
"P3DY1 42800000 00000000";
699 std::string v3dx_intro =
"V3DX1 3DCCCCCD 00000000";
700 std::string v3dy_intro =
"V3DY1 3DCCCCCD 00000000";
701 std::string oblen_intro =
"OBLE1 3F400000 00000000";
703 int rawTargetChannel16BitCnt = 4;
704 int rawTargetChannel8BitCnt = 1;
705 std::string mode1_intro =
"MODE1 3F800000 00000000";
707 std::string obid_intro =
"OBID1 3F800000 00000000";
710 std::string trailer =
"0 0 0 0 0 0\x3";
712 std::vector<std::string> channel16BitID;
713 std::vector<std::string> channel8BitID;
714 channel16BitID.push_back(dist1_intro);
715 channel16BitID.push_back(azmt1_intro);
716 channel16BitID.push_back(vrad1_intro);
717 channel16BitID.push_back(ampl1_intro);
719 channel16BitID.push_back(pdx1_intro);
720 channel16BitID.push_back(pdy1_intro);
721 channel16BitID.push_back(v3dx_intro);
722 channel16BitID.push_back(v3dy_intro);
723 channel16BitID.push_back(oblen_intro);
726 channel8BitID.push_back(mode1_intro);
727 channel8BitID.push_back(obid_intro);
729 int channel8BitCnt = channel8BitID.size();
730 int objectChannel16BitCnt = 5;
731 channel16BitCnt = channel16BitID.size();
734 std::vector<SickScanRadarRawTarget> rawTargetList;
736 #if 0 // simulate railway crossing 737 for (
float y = -20;
y <= 20.0;
y += 2.0)
740 float azimuth = atan2(
y, x);
741 float dist = sqrt(x*x +
y*
y);
742 float vrad = speed * sin(azimuth);
744 float ampl = 50.0 + y;
745 rawTarget.
Ampl(ampl);
746 rawTarget.
Mode(mode);
747 rawTarget.
Dist(dist);
749 rawTarget.
Vrad(vrad);
750 rawTargetList.push_back(rawTarget);
754 std::vector<SickScanRadarObject> objectList;
757 for (
float x = 20; x <= 100.0; x += 50.0)
761 for (
int iY = -1; iY <= 1; iY += 2)
765 float vehicleWidth = 1.8;
767 float speed = y * 10.0f;
776 vehicle.
P3Dx((xOff + 0.1 * speed * (callCnt % 20)) * 1000.0);
777 vehicle.
P3Dy(y * 1000.0);
778 float objLen = 6.0f + y;
781 vehicle.
ObjId(objId++);
782 objectList.push_back(vehicle);
784 for (
int i = 0; i < 2; i++)
788 xp[i] = vehicle.
P3Dx() * 0.001;
789 yp[i] = vehicle.
P3Dy() * 0.001;
793 yp[i] -= vehicleWidth / 2.0;
797 yp[i] += vehicleWidth / 2.0;
801 xp[i] -= objLen * 0.5;
805 xp[i] += objLen * 0.5;
808 float azimuth = atan2(yp[i], xp[i]);
809 float dist = sqrt(xp[i] * xp[i] + yp[i] * yp[i]);
810 float vrad = speed * cos(azimuth);
814 rawTarget.
Ampl(ampl);
815 rawTarget.
Mode(mode);
816 rawTarget.
Dist(dist);
818 rawTarget.
Vrad(vrad);
819 rawTargetList.push_back(rawTarget);
828 char szDummy[255] = {0};
829 std::string resultStr;
831 sprintf(szDummy,
"%x ", channel16BitCnt);
832 resultStr += szDummy;
833 for (
int i = 0; i < channel16BitCnt; i++)
835 resultStr += channel16BitID[i];
836 int valNum = rawTargetList.size();
837 bool processRawTarget =
true;
838 if (i < rawTargetChannel16BitCnt)
840 valNum = rawTargetList.size();
844 processRawTarget =
false;
845 valNum = objectList.size();
848 sprintf(szDummy,
" %x ", valNum);
849 resultStr += szDummy;
851 for (
int j = 0; j < valNum; j++)
856 val = 1000.0 * rawTargetList[j].Dist();
859 val = 1.0 /
deg2rad * rawTargetList[j].Azimuth();
862 val = rawTargetList[j].Vrad();
865 val = rawTargetList[j].Ampl();
868 val = objectList[j].P3Dx();
871 val = objectList[j].P3Dy();
874 val = objectList[j].V3Dx();
877 val = objectList[j].V3Dy();
880 val = objectList[j].ObjLength();
885 if (processRawTarget)
887 val /= rawTargetFactorList[i];
891 int idx = i - rawTargetChannel16BitCnt;
892 val /= objectFactorList[idx];
903 int16_t shortVal = (int16_t) (val);
905 sprintf(szDummy,
"%08x", shortVal);
906 strcpy(szDummy, szDummy + 4);
907 resultStr += szDummy;
912 sprintf(szDummy,
"%x ", channel8BitCnt);
913 resultStr += szDummy;
914 int valNum = rawTargetList.size();
915 for (
int i = 0; i < channel8BitCnt; i++)
917 resultStr += channel8BitID[i];
919 bool processRawTarget =
true;
920 if (i < rawTargetChannel8BitCnt)
922 valNum = rawTargetList.size();
926 processRawTarget =
false;
927 valNum = objectList.size();
929 sprintf(szDummy,
" %x ", valNum);
930 resultStr += szDummy;
931 for (
int j = 0; j < valNum; j++)
936 val = rawTargetList[j].Mode();
939 val = objectList[j].ObjId();
944 if (processRawTarget)
946 offset = rawTargetChannel16BitCnt;
947 val /= rawTargetFactorList[i + offset];
951 offset = objectChannel16BitCnt;
952 int idx = i - rawTargetChannel8BitCnt;
953 val /= objectFactorList[idx + offset];
963 int8_t shortVal = (int16_t) (val);
965 sprintf(szDummy,
"%08x", shortVal);
966 strcpy(szDummy, szDummy + 6);
967 resultStr += szDummy;
972 resultStr += trailer;
974 *actual_length = resultStr.length();
975 strcpy((
char *) receiveBuffer, resultStr.c_str());
979 std::string filePattern)
981 static int callCnt = 0;
983 char szLine[1024] = {0};
984 char szDummyWord[1024] = {0};
985 int actual_length = 0;
987 char szFileName[1024] = {0};
989 receiveBuffer[0] =
'\x02';
992 for (
int iLoop = 0; iLoop < 2; iLoop++)
994 sprintf(szFileName, filePattern.c_str(), callCnt);
996 fin = fopen(szFileName,
"r");
998 if ((fin == NULL) && (iLoop == 0))
1007 if ((iLoop == 1) && (fin == NULL))
1009 ROS_ERROR(
"Can not find simulation file corresponding to pattern %s", filePattern.c_str());
1013 while (fgets(szLine, 1024, fin) != NULL)
1015 char *ptr = strchr(szLine,
'\n');;
1021 ptr = strchr(szLine,
':');
1024 if (1 == sscanf(ptr + 2,
"%s", szDummyWord))
1028 receiveBuffer[actual_length++] =
' ';
1030 strcpy((
char *) receiveBuffer + actual_length, szDummyWord);
1031 actual_length += strlen(szDummyWord);
1036 receiveBuffer[actual_length] = (char)
'\x03';
1038 receiveBuffer[actual_length] = (char)
'\x00';
1040 *pActual_length = actual_length;
1045 bool useBinaryProtocol)
1049 enum enumSimulationMode
1051 EMULATE_OFF, EMULATE_SYN, EMULATE_FROM_FILE_TRAIN, EMULATE_FROM_FILE_CAR
1054 int simulationMode = EMULATE_OFF;
1058 simulationMode = EMULATE_SYN;
1061 switch (simulationMode)
1068 case EMULATE_FROM_FILE_TRAIN:
1070 "/mnt/hgfs/development/ros/bags/raw/trainSeq/tmp%06d.txt");
1072 case EMULATE_FROM_FILE_CAR:
1074 "/mnt/hgfs/development/ros/bags/raw/carSeq/tmp%06d.txt");
1078 printf(
"Simulation Mode unknown\n");
1082 sensor_msgs::PointCloud2 cloud_;
1083 sick_scan::RadarScan radarMsg_;
1085 std::vector<SickScanRadarObject> objectList;
1086 std::vector<SickScanRadarRawTarget> rawTargetList;
1088 if (useBinaryProtocol)
1090 throw std::logic_error(
"Binary protocol currently not supported.");
1094 bool dataToProcess =
false;
1095 char *buffer_pos = (
char *) receiveBuffer;
1096 char *dstart = NULL;
1099 dstart = strchr(buffer_pos, 0x02);
1102 dend = strchr(dstart + 1, 0x03);
1104 if ((dstart != NULL) && (dend != NULL))
1106 dataToProcess =
true;
1107 dlength = dend - dstart;
1114 dataToProcess =
false;
1118 enum RADAR_PROC_LIST
1120 RADAR_PROC_RAW_TARGET, RADAR_PROC_TRACK, RADAR_PROC_NUM
1125 for (
int iLoop = 0; iLoop < RADAR_PROC_NUM; iLoop++)
1130 std::string channelRawTargetId[] = {
"x",
"y",
"z",
"vrad",
"amplitude"};
1131 std::string channelObjectId[] = {
"x",
"y",
"z",
"vx",
"vy",
"vz",
"objLen",
"objId"};
1132 std::vector<std::string> channelList;
1133 std::string frameId =
"radar";
1136 case RADAR_PROC_RAW_TARGET:
1137 numTargets = rawTargetList.size();
1138 for (
int i = 0; i <
sizeof(channelRawTargetId) /
sizeof(channelRawTargetId[0]); i++)
1140 channelList.push_back(channelRawTargetId[i]);
1144 case RADAR_PROC_TRACK:
1145 numTargets = objectList.size();
1146 for (
int i = 0; i <
sizeof(channelObjectId) /
sizeof(channelObjectId[0]); i++)
1148 channelList.push_back(channelObjectId[i]);
1153 if (numTargets == 0)
1157 int numChannels = channelList.size();
1159 std::vector<float> valSingle;
1160 valSingle.resize(numChannels);
1161 cloud_.header.stamp = timeStamp;
1162 cloud_.header.frame_id = frameId;
1163 cloud_.header.seq = 0;
1165 cloud_.width = numTargets;
1166 cloud_.is_bigendian =
false;
1167 cloud_.is_dense =
true;
1168 cloud_.point_step = numChannels *
sizeof(float);
1169 cloud_.row_step = cloud_.point_step * cloud_.width;
1170 cloud_.fields.resize(numChannels);
1171 for (
int i = 0; i < numChannels; i++)
1173 cloud_.fields[i].name = channelList[i];
1174 cloud_.fields[i].offset = i *
sizeof(float);
1175 cloud_.fields[i].count = 1;
1176 cloud_.fields[i].datatype = sensor_msgs::PointField::FLOAT32;
1179 cloud_.data.resize(cloud_.row_step * cloud_.height);
1180 float *valPtr = (
float *) (&(cloud_.data[0]));
1182 for (
int i = 0; i < numTargets; i++)
1189 valSingle[0] = rawTargetList[i].Dist() * cos(angle);
1190 valSingle[1] = rawTargetList[i].Dist() * sin(angle);
1192 valSingle[3] = rawTargetList[i].Vrad();
1193 valSingle[4] = rawTargetList[i].Ampl();
1198 valSingle[0] = objectList[i].P3Dx();
1199 valSingle[1] = objectList[i].P3Dy();
1201 valSingle[3] = objectList[i].V3Dx();
1202 valSingle[4] = objectList[i].V3Dy();
1204 valSingle[6] = objectList[i].ObjLength();
1205 valSingle[7] = objectList[i].ObjId();
1209 for (
int j = 0; j < numChannels; j++)
1211 valPtr[off] = valSingle[j];
1215 #if 1 // just for debugging 1218 case RADAR_PROC_RAW_TARGET:
1221 case RADAR_PROC_TRACK:
1227 printf(
"PUBLISH:\n");
1229 if (iLoop == RADAR_PROC_RAW_TARGET)
1232 radarMsg_.targets = cloud_;
1239 radarMsg_.header.stamp = timeStamp;
1240 radarMsg_.header.frame_id =
"radar";
1241 radarMsg_.header.seq = 0;
1243 radarMsg_.objects.resize(objectList.size());
1244 for (
int i = 0; i < radarMsg_.objects.size(); i++)
1246 float vx = objectList[i].V3Dx();
1247 float vy = objectList[i].V3Dy();
1248 float v = sqrt(vx * vx + vy * vy);
1249 float heading = atan2(objectList[i].V3Dy(), objectList[i].V3Dx());
1251 radarMsg_.objects[i].velocity.twist.linear.x = objectList[i].V3Dx();
1252 radarMsg_.objects[i].velocity.twist.linear.y = objectList[i].V3Dy();
1253 radarMsg_.objects[i].velocity.twist.linear.z = 0.0;
1255 radarMsg_.objects[i].bounding_box_center.position.x = objectList[i].P3Dx();
1256 radarMsg_.objects[i].bounding_box_center.position.y = objectList[i].P3Dy();
1257 radarMsg_.objects[i].bounding_box_center.position.z = 0.0;
1259 float heading2 = heading / 2.0;
1263 radarMsg_.objects[i].bounding_box_center.orientation.x = 0.0;
1264 radarMsg_.objects[i].bounding_box_center.orientation.y = 0.0;
1265 radarMsg_.objects[i].bounding_box_center.orientation.z = sin(heading2);
1266 radarMsg_.objects[i].bounding_box_center.orientation.w = cos(heading2);
1269 radarMsg_.objects[i].bounding_box_size.x = objectList[i].ObjLength();
1270 radarMsg_.objects[i].bounding_box_size.y = 1.7;
1271 radarMsg_.objects[i].bounding_box_size.z = 1.7;
1272 for (
int ii = 0; ii < 6; ii++)
1274 int mainDiagOffset = ii * 6 + ii;
1275 radarMsg_.objects[i].object_box_center.covariance[mainDiagOffset] = 1.0;
1276 radarMsg_.objects[i].velocity.covariance[mainDiagOffset] = 1.0;
1278 radarMsg_.objects[i].object_box_center.pose = radarMsg_.objects[i].bounding_box_center;
1279 radarMsg_.objects[i].object_box_size = radarMsg_.objects[i].bounding_box_size;
ros::Publisher cloud_radar_rawtarget_pub_
int parseAsciiDatagram(char *datagram, size_t datagram_length, sick_scan::RadarScan *msgPtr, std::vector< SickScanRadarObject > &objectList, std::vector< SickScanRadarRawTarget > &rawTargetList)
Parsing Ascii datagram.
void publish(const boost::shared_ptr< M > &message) const
static SickScanRadarSingleton * instance
ros::Publisher radarScan_pub_
void simulateAsciiDatagramFromFile(unsigned char *receiveBuffer, int *actual_length, std::string filePattern)
float convertScaledIntValue(int value, float scale, float offset)
TFSIMD_FORCE_INLINE const tfScalar & y() const
ros::Publisher cloud_radar_track_pub_
int getHexValue(std::string str)
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
int parseDatagram(ros::Time timeStamp, unsigned char *receiveBuffer, int actual_length, bool useBinaryProtocol)
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static SickScanRadarSingleton * getInstance()
void setEmulation(bool _emul)
bool getParam(const std::string &key, std::string &s) const
float getFloatValue(std::string str)
int16_t getShortValue(std::string str)
void simulateAsciiDatagram(unsigned char *receiveBuffer, int *actual_length)