rosbag_content.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include <string>
7 
8 #include "../../third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/bag.h"
9 #include "../../third-party/realsense-file/rosbag/rosbag_storage/include/rosbag/view.h"
10 
11 #include "print_helpers.h"
12 
13 namespace rosbag_inspector
14 {
16  {
18  compression_info(const std::tuple<std::string, uint64_t, uint64_t>& t)
19  {
20  compression_type = std::get<0>(t);
21  compressed = std::get<1>(t);
22  uncompressed = std::get<2>(t);
23  }
27  };
28 
30  {
32  {
33  bag.open(file);
34 
35  rosbag::View entire_bag_view(bag);
36 
37  for (auto&& m : entire_bag_view)
38  {
39  topics_to_message_types[m.getTopic()].push_back(m.getDataType());
40  }
41 
42  path = bag.getFileName();
43  for (auto rit = path.rbegin(); rit != path.rend(); ++rit)
44  {
45  if (*rit == '\\' || *rit == '/')
46  break;
47  file_name += *rit;
48  }
49  std::reverse(file_name.begin(), file_name.end());
50 
51  version = tmpstringstream() << bag.getMajorVersion() << "." << bag.getMinorVersion();
52  file_duration = get_duration(bag);
53  size = 1.0 * bag.getSize() / (1024LL * 1024LL);
54  compression_info = bag.getCompressionInfo();
55  }
56 
58  {
59  bag.open(other.path);
60  cache = other.cache;
61  file_duration = other.file_duration;
62  file_name = other.file_name;
63  path = other.path;
64  version = other.version;
65  size = other.size;
67  topics_to_message_types = other.topics_to_message_types;
68  }
70  {
71  other.bag.close();
72  bag.open(other.path);
73  cache = other.cache;
74  file_duration = other.file_duration;
75  file_name = other.file_name;
76  path = other.path;
77  version = other.version;
78  size = other.size;
80  topics_to_message_types = other.topics_to_message_types;
81 
82  other.cache.clear();
83  other.file_duration = std::chrono::nanoseconds::zero();
84  other.file_name.clear();
85  other.path.clear();
86  other.version.clear();
87  other.size = 0;
88  other.compression_info.compressed = 0;
89  other.compression_info.uncompressed = 0;
90  other.compression_info.compression_type = "";
91  other.topics_to_message_types.clear();
92  }
94  {
95  auto key = std::make_tuple(m.getCallerId(), m.getDataType(), m.getMD5Sum(), m.getTopic(), m.getTime(), count);
96  if (cache.find(key) != cache.end())
97  {
98  return cache[key];
99  }
100  std::ostringstream oss;
101  oss << m;
102  cache[key] = oss.str();
103  return oss.str();
104  }
105 
107  {
108  rosbag::View only_frames(bag, [](rosbag::ConnectionInfo const* info) {
109  std::regex exp(R"RRR(/device_\d+/sensor_\d+/.*_\d+/(image|imu))RRR");
110  return std::regex_search(info->topic, exp);
111  });
112  return std::chrono::nanoseconds((only_frames.getEndTime() - only_frames.getBeginTime()).toNSec());
113  }
114 
115  std::map<std::tuple<std::string, std::string, std::string, std::string, rs2rosinternal::Time, uint64_t>, std::string> cache;
120  double size;
122  std::map<std::string, std::vector<std::string>> topics_to_message_types;
124  };
125 }
rosbag_content(rosbag_content &&other)
rosbag_content(const rosbag_content &other)
const GLfloat * m
Definition: glext.h:6814
std::chrono::nanoseconds file_duration
std::map< std::tuple< std::string, std::string, std::string, std::string, rs2rosinternal::Time, uint64_t >, std::string > cache
GLsizei const GLchar *const * path
Definition: glext.h:4276
rosbag_inspector::compression_info compression_info
GLsizei const GLchar *const * string
rosbag_content(const std::string &file)
std::string const & getMD5Sum() const
std::chrono::nanoseconds get_duration(const rosbag::Bag &bag)
GLdouble t
GLuint64 key
Definition: glext.h:8966
def info(name, value, persistent=False)
Definition: test.py:301
rs2rosinternal::Time const & getTime() const
GLsizeiptr size
A class pointing into a bag file.
unsigned __int64 uint64_t
Definition: stdint.h:90
std::chrono::duration< uint64_t, std::nano > nanoseconds
compression_info(const std::tuple< std::string, uint64_t, uint64_t > &t)
std::string const & getTopic() const
GLint GLsizei count
std::string const & getDataType() const
std::map< std::string, std::vector< std::string > > topics_to_message_types
std::string getCallerId() const
std::string instanciate_and_cache(const rosbag::MessageInstance &m, uint64_t count)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:40