6 #include <condition_variable> 10 #include <unordered_map> 15 #include <rosbag/bag.h> 23 std::shared_ptr<RosBagView> _view;
24 std::shared_ptr<MessagePlaybackScope> _message_playback_scope;
25 mutable std::mutex _view_mutex;
28 std::string _file_name;
29 ros::Time _bag_start_time;
31 std::mutex _action_mutex;
32 std::function<void()> _pending_action;
33 std::function<double()> _time_function;
34 std::condition_variable _action_condition;
35 std::unordered_map<std::string, std::shared_ptr<Topic>> _topics;
36 std::vector<std::string> _topic_names;
37 std::vector<std::pair<std::string, std::string>> _topic_type_name_list;
38 volatile bool _is_playing =
false;
40 void startAction(
const std::function<
void()> &action);
41 inline bool interrupted_nolock() {
42 return _pending_action !=
nullptr || _exit;
44 inline bool interrupted() {
45 std::unique_lock<std::mutex> lock(_action_mutex);
46 return interrupted_nolock();
51 void publish(
const std::string &topic,
52 const std::shared_ptr<const Message> &message);
59 void play(
const std::vector<double> ¬ification_times);
61 void seek(
double time_from_start);
63 inline double duration()
const {
return _duration; }
64 const std::string &path()
const {
return _path; }
65 const std::string &fileName()
const {
return _file_name; }
66 std::vector<std::string> listTopics(
const std::string &type_name);
67 bool findMessageTimeSpan(
const std::string &topic,
double time,
double *start,
68 double *duration)
const;
69 const ros::Time &startTime()
const {
return _bag_start_time; }
72 void readMessageSamples(
73 const std::string &topic,
double start,
double stop,
74 const std::function<
bool(
const std::shared_ptr<const Message> &)>
76 bool isPlaying()
const {
return _is_playing; }