20 #ifndef DENSE_MAP_ROS_UTILS_H_
21 #define DENSE_MAP_ROS_UTILS_H_
25 #include <rosbag/view.h>
26 #include <sensor_msgs/point_cloud2_iterator.h>
27 #include <tf2/LinearMath/Matrix3x3.h>
28 #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
29 #include <tf2_ros/transform_broadcaster.h>
30 #include <tf2_ros/transform_listener.h>
32 #include <opencv2/core/core.hpp>
35 #include <Eigen/Geometry>
37 #include <dense_map_utils.h>
53 void PublishTF(
const Eigen::Affine3d& publish_tf, std::string
const& parent_frame, std::string
const& child_frame,
54 ros::Time
const& timestamp, tf2_ros::TransformBroadcaster& tf_publisher);
56 void readBagPoses(std::string
const& bag_file, std::string
const& topic, StampedPoseStorage& poses);
58 void readBagImageTimestamps(std::string
const& bag_file, std::string
const& topic, std::vector<double>& timestamps);
64 void indexMessages(rosbag::View& view,
65 std::map<std::string, std::vector<rosbag::MessageInstance>>& bag_map);
67 void readExifFromBag(std::vector<rosbag::MessageInstance>
const& bag_msgs, std::map<
double, std::vector<double>>& exif);
73 bool lookupImage(
double desired_time, std::vector<rosbag::MessageInstance>
const& bag_msgs,
bool save_grayscale,
74 cv::Mat& image,
int& bag_pos,
double& found_time, std::string image_dir =
"");
82 bool lookupCloud(
double desired_time, std::vector<rosbag::MessageInstance>
const& bag_msgs,
83 double max_time_diff, cv::Mat& cloud,
int& bag_pos,
double& found_time);
91 void readTopicsInBag(std::string
const& bag_file, std::vector<std::string>& topics);
97 RosBagHandle(std::string
const& bag_file, std::string
const& topic) {
99 bag.open(bag_file, rosbag::bagmode::Read);
100 std::vector<std::string> topics;
101 topics.push_back(topic);
102 view = boost::shared_ptr<rosbag::View>(
new rosbag::View(bag, rosbag::TopicQuery(topics)));
103 for (rosbag::MessageInstance
const m : *view) bag_msgs.push_back(m);
106 boost::shared_ptr<rosbag::View> view;
107 std::vector<rosbag::MessageInstance> bag_msgs;
112 #endif // DENSE_MAP_ROS_UTILS_H_