ros_parser_base.h
Go to the documentation of this file.
1 #ifndef ROS_MESSAGEPARSER_H
2 #define ROS_MESSAGEPARSER_H
3 
5 #include <ros/types.h>
6 #include <ros/serialization.h>
9 #include <std_msgs/Header.h>
10 
11 
13 {
14 public:
15 
16  void setUseHeaderStamp( bool use )
17  {
18  _use_header_stamp = use;
19  }
20 
21 protected:
23 
24 };
25 
26 template <typename MainType, typename SubType, class ChildParser>
28 {
29 public:
30  RosMessageStampedParser( const char* child_prefix):
31  _child_prefix(child_prefix)
32  {
33  _data.emplace_back( "/header/seq" );
34  _data.emplace_back( "/header/stamp" );
35  }
36 
37 
38  const std::unordered_set<std::string>& getCompatibleKeys() const override
39  {
40  static std::unordered_set<std::string> compatible_key =
42  return compatible_key;
43  }
44 
45  virtual void pushMessageRef(const std::string& key,
46  const MessageRef& buffer,
47  double timestamp) override
48  {
49  std_msgs::Header header;
50  ros::serialization::IStream is( const_cast<uint8_t*>(buffer.data()), buffer.size() );
52 
53  size_t header_size = sizeof( ros::Time ) + 8 + header.frame_id.size();
54 
55  _data[0].pushBack( {timestamp, header.seq} );
56  _data[1].pushBack( {timestamp, header.stamp.toSec()} );
57 
58  MessageRef sub_buffer( buffer.data(), header_size);
59 
60  _child_parser.pushMessageRef( key, sub_buffer, timestamp );
61  }
62 
63  void extractData(PlotDataMapRef& plot_map, const std::string& prefix) override
64  {
65  for (auto& it: _data)
66  {
67  MessageParser::appendData(plot_map, prefix + it.name(), it);
68  }
69  _child_parser.extractData(plot_map, prefix + _child_prefix);
70  }
71 private:
72  std::vector<PlotData> _data;
73  ChildParser _child_parser;
74  std::string _child_prefix;
75 
76 };
77 
78 
79 
80 #endif // ROS_MESSAGEPARSER_H
size_t size() const
std::vector< PlotData > _data
const std::unordered_set< std::string > & getCompatibleKeys() const override
void extractData(PlotDataMapRef &plot_map, const std::string &prefix) override
const uint8_t * data() const
static const char * value()
RosMessageStampedParser(const char *child_prefix)
virtual void pushMessageRef(const std::string &key, const MessageRef &buffer, double timestamp) override
static void appendData(PlotDataMapRef &destination_plot_map, const std::string &field_name, PlotData &in_data)
struct absl::base_internal::@37::AllocList::Header header
void deserialize(Stream &stream, T &t)
The MessageParser is the base class to create plugins that are able to parse one or multiple Message ...
void setUseHeaderStamp(bool use)


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:18