ros_parser.h
Go to the documentation of this file.
1 #ifndef ROS_PARSER_H
2 #define ROS_PARSER_H
3 
7 #include "special_messages.h"
8 
10 {
11 public:
12  ParserROS(const std::string& topic_name, const std::string& type_name,
13  const std::string& schema, RosMsgParser::Deserializer* deserializer,
15 
16  bool parseMessage(const PJ::MessageRef serialized_msg, double& timestamp) override;
17 
18  void setLargeArraysPolicy(bool clamp, unsigned max_size) override;
19 
21  {
23  }
24 
25 protected:
27  std::unique_ptr<RosMsgParser::Deserializer> _deserializer;
29  std::string _topic;
30 
31  PJ::Msg::Header readHeader(double& timestamp);
32  void parseHeader(const std::string& prefix, double& timestamp);
33  void parseEmpty(const std::string& prefix, double& timestamp);
34 
35  template <size_t N>
36  void parseCovariance(const std::string& prefix, double& timestamp);
37 
38  void parseVector3(const std::string& prefix, double& timestamp);
39  void parsePoint(const std::string& prefix, double& timestamp);
40  void parseQuaternion(const std::string& prefix, double& timestamp);
41 
42  void parseTwist(const std::string& prefix, double& timestamp);
43  void parseTwistWithCovariance(const std::string& prefix, double& timestamp);
44 
45  void parseTransform(const std::string& prefix, double& timestamp);
46  void parseTransformStamped(const std::string& prefix, double& timestamp);
47 
48  void parsePose(const std::string& prefix, double& timestamp);
49  void parsePoseStamped(const std::string& prefix, double& timestamp);
50  void parsePoseWithCovariance(const std::string& prefix, double& timestamp);
51 
52  void parseImu(const std::string& prefix, double& timestamp);
53  void parseOdometry(const std::string& prefix, double& timestamp);
54 
55  void parseDiagnosticMsg(const std::string& prefix, double& timestamp);
56  void parseJointStateMsg(const std::string& prefix, double& timestamp);
57  void parseTF2Msg(const std::string& prefix, double& timestamp);
58 
59  void parseDataTamerSchemas(const std::string& prefix, double& timestamp);
60  void parseDataTamerSnapshot(const std::string& prefix, double& timestamp);
61 
62  void parsePalStatisticsNames(const std::string& prefix, double& timestamp);
63  void parsePalStatisticsValues(const std::string& prefix, double& timestamp);
64 
65  std::function<void(const std::string& prefix, double&)> _customized_parser;
66 
67  bool _has_header = false;
69 };
70 
71 template <size_t N>
72 inline void ParserROS::parseCovariance(const std::string& prefix, double& timestamp)
73 {
74  std::array<double, N * N> cov;
75  for (auto& val : cov)
76  {
77  val = _deserializer->deserialize(RosMsgParser::FLOAT64).convert<double>();
78  }
79  for (int i = 0; i < N; i++)
80  {
81  for (int j = i; j < N; j++)
82  {
83  const size_t index = i * N + j;
84  getSeries(fmt::format("{}/[{};{}]", prefix, i, j))
85  .pushBack({ timestamp, cov[index] });
86  }
87  }
88 }
89 
90 #endif // ROS_PARSER_H
ParserROS::_strict_truncation_check
bool _strict_truncation_check
Definition: ros_parser.h:68
ParserROS::parseTwistWithCovariance
void parseTwistWithCovariance(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:261
ParserROS::parseEmpty
void parseEmpty(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:212
RosMsgParser::Parser
Definition: ros_parser.hpp:51
ParserROS::parsePalStatisticsNames
void parsePalStatisticsNames(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:542
PJ::TimeseriesBase::pushBack
void pushBack(const Point &p) override
Definition: timeseries.h:61
sol::type_name
std::string type_name(lua_State *L, type t)
Definition: sol.hpp:8079
ParserROS::_deserializer
std::unique_ptr< RosMsgParser::Deserializer > _deserializer
Definition: ros_parser.h:27
ParserROS::parseTransformStamped
void parseTransformStamped(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:273
ParserROS::_customized_parser
std::function< void(const std::string &prefix, double &)> _customized_parser
Definition: ros_parser.h:65
ParserROS::readHeader
PJ::Msg::Header readHeader(double &timestamp)
Definition: ros_parser.cpp:178
ParserROS::parseJointStateMsg
void parseJointStateMsg(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:389
ParserROS
Definition: ros_parser.h:9
RosMsgParser::FLOAT64
@ FLOAT64
Definition: builtin_types.hpp:57
ParserROS::setLargeArraysPolicy
void setLargeArraysPolicy(bool clamp, unsigned max_size) override
Definition: ros_parser.cpp:167
ParserROS::parseDiagnosticMsg
void parseDiagnosticMsg(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:326
ParserROS::parseMessage
bool parseMessage(const PJ::MessageRef serialized_msg, double &timestamp) override
Definition: ros_parser.cpp:93
PJ::MessageParser
The MessageParser is the base class used to parse a message with a specific encoding+schema.
Definition: messageparser_base.h:75
ParserROS::parseImu
void parseImu(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:302
PJ::MessageParser::getSeries
PlotData & getSeries(const std::string &key)
Definition: messageparser_base.h:120
ros_parser.hpp
nlohmann::detail::void
j template void())
Definition: json.hpp:4061
special_messages.h
sol::meta::enable
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
ParserROS::parsePose
void parsePose(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:284
ParserROS::_topic
std::string _topic
Definition: ros_parser.h:29
ParserROS::parseHeader
void parseHeader(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:200
ParserROS::parseCovariance
void parseCovariance(const std::string &prefix, double &timestamp)
Definition: ros_parser.h:72
ParserROS::parseTransform
void parseTransform(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:267
format
auto format(const text_style &ts, const S &format_str, const Args &... args) -> std::basic_string< Char >
Definition: color.h:543
ParserROS::parseDataTamerSnapshot
void parseDataTamerSnapshot(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:506
RosMsgParser::Deserializer
Definition: deserializer.hpp:20
ParserROS::_parser
RosMsgParser::Parser _parser
Definition: ros_parser.h:26
ParserROS::enableTruncationCheck
void enableTruncationCheck(bool enable)
Definition: ros_parser.h:20
ParserROS::parseTF2Msg
void parseTF2Msg(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:459
ParserROS::parsePoseStamped
void parsePoseStamped(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:290
PJ::MessageRef
Definition: messageparser_base.h:28
core.h
ParserROS::parseOdometry
void parseOdometry(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:316
ParserROS::parseQuaternion
void parseQuaternion(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:237
mqtt_test.data
dictionary data
Definition: mqtt_test.py:22
ParserROS::parseVector3
void parseVector3(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:217
PJ::PlotDataMapRef
Definition: plotdata.h:34
ParserROS::parsePoint
void parsePoint(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:227
ParserROS::parseTwist
void parseTwist(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:255
PJ::Msg::Header
Definition: special_messages.h:25
ParserROS::ParserROS
ParserROS(const std::string &topic_name, const std::string &type_name, const std::string &schema, RosMsgParser::Deserializer *deserializer, PJ::PlotDataMapRef &data)
Definition: ros_parser.cpp:13
ParserROS::parsePalStatisticsValues
void parsePalStatisticsValues(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:556
ParserROS::_flat_msg
RosMsgParser::FlatMessage _flat_msg
Definition: ros_parser.h:28
messageparser_base.h
ParserROS::_has_header
bool _has_header
Definition: ros_parser.h:67
ParserROS::parsePoseWithCovariance
void parsePoseWithCovariance(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:296
ParserROS::parseDataTamerSchemas
void parseDataTamerSchemas(const std::string &prefix, double &timestamp)
Definition: ros_parser.cpp:487
RosMsgParser::FlatMessage
Definition: ros_parser.hpp:33


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46