Skip to content

Commit 284f8b8

Browse files
Merge branch 'dev' into 'master'
V1.0.37 fix bug in calculate lidar work mode See merge request SoftwareTeam/GeneralSoftware/HesaiLidar_Swift_ROS!71
2 parents 9114ca3 + 04dabd6 commit 284f8b8

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Developed based on [HesaiLidar_Swift_SDK](https://github.com/HesaiTechnology/Hes
99
```
1010
* master: Pandar LiDAR ROS driver for Ubuntu 18.04 and Ubuntu20.04 supports the latest UDP protocol v1.4 v1.3 and v3.2
1111
* UDP1.4_ubuntu16.04: Pandar LiDAR ROS driver for Ubuntu 16.04 supports the latest UDP protocol v1.4
12-
* UDP1.3: Pandar LiDAR ROS driver for ubuntu16.04,ubuntu 18.04 and Ubuntu 20.04 supports UDP protocol v1.3
12+
* UDP4.3: Pandar LiDAR ROS driver for Ubuntu 16.04/Ubuntu 18.04/Ubuntu 20.04 supports the latest UDP protocol v4.3
1313
1414
To get the UDP protocol version number of your device, check the UDP package header field.
1515
```

change notes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,12 @@ PandarSwiftROS_1.0.36
146146
##modify
147147
1. Support multicast
148148

149+
Wednesday December 14th, 2022 17:30
150+
##version
151+
PandarSwiftROS_1.0.37
152+
153+
##modify
154+
1. Support save pcd
155+
149156

150157

pandar_pointcloud/src/conversions/convert.cc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Convert::Convert(ros::NodeHandle node, ros::NodeHandle private_nh,
8686
: data_(new pandar_rawdata::RawData()),
8787
drv(node, private_nh, node_type, this) {
8888

89-
m_sRosVersion = "PandarSwiftROS_1.0.36";
89+
m_sRosVersion = "PandarSwiftROS_1.0.37";
9090
ROS_WARN("--------PandarSwift ROS version: %s--------\n\n",m_sRosVersion.c_str());
9191

9292
publishmodel = "";
@@ -344,7 +344,7 @@ int Convert::loadChannelConfigFile(std::string channel_config_content){
344344
m_PandarQTChannelConfig.m_u8MinVersion = std::stoi(versionLine[2].c_str());
345345
}
346346
else{
347-
std::cout << "channel config file delimiter is wrong" << versionLine[0];
347+
std::cout << "channel config file delimiter is wrong" << versionLine[0] << std::endl;
348348
return -1;
349349
}
350350
std::getline(ifs, line);
@@ -366,13 +366,17 @@ int Convert::loadChannelConfigFile(std::string channel_config_content){
366366
std::getline(ifs, line);
367367
std::vector<std::string> ChannelLine;
368368
boost::split(ChannelLine, line, boost::is_any_of(","));
369+
if (ChannelLine.size() != loop_num) {
370+
std::cout << "channel config file format is wrong" << std::endl;
371+
return -1;
372+
}
369373
for(int j = 0; j < loop_num; j++){
370374
if(ChannelLine.size() == loop_num){
371375
m_PandarQTChannelConfig.m_vChannelConfigTable[j][i] = std::stoi(ChannelLine[j].c_str());
372376
// printf("%d %d \n",i, m_PandarQTChannelConfig.m_vChannelConfigTable[j][i]);
373377
}
374378
else{
375-
std::cout << "loop num is not equal to the first channel line";
379+
std::cout << "loop num is not equal to the first channel line" << std::endl;
376380
return -1;
377381
}
378382

@@ -772,7 +776,7 @@ void Convert::init() {
772776
PANDAR128_AZIMUTH_SIZE * header->u8BlockNum +
773777
PANDAR128_CRC_SIZE +
774778
(header->hasFunctionSafety()? PANDAR128_FUNCTION_SAFETY_SIZE : 0));
775-
m_iWorkMode = tail->nShutdownFlag & 0x03;
779+
m_iWorkMode = tail->getOperationMode();
776780
m_iReturnMode = tail->nReturnMode;
777781
drv.setUdpVersion(m_u8UdpVersionMajor, m_u8UdpVersionMinor);
778782
lidarmotorspeed = tail->nMotorSpeed;
@@ -953,7 +957,7 @@ int Convert::checkLiadaMode() {
953957
PANDAR128_AZIMUTH_SIZE * header->u8BlockNum +
954958
PANDAR128_CRC_SIZE +
955959
(header->hasFunctionSafety()? PANDAR128_FUNCTION_SAFETY_SIZE : 0));
956-
lidarworkmode = tail->nShutdownFlag & 0x03;
960+
lidarworkmode = tail->getOperationMode();
957961
lidarreturnmode = tail->nReturnMode;
958962
lidarmotorspeed = tail->nMotorSpeed;
959963
laserNum = header->u8LaserNum;
@@ -1221,9 +1225,8 @@ void Convert::calcPointXYZIT(pandar_msgs::PandarPacket &packet, int cursor) {
12211225
// ROS_WARN("#####block.fAzimuth[%u]",u16Azimuth);
12221226
index += PANDAR128_AZIMUTH_SIZE;
12231227

1224-
int mode = tail->nShutdownFlag & 0x03;
1225-
int state = (tail->nShutdownFlag & 0xF0) >> 4;
1226-
1228+
int mode = tail->getOperationMode();
1229+
int state = tail->getAngleState(blockid);
12271230
for (int i = 0; i < header->u8LaserNum; i++) {
12281231
/* for all the units in a block */
12291232
uint16_t u16Distance = *(uint16_t*)(&packet.data[0] + index);
@@ -1343,7 +1346,7 @@ void Convert::calcQT128PointXYZIT(pandar_msgs::PandarPacket &packet, int cursor)
13431346
int index = 0;
13441347
index += PANDAR128_HEAD_SIZE;
13451348
for (int blockid = 0; blockid < header->u8BlockNum; blockid++) {
1346-
int loopIndex = blockid;
1349+
int loopIndex = (tail->nModeFlag + (blockid / ((tail->nReturnMode < 0x39) ? 1 : 2)) + 1) % header->u8BlockNum;
13471350
if((isSelfDefine && m_PandarQTChannelConfig.m_bIsChannelConfigObtained)){
13481351
loopIndex = (tail->nModeFlag + (blockid / ((tail->nReturnMode < 0x39) ? 1 : 2)) + 1) % m_PandarQTChannelConfig.m_vChannelConfigTable.size();
13491352
}

pandar_pointcloud/src/conversions/convert.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ typedef struct __attribute__((__packed__)) Pandar128TailVersion14_s {
235235
uint32_t nTimestamp;
236236
uint8_t nFactoryInfo;
237237
uint32_t nSeqNum;
238+
inline uint8_t getAngleState(int blockIndex) const {
239+
return (nAzimuthFlag >> (2 * (7 - blockIndex))) & 0x03;
240+
}
241+
inline uint8_t getOperationMode() const { return nShutdownFlag & 0x0f; }
238242
} Pandar128TailVersion14;
239243

240244
typedef struct __attribute__((__packed__)) PandarQT128Tail_s {
@@ -250,6 +254,10 @@ typedef struct __attribute__((__packed__)) PandarQT128Tail_s {
250254
uint32_t nTimestamp;
251255
uint8_t nFactoryInfo;
252256
uint32_t nSeqNum;
257+
inline uint8_t getAngleState(int blockIndex) const {
258+
return (nAzimuthFlag >> (2 * (7 - blockIndex))) & 0x03;
259+
}
260+
inline uint8_t getOperationMode() const { return nShutdownFlag & 0x0f; }
253261
} PandarQT128Tail;
254262

255263
typedef struct __attribute__((__packed__)) Pandar128PacketVersion13_t {
@@ -323,6 +331,13 @@ typedef struct PacketsBuffer_s {
323331
lastOverflowed = false;
324332
ROS_WARN("buffer recovered");
325333
}
334+
if(((m_iterPush > m_iterTaskEnd) && (m_iterPush - m_iterTaskEnd) > 4 * m_stepSize) ||
335+
((m_iterPush < m_iterTaskBegin) && (m_iterTaskBegin - m_iterPush) < CIRCLE - 4 * m_stepSize)){
336+
337+
while((((m_iterPush > m_iterTaskEnd) && (m_iterPush - m_iterTaskEnd) > 4 * m_stepSize) ||
338+
((m_iterPush < m_iterTaskBegin) && (m_iterTaskBegin - m_iterPush) < CIRCLE - 4 * m_stepSize)))
339+
usleep(1000);
340+
}
326341
*(m_iterPush++) = pkt;
327342
return 1;
328343
}

0 commit comments

Comments
 (0)