1 #ifndef _RGBDHANDLER_H_
2 #define _RGBDHANDLER_H_
4 #include <rclcpp/rclcpp.hpp>
6 #include <rtabmap_msgs/msg/rgbd_image.hpp>
8 #include <rtabmap/core/Compression.h>
9 #include <rtabmap/core/Memory.h>
10 #include <rtabmap/core/RegistrationVis.h>
11 #include <rtabmap/core/Rtabmap.h>
12 #include <rtabmap/core/SensorData.h>
13 #include <rtabmap/core/VWDictionary.h>
14 #include <rtabmap/core/util2d.h>
15 #include <rtabmap/core/util3d.h>
16 #include <rtabmap/utilite/UStl.h>
18 #include <message_filters/subscriber.h>
19 #include <message_filters/sync_policies/approximate_time.h>
20 #include <message_filters/synchronizer.h>
21 #include <message_filters/time_synchronizer.h>
23 #include <image_transport/image_transport.hpp>
24 #include <image_transport/subscriber_filter.hpp>
26 #include <tf2_ros/buffer.h>
27 #include <tf2_ros/transform_listener.h>
29 #include <cv_bridge/cv_bridge.h>
32 #include <cslam_common_interfaces/msg/keyframe_odom.hpp>
33 #include <cslam_common_interfaces/msg/keyframe_rgb.hpp>
34 #include <cslam_common_interfaces/msg/viz_point_cloud.hpp>
35 #include <cslam_common_interfaces/msg/inter_robot_loop_closure.hpp>
36 #include <cslam_common_interfaces/msg/local_descriptors_request.hpp>
37 #include <cslam_common_interfaces/msg/local_image_descriptors.hpp>
38 #include <cslam_common_interfaces/msg/local_keyframe_match.hpp>
39 #include <cslam_common_interfaces/msg/intra_robot_loop_closure.hpp>
40 #include <diagnostic_msgs/msg/key_value.hpp>
41 #include <sensor_msgs/msg/nav_sat_fix.hpp>
44 #include <nav_msgs/msg/odometry.hpp>
49 #include <rtabmap_conversions/MsgConversion.h>
79 cslam_common_interfaces::msg::LocalDescriptorsRequest::
80 ConstSharedPtr request);
88 cslam_common_interfaces::msg::LocalKeyframeMatch::ConstSharedPtr
97 const std::shared_ptr<
98 cslam_common_interfaces::msg::LocalImageDescriptors>
116 const std::shared_ptr<
117 cslam_common_interfaces::msg::LocalImageDescriptors>
119 rtabmap::SensorData &sensor_data);
128 const std::shared_ptr<rtabmap::SensorData> sensor_data,
129 rtabmap_msgs::msg::RGBDImage &msg_data);
145 void send_keyframe(
const std::pair<std::shared_ptr<rtabmap::SensorData>, std::shared_ptr<const nav_msgs::msg::Odometry>> &keypoints_data);
153 void send_keyframe(
const std::pair<std::shared_ptr<rtabmap::SensorData>, std::shared_ptr<const nav_msgs::msg::Odometry>> &keypoints_data,
const sensor_msgs::msg::NavSatFix& gps_data);
160 virtual void send_visualization(
const std::pair<std::shared_ptr<rtabmap::SensorData>, std::shared_ptr<const nav_msgs::msg::Odometry>> &keypoints_data);
167 void send_visualization_keypoints(
const std::pair<std::shared_ptr<rtabmap::SensorData>, std::shared_ptr<const nav_msgs::msg::Odometry>> &keypoints_data);
186 const sensor_msgs::msg::Image::ConstSharedPtr image_rect_rgb,
187 const sensor_msgs::msg::Image::ConstSharedPtr image_rect_depth,
188 const sensor_msgs::msg::CameraInfo::ConstSharedPtr camera_info_rgb,
189 const nav_msgs::msg::Odometry::ConstSharedPtr odom);
203 void gps_callback(
const sensor_msgs::msg::NavSatFix::ConstSharedPtr msg);
212 const sensor_msgs::msg::PointCloud2 &input_cloud);
215 std::deque<std::pair<std::shared_ptr<rtabmap::SensorData>,
216 nav_msgs::msg::Odometry::ConstSharedPtr>>
223 std::shared_ptr<rclcpp::Node>
node_;
230 rclcpp::Subscription<
231 cslam_common_interfaces::msg::LocalDescriptorsRequest>::SharedPtr
235 cslam_common_interfaces::msg::LocalImageDescriptors>::SharedPtr
239 rclcpp::Publisher<cslam_common_interfaces::msg::KeyframeRGB>::SharedPtr
242 rclcpp::Publisher<cslam_common_interfaces::msg::KeyframeOdom>::SharedPtr
245 rclcpp::Publisher<cslam_common_interfaces::msg::VizPointCloud>::SharedPtr
248 rclcpp::Subscription<
249 cslam_common_interfaces::msg::LocalKeyframeMatch>::SharedPtr
252 rclcpp::Subscription<
253 cslam_common_interfaces::msg::LocalImageDescriptors>::SharedPtr
259 cslam_common_interfaces::msg::InterRobotLoopClosure>::SharedPtr
263 cslam_common_interfaces::msg::IntraRobotLoopClosure>::SharedPtr
267 diagnostic_msgs::msg::KeyValue>::SharedPtr
272 std::shared_ptr<tf2_ros::Buffer>
288 std::deque<sensor_msgs::msg::NavSatFix>
292 image_transport::SubscriberFilter sub_image_color_;
293 message_filters::Subscriber<sensor_msgs::msg::CameraInfo> sub_camera_info_color_;
294 image_transport::SubscriberFilter sub_image_depth_;
295 message_filters::Subscriber<sensor_msgs::msg::CameraInfo> sub_camera_info_depth_;
296 typedef message_filters::sync_policies::ApproximateTime<
297 sensor_msgs::msg::Image, sensor_msgs::msg::Image,
298 sensor_msgs::msg::CameraInfo,
299 nav_msgs::msg::Odometry>
301 message_filters::Synchronizer<RGBDSyncPolicy> *rgbd_sync_policy_;
303 sensor_msgs::msg::PointCloud2::SharedPtr cloud_msg_;
Interface class for handling sensor data.
std::shared_ptr< rtabmap::SensorData > previous_keyframe_
void gps_callback(const sensor_msgs::msg::NavSatFix::ConstSharedPtr msg)
GPS data callback.
void send_keyframe(const std::pair< std::shared_ptr< rtabmap::SensorData >, std::shared_ptr< const nav_msgs::msg::Odometry >> &keypoints_data)
Function to send the image to the python node.
std::shared_ptr< rclcpp::Node > node_
rclcpp::Publisher< cslam_common_interfaces::msg::VizPointCloud >::SharedPtr keyframe_pointcloud_publisher_
rclcpp::Subscription< cslam_common_interfaces::msg::LocalImageDescriptors >::SharedPtr local_descriptors_subscriber_
bool generate_new_keyframe(std::shared_ptr< rtabmap::SensorData > &keyframe)
Generate a new keyframe according to the policy.
void sensor_data_to_rgbd_msg(const std::shared_ptr< rtabmap::SensorData > sensor_data, rtabmap_msgs::msg::RGBDImage &msg_data)
converts sensor data to descriptor msg
rclcpp::Subscription< sensor_msgs::msg::NavSatFix >::SharedPtr gps_subscriber_
rclcpp::Publisher< cslam_common_interfaces::msg::IntraRobotLoopClosure >::SharedPtr intra_robot_loop_closure_publisher_
void receive_local_keyframe_match(cslam_common_interfaces::msg::LocalKeyframeMatch::ConstSharedPtr msg)
Receives a local match and tries to compute a local loop closure.
rclcpp::Subscription< cslam_common_interfaces::msg::LocalDescriptorsRequest >::SharedPtr send_local_descriptors_subscriber_
unsigned int min_inliers_
unsigned int nb_local_keyframes_
void send_visualization_pointcloud(const std::shared_ptr< rtabmap::SensorData > &sensor_data)
Send colored pointcloud for visualizations.
std::shared_ptr< tf2_ros::TransformListener > tf_listener_
sensor_msgs::msg::PointCloud2 visualization_pointcloud_voxel_subsampling(const sensor_msgs::msg::PointCloud2 &input_cloud)
Subsample pointcloud to reduce size for visualization.
void compute_local_descriptors(std::shared_ptr< rtabmap::SensorData > &frame_data)
Computes local 3D descriptors from frame data and store them.
void rgbd_callback(const sensor_msgs::msg::Image::ConstSharedPtr image_rect_rgb, const sensor_msgs::msg::Image::ConstSharedPtr image_rect_depth, const sensor_msgs::msg::CameraInfo::ConstSharedPtr camera_info_rgb, const nav_msgs::msg::Odometry::ConstSharedPtr odom)
Callback receiving sync data from camera.
void send_visualization_keypoints(const std::pair< std::shared_ptr< rtabmap::SensorData >, std::shared_ptr< const nav_msgs::msg::Odometry >> &keypoints_data)
Send keypoints for visualizations.
rtabmap::RegistrationVis registration_
rclcpp::Publisher< diagnostic_msgs::msg::KeyValue >::SharedPtr log_publisher_
unsigned int max_queue_size_
sensor_msgs::msg::NavSatFix latest_gps_fix_
message_filters::Subscriber< nav_msgs::msg::Odometry > sub_odometry_
float visualization_max_range_
float keyframe_generation_ratio_threshold_
rclcpp::Publisher< cslam_common_interfaces::msg::InterRobotLoopClosure >::SharedPtr inter_robot_loop_closure_publisher_
std::map< int, std::shared_ptr< rtabmap::SensorData > > local_descriptors_map_
unsigned int log_total_local_descriptors_cumulative_communication_
std::string base_frame_id_
std::deque< std::pair< std::shared_ptr< rtabmap::SensorData >, nav_msgs::msg::Odometry::ConstSharedPtr > > received_data_queue_
std::deque< sensor_msgs::msg::NavSatFix > received_gps_queue_
bool generate_new_keyframes_based_on_inliers_ratio_
rclcpp::Publisher< cslam_common_interfaces::msg::KeyframeOdom >::SharedPtr keyframe_odom_publisher_
bool enable_gps_recording_
rclcpp::Subscription< cslam_common_interfaces::msg::LocalKeyframeMatch >::SharedPtr local_keyframe_match_subscriber_
unsigned int max_nb_robots_
float visualization_voxel_size_
virtual void send_visualization(const std::pair< std::shared_ptr< rtabmap::SensorData >, std::shared_ptr< const nav_msgs::msg::Odometry >> &keypoints_data)
Send keypoints for visualizations.
rclcpp::Publisher< cslam_common_interfaces::msg::KeyframeRGB >::SharedPtr keyframe_data_publisher_
unsigned int visualization_period_ms_
void receive_local_image_descriptors(const std::shared_ptr< cslam_common_interfaces::msg::LocalImageDescriptors > msg)
Message callback to receive descriptors and compute.
rclcpp::Publisher< cslam_common_interfaces::msg::LocalImageDescriptors >::SharedPtr visualization_local_descriptors_publisher_
rclcpp::Publisher< cslam_common_interfaces::msg::LocalImageDescriptors >::SharedPtr local_descriptors_publisher_
std::shared_ptr< tf2_ros::Buffer > tf_buffer_
void clear_sensor_data(std::shared_ptr< rtabmap::SensorData > &sensor_data)
Clear images and large data fields in sensor data.
virtual void local_descriptors_msg_to_sensor_data(const std::shared_ptr< cslam_common_interfaces::msg::LocalImageDescriptors > msg, rtabmap::SensorData &sensor_data)
converts descriptors to sensore data
void local_descriptors_request(cslam_common_interfaces::msg::LocalDescriptorsRequest::ConstSharedPtr request)
Service callback to publish local descriptors.
bool enable_visualization_
virtual void process_new_sensor_data()
Processes Latest received image.
RGBDHandler(std::shared_ptr< rclcpp::Node > &node)
Initialization of parameters and ROS 2 objects.