Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Dec 12, 2023
1 parent 7b4ed81 commit 23f7e46
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plotjuggler_plugins/DataLoadMCAP/dialog_mcap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void DialogMCAP::accept()

settings.setValue(prefix + "clamp", clamp_checked);
settings.setValue(prefix + "max_array", max_array);
settings.setValue(prefix + "use_timestamp", max_array);
settings.setValue(prefix + "use_timestamp", use_timestamp);

QItemSelectionModel* select = ui->tableWidget->selectionModel();
QStringList selected_topics;
Expand Down
11 changes: 7 additions & 4 deletions plotjuggler_plugins/ParserROS/ros_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ bool ParserROS::parseMessage(const PJ::MessageRef serialized_msg, double& timest

if(_has_header && this->useEmbeddedTimestamp())
{
double ts = 0;
if(_deserializer->isROS2())
{
auto sec = _flat_msg.value[0].second.convert<double>();
auto nsec = _flat_msg.value[1].second.convert<double>();
timestamp = sec + 1e-9*nsec;
ts = sec + 1e-9*nsec;
}
else {
auto sec = _flat_msg.value[1].second.convert<double>();
auto nsec = _flat_msg.value[2].second.convert<double>();
timestamp = sec + 1e-9*nsec;
ts = sec + 1e-9*nsec;
}
timestamp = (ts > 0) ? ts : timestamp;
}

std::string series_name;
Expand Down Expand Up @@ -150,9 +152,10 @@ Msg::Header ParserROS::readHeader(double& timestamp)
header.stamp.sec = _deserializer->deserializeUInt32();
header.stamp.nanosec = _deserializer->deserializeUInt32();

if (useEmbeddedTimestamp())
const double ts = header.stamp.toSec();
if (useEmbeddedTimestamp() && ts > 0)
{
timestamp = double(header.stamp.sec) + 1e-9 * double(header.stamp.nanosec);
timestamp = ts;
}
_deserializer->deserializeString(header.frame_id);

Expand Down
2 changes: 1 addition & 1 deletion plotjuggler_plugins/ParserROS/special_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct Time

double toSec() const
{
return double(sec) + double(nanosec)*1e-9;
return double(sec) + double(nanosec)*1e-9;
}
};

Expand Down

0 comments on commit 23f7e46

Please sign in to comment.