Skip to content

Commit

Permalink
Fix check for header first in rosbag play for rate control topic (#1352)
Browse files Browse the repository at this point in the history
* Skip empty lines

* Only check 'Header ' is at the beginning

This allows to support sensor_msgs/Image, which has a comment after.
Also note we only need to check for the type, not the name of the field.

* Break while loop after first field.
  • Loading branch information
Enrique Fernández Perdomo authored and dirk-thomas committed Mar 21, 2018
1 parent 1fa062c commit 2c8a3f6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/rosbag/src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,12 @@ void Player::updateRateTopicTime(const ros::MessageEvent<topic_tools::ShapeShift
std::string s;
bool flag = false;
while(std::getline(f, s, '\n')) {
if (s.find("#") != 0) {
if (!s.empty() && s.find("#") != 0) {
// Does not start with #, is not a comment.
if(s == "Header header") {
if (s.find("Header ") == 0) {
flag = true;
}
break;
}
}
// If the header is not the first element in the message according to the definition, throw an error.
Expand Down

0 comments on commit 2c8a3f6

Please sign in to comment.