18 , _deserializer(deserializer)
22 clampLargeArray() ? Parser::KEEP_LARGE_ARRAYS : Parser::DISCARD_LARGE_ARRAYS;
27 _has_header = !root_fields.empty() && root_fields.front().type().baseName() ==
"std_"
31 using std::placeholders::_1;
32 using std::placeholders::_2;
37 else if (Msg::DiagnosticArray::id() ==
type_name)
41 else if (Msg::JointState::id() ==
type_name)
45 else if (Msg::TFMessage::id() ==
type_name)
49 else if (Msg::DataTamerSchemas::id() ==
type_name)
53 else if (Msg::DataTamerSnapshot::id() ==
type_name)
65 else if (Msg::PoseStamped::id() ==
type_name)
69 else if (Msg::Odometry::id() ==
type_name)
73 else if (Msg::Transform::id() ==
type_name)
77 else if (Msg::TransformStamped::id() ==
type_name)
81 else if (Msg::PalStatisticsNames::id() ==
type_name ||
type_name ==
"plotjuggler_msgs/"
86 else if (Msg::PalStatisticsValues::id() ==
type_name ||
type_name ==
"plotjuggler_msgs/"
112 ts = sec + 1e-9 * nsec;
118 timestamp = (ts > 0) ? ts : timestamp;
121 std::string series_name;
125 key.toStr(series_name);
127 data.pushBack({ timestamp, str });
132 key.toStr(series_name);
140 data.pushBack({ timestamp, double(value.convert<int64_t>()) });
145 data.pushBack({ timestamp, double(value.convert<uint64_t>()) });
151 data.pushBack({ timestamp, value.convert<
double>() });
155 std::string
msg = std::string(ex.
what());
156 if (
msg ==
"Floating point truncated")
158 msg +=
".\n\nYou can disable this check in:\n"
159 "App -> Preferences... -> Behavior -> Parsing";
161 throw std::runtime_error(
msg);
173 MessageParser::setLargeArraysPolicy(clamp, max_size);
190 const double ts =
header.stamp.toSec();
264 parseCovariance<6>(prefix +
"/covariance", timestamp);
269 parsePoint(prefix +
"/translation", timestamp);
277 std::string child_frame_id;
299 parseCovariance<6>(prefix +
"/covariance", timestamp);
307 parseCovariance<3>(prefix +
"/orientation_covariance", timestamp);
310 parseCovariance<3>(prefix +
"/angular_velocity_covariance", timestamp);
312 parseVector3(prefix +
"/linear_acceleration", timestamp);
313 parseCovariance<3>(prefix +
"/linear_acceleration_covariance", timestamp);
319 std::string child_frame_id;
333 msg.status.resize(status_count);
335 for (
size_t st = 0; st < status_count; st++)
337 auto& status =
msg.status[st];
343 status.key_value.clear();
347 std::string value_str;
348 for (
size_t kv = 0; kv < key_value_count; kv++)
352 status.key_value.push_back({ key, value_str });
358 std::string series_name;
360 for (
const auto& status :
msg.status)
362 for (
const auto& kv : status.key_value)
364 if (status.hardware_id.empty())
366 series_name =
fmt::format(
"{}/{}/{}", prefix, status.name, kv.first);
371 fmt::format(
"{}/{}/{}/{}", prefix, status.hardware_id, status.name, kv.first);
375 double value = QString::fromStdString(kv.second).toDouble(&
ok);
394 msg.position.clear();
395 msg.velocity.clear();
403 msg.name.resize(name_size);
404 for (
auto& name :
msg.name)
414 msg.position.resize(pos_size);
415 for (
auto& pos :
msg.position)
424 msg.velocity.resize(vel_size);
425 for (
auto& vel :
msg.velocity)
434 msg.effort.resize(eff_size);
435 for (
auto& eff :
msg.effort)
441 std::string series_name;
442 for (
size_t i = 0; i < std::min(name_size, pos_size); i++)
447 for (
size_t i = 0; i < std::min(name_size, vel_size); i++)
452 for (
size_t i = 0; i < std::min(name_size, eff_size); i++)
461 const size_t transform_size =
_deserializer->deserializeUInt32();
463 if (transform_size == 0)
468 for (
size_t i = 0; i < transform_size; i++)
471 std::string child_frame_id;
474 std::string new_prefix;
475 if (
header.frame_id.empty())
477 new_prefix =
fmt::format(
"{}/{}", prefix, child_frame_id);
489 const size_t vector_size =
_deserializer->deserializeUInt32();
491 for (
size_t i = 0; i < vector_size; i++)
495 std::string channel_name;
497 std::string schema_text;
501 dt_schema.channel_name = channel_name;
519 snapshot.
payload = { payload.
data(), payload.size() };
526 const auto& dt_schema = it->second;
528 const auto toDouble = [](
const auto& value) {
return static_cast<double>(value); };
530 auto callback = [&](
const std::string& name_field,
532 double timestamp = double(snapshot.
timestamp) * 1e-9;
545 std::vector<std::string> names;
546 const size_t vector_size =
_deserializer->deserializeUInt32();
547 names.resize(vector_size);
548 for (
auto& name : names)
559 std::vector<double> values;
560 const size_t vector_size =
_deserializer->deserializeUInt32();
561 values.resize(vector_size);
563 for (
auto& value : values)
571 const auto& names = it->second;
572 const size_t N = std::min(names.size(), values.size());
573 for (
size_t i = 0; i < N; i++)
576 series.pushBack({ timestamp, values[i] });