19#include <message_filters/connection.h>
20#include <message_filters/sync_policies/approximate_time.h>
21#include <message_filters/synchronizer.h>
22#include <message_filters/time_synchronizer.h>
23#include <tf2_ros/buffer.h>
27#include <rclcpp/rclcpp.hpp>
28#include <sensor_msgs/msg/detail/point_cloud2__struct.hpp>
29#include <sensor_msgs/msg/point_cloud2.hpp>
31#include <tf2_msgs/msg/detail/tf_message__struct.hpp>
32#include <tf2_msgs/msg/tf_message.hpp>
33#include <unordered_map>
37#include "rosbag_reader.hpp"
38#include "cli/cli_config.hpp"
41typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::msg::PointCloud2, sensor_msgs::msg::PointCloud2, sensor_msgs::msg::PointCloud2, sensor_msgs::msg::PointCloud2> ApproxTimeSyncPolicy;
43namespace pointcloudcrafter
58 void run() { reader_.process(); }
74 const sensor_msgs::msg::PointCloud2::ConstSharedPtr & pc1,
75 const sensor_msgs::msg::PointCloud2::ConstSharedPtr & pc2,
76 const sensor_msgs::msg::PointCloud2::ConstSharedPtr & pc3,
77 const sensor_msgs::msg::PointCloud2::ConstSharedPtr & pc4);
84 void process_pointclouds(std::vector<sensor_msgs::msg::PointCloud2::ConstSharedPtr> & pc_msgs);
91 const sensor_msgs::msg::PointCloud2 & msg_in, sensor_msgs::msg::PointCloud2 & msg_out);
99 tf2_ros::Buffer tf2_buffer_;
101 rclcpp::Logger logger_;
103 std::vector<std::unique_ptr<tools::MsgFilter<sensor_msgs::msg::PointCloud2>>> subscribers_;
105 std::unique_ptr<message_filters::Synchronizer<ApproxTimeSyncPolicy>> synchronizer_;
106 message_filters::Connection sync_connection_{};
108 std::unordered_map<std::string, Eigen::Affine3d> file_transforms_{};
111 size_t num_sensors_{};
112 int64_t loaded_frames_{0};
113 int64_t stride_frames_{0};
114 int64_t skip_frames_{0};
Rosbag(const config::RosbagConfig &cfg)
Constructor.
Definition pointcloudcrafter_rosbag.cpp:61
void transform_pc(const sensor_msgs::msg::PointCloud2 &msg_in, sensor_msgs::msg::PointCloud2 &msg_out)
Transform a pointcloud given the transform from either the file or the TF buffer.
Definition pointcloudcrafter_rosbag.cpp:307
void pointcloud_sync_callback(const sensor_msgs::msg::PointCloud2::ConstSharedPtr &pc1, const sensor_msgs::msg::PointCloud2::ConstSharedPtr &pc2, const sensor_msgs::msg::PointCloud2::ConstSharedPtr &pc3, const sensor_msgs::msg::PointCloud2::ConstSharedPtr &pc4)
Callback for synchronized pointclouds.
Definition pointcloudcrafter_rosbag.cpp:156
void run()
Run the pointcloud crafter.
Definition pointcloudcrafter_rosbag.hpp:58
void process_pointclouds(std::vector< sensor_msgs::msg::PointCloud2::ConstSharedPtr > &pc_msgs)
Process the pointclouds once all pointclouds are synchronized.
Definition pointcloudcrafter_rosbag.cpp:186
void tf_callback(const tools::RosbagReaderMsg< tf2_msgs::msg::TFMessage > &msg)
Callback for TF messages.
Definition pointcloudcrafter_rosbag.cpp:140
Rosbag input configuration.
Definition cli_config.hpp:236