diff --git a/plotjuggler_plugins/ParserROS/ros_parser.cpp b/plotjuggler_plugins/ParserROS/ros_parser.cpp index 124fda319..2e5a61629 100644 --- a/plotjuggler_plugins/ParserROS/ros_parser.cpp +++ b/plotjuggler_plugins/ParserROS/ros_parser.cpp @@ -22,7 +22,9 @@ ParserROS::ParserROS(const std::string& topic_name, const std::string& type_name clampLargeArray() ? Parser::KEEP_LARGE_ARRAYS : Parser::DISCARD_LARGE_ARRAYS; _parser.setMaxArrayPolicy(policy, maxArraySize()); - _has_header = _parser.getSchema()->root_msg->field(0).type().baseName() == "std_msgs/Header"; + + const auto& root_fields = _parser.getSchema()->root_msg->fields(); + _has_header = !root_fields.empty() && root_fields.front().type().baseName() == "std_msgs/Header"; using std::placeholders::_1; using std::placeholders::_2; diff --git a/plotjuggler_plugins/ParserROS/ros_parser.h b/plotjuggler_plugins/ParserROS/ros_parser.h index 5eada987d..992b28aee 100644 --- a/plotjuggler_plugins/ParserROS/ros_parser.h +++ b/plotjuggler_plugins/ParserROS/ros_parser.h @@ -19,7 +19,7 @@ class ParserROS : public PJ::MessageParser protected: RosMsgParser::Parser _parser; - std::shared_ptr _deserializer; + std::unique_ptr _deserializer; RosMsgParser::FlatMessage _flat_msg; std::string _topic;