bag_player.cpp
Go to the documentation of this file.
1 #include "rosbag/bag_player.h"
2 
3 #define foreach BOOST_FOREACH
4 
5 namespace rosbag
6 {
7 
8 BagPlayer::BagPlayer(const std::string &fname) {
11  View v(bag);
13  bag_end_ = v.getEndTime();
15  playback_speed_ = 1.0;
16 }
17 
19  bag.close();
20 }
21 
23  return last_message_time_;
24 }
25 
27  bag_start_ = start;
28 }
29 
31  bag_end_ = end;
32 }
33 
34 void BagPlayer::set_playback_speed(double scale) {
35  if (scale > 0.0)
36  playback_speed_ = scale;
37 }
38 
40  return play_start_ + (msg_time - bag_start_) * (1 / playback_speed_);
41 }
42 
44 
45  std::vector<std::string> topics;
46  std::pair<std::string, BagCallback *> cb;
47  foreach(cb, cbs_)
48  topics.push_back(cb.first);
49 
52 
53  foreach(MessageInstance const m, view)
54  {
55  if (cbs_.find(m.getTopic()) == cbs_.end())
56  continue;
57 
59 
60  last_message_time_ = m.getTime(); /* this is the recorded time */
61  cbs_[m.getTopic()]->call(m);
62  }
63 }
64 
65 void BagPlayer::unregister_callback(const std::string &topic) {
66  delete cbs_[topic];
67  cbs_.erase(topic);
68 }
69 
70 }
71 
std::map< std::string, BagCallback * > cbs_
Definition: bag_player.h:120
GLuint GLuint end
rs2rosinternal::Time getEndTime()
Definition: view.cpp:202
void open(std::string const &filename, uint32_t mode=bagmode::Read)
Open a bag file.
Definition: bag.cpp:101
std::mutex m
rs2rosinternal::Time const & getTime() const
void set_end(const rs2rosinternal::Time &end)
Definition: bag_player.cpp:30
void set_playback_speed(double scale)
Definition: bag_player.cpp:34
void unregister_callback(const std::string &topic)
Definition: bag_player.cpp:65
void set_start(const rs2rosinternal::Time &start)
Definition: bag_player.cpp:26
rs2rosinternal::Time getBeginTime()
Definition: view.cpp:187
void close()
Close the bag file.
Definition: bag.cpp:161
virtual ~BagPlayer()
Definition: bag_player.cpp:18
rs2rosinternal::Time bag_start_
Definition: bag_player.h:121
A class pointing into a bag file.
Time representation. May either represent wall clock time or ROS clock time.
Definition: time.h:177
GLuint start
static bool sleepUntil(const Time &end)
Sleep until a specific time has been reached.
Definition: time.cpp:351
BagPlayer(const std::string &filename)
Definition: bag_player.cpp:8
rs2rosinternal::Time real_time(const rs2rosinternal::Time &msg_time)
Definition: bag_player.cpp:39
rs2rosinternal::Time bag_end_
Definition: bag_player.h:122
double playback_speed_
Definition: bag_player.h:124
rs2rosinternal::Time last_message_time_
Definition: bag_player.h:123
fname
Definition: rmse.py:13
Definition: bag.h:66
rs2rosinternal::Time play_start_
Definition: bag_player.h:125
static void init()
Definition: time.cpp:269
static Time now()
Retrieve the current time. If ROS clock time is in use, this returns the time according to the ROS cl...
Definition: time.cpp:241
std::string const & getTopic() const
::std_msgs::Time_< std::allocator< void > > Time
Definition: Time.h:47
GLdouble v
rs2rosinternal::Time get_time()
Definition: bag_player.cpp:22


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:41:42