Skip to content

Commit d802b84

Browse files
authored
Fix non-responsive node on packet timeout (#466)
* No abort on packet timeout Changed getPacket() to return 0 on timeout and 1 on success. * Removed trailing whitespace
1 parent 30bc444 commit d802b84

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

velodyne_driver/src/driver/driver.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ bool VelodyneDriver::poll(void)
220220
while(true)
221221
{
222222
int rc = input_->getPacket(&tmp_packet, config_.time_offset);
223-
if (rc == 0) break; // got a full packet?
223+
if (rc == 1) break; // got a full packet?
224224
if (rc < 0) return false; // end of file reached?
225+
if (rc == 0) continue; //timeout?
225226
}
226227
scan->packets.push_back(tmp_packet);
227228

@@ -255,8 +256,9 @@ bool VelodyneDriver::poll(void)
255256
{
256257
// keep reading until full packet received
257258
int rc = input_->getPacket(&scan->packets[i], config_.time_offset);
258-
if (rc == 0) break; // got a full packet?
259+
if (rc == 1) break; // got a full packet?
259260
if (rc < 0) return false; // end of file reached?
261+
if (rc == 0) continue; //timeout?
260262
}
261263
}
262264
}

velodyne_driver/src/lib/input.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ namespace velodyne_driver
189189
if (retval == 0) // poll() timeout?
190190
{
191191
ROS_WARN("Velodyne poll() timeout");
192-
return -1;
192+
return 0;
193193
}
194194
if ((fds[0].revents & POLLERR)
195195
|| (fds[0].revents & POLLHUP)
@@ -243,7 +243,7 @@ namespace velodyne_driver
243243
pkt->stamp = rosTimeFromGpsTimestamp(&(pkt->data[1200]));
244244
}
245245

246-
return 0;
246+
return 1;
247247
}
248248

249249
////////////////////////////////////////////////////////////////////////
@@ -339,7 +339,7 @@ namespace velodyne_driver
339339
pkt->stamp = rosTimeFromGpsTimestamp(&(pkt->data[1200]), header);
340340
}
341341
empty_ = false;
342-
return 0; // success
342+
return 1; // success
343343
}
344344

345345
if (empty_) // no data in file?

0 commit comments

Comments
 (0)