35 #ifndef DATA_BAGGER_ASTROBEE_RECORDER_H_
36 #define DATA_BAGGER_ASTROBEE_RECORDER_H_
39 #if !defined(_MSC_VER)
45 #include <boost/thread/condition.hpp>
46 #include <boost/thread/mutex.hpp>
47 #include <boost/regex.hpp>
51 #include <ros/callback_queue.h>
53 #include <std_msgs/Empty.h>
54 #include <topic_tools/shape_shifter.h>
62 #include <condition_variable>
64 #include "rosbag/bag.h"
65 #include "rosbag/stream.h"
66 #include "rosbag/macros.h"
67 #include "rosbag/recorder.h"
71 using rosbag::OutgoingMessage;
72 using rosbag::OutgoingQueue;
73 using rosbag::RecorderOptions;
78 explicit Recorder(RecorderOptions
const& options);
82 bool isSubscribed(std::string
const& topic)
const;
84 boost::shared_ptr<ros::Subscriber> subscribe(std::string
const& topic);
93 void updateFilenames();
98 bool scheduledCheckDisk();
101 void snapshotTrigger(std_msgs::Empty::ConstPtr trigger);
102 void doQueue(
const ros::MessageEvent<topic_tools::ShapeShifter const>& msg_event,
103 std::string
const& topic,
104 boost::shared_ptr<ros::Subscriber> subscriber,
105 boost::shared_ptr<int> count);
107 void checkNumSplits();
110 void doRecordSnapshotter();
111 void doCheckMaster(ros::TimerEvent
const& e, ros::NodeHandle& node_handle);
113 bool shouldSubscribeToTopic(std::string
const& topic,
bool from_node =
false);
116 static std::string timeToStr(T ros_t);
119 RecorderOptions options_;
123 std::string target_filename_;
124 std::string write_filename_;
125 std::list<std::string> current_files_;
127 std::set<std::string> currently_recording_;
128 int num_subscribers_;
132 boost::condition_variable_any queue_condition_;
133 boost::mutex queue_mutex_;
134 std::queue<OutgoingMessage>* queue_;
135 uint64_t queue_size_;
136 uint64_t max_queue_size_;
138 uint64_t split_count_;
140 std::queue<OutgoingQueue> queue_queue_;
146 bool writing_enabled_;
147 boost::mutex check_disk_mutex_;
148 ros::WallTime check_disk_next_;
149 ros::WallTime warn_next_;
150 ros::NodeHandle node_handle_;
151 ros::CallbackQueue callback_queue_;
154 std::condition_variable condition_variable_;
159 #endif // DATA_BAGGER_ASTROBEE_RECORDER_H_