update cloud reprojection node to sync image+cloud, looks sync good
This commit is contained in:
@@ -16,15 +16,14 @@ limitations under the License.
|
||||
#ifdef ROS2
|
||||
#include <rclcpp/rclcpp.hpp>
|
||||
#include <sensor_msgs/msg/image.hpp>
|
||||
#include <sensor_msgs/msg/compressed_image.hpp>
|
||||
#include <cv_bridge/cv_bridge.h>
|
||||
#include <mutex>
|
||||
#else
|
||||
#include <ros/ros.h>
|
||||
#include <sensor_msgs/Image.h>
|
||||
#include <sensor_msgs/CompressedImage.h>
|
||||
#include <cv_bridge/cv_bridge.h>
|
||||
#include <message_filters/subscriber.h>
|
||||
#include <message_filters/sync_policies/approximate_time.h>
|
||||
#include <message_filters/synchronizer.h>
|
||||
#endif
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
@@ -39,25 +38,26 @@ public:
|
||||
|
||||
private:
|
||||
using Image = sensor_msgs::msg::Image;
|
||||
using CompressedImage = sensor_msgs::msg::CompressedImage;
|
||||
|
||||
std::string reprojected_topic_;
|
||||
std::string camera_topic_;
|
||||
std::string overlay_topic_;
|
||||
double alpha_; // blend alpha for overlay
|
||||
std::string output_topic_;
|
||||
int jpeg_quality_;
|
||||
|
||||
rclcpp::Subscription<Image>::SharedPtr reproj_sub_;
|
||||
rclcpp::Subscription<Image>::SharedPtr camera_sub_;
|
||||
rclcpp::Publisher<Image>::SharedPtr overlay_pub_;
|
||||
rclcpp::Publisher<CompressedImage>::SharedPtr combined_pub_;
|
||||
|
||||
// Cache latest images
|
||||
cv::Mat latest_reproj_img_;
|
||||
cv::Mat latest_camera_img_;
|
||||
std_msgs::msg::Header latest_header_;
|
||||
std_msgs::msg::Header latest_reproj_header_;
|
||||
std_msgs::msg::Header latest_camera_header_;
|
||||
std::mutex mutex_;
|
||||
|
||||
void reprojCallback(const Image::ConstSharedPtr& msg);
|
||||
void cameraCallback(const Image::ConstSharedPtr& msg);
|
||||
void publishOverlay();
|
||||
void publishHcatCompressed();
|
||||
};
|
||||
#else
|
||||
#include <mutex>
|
||||
@@ -71,21 +71,21 @@ private:
|
||||
|
||||
std::string reprojected_topic_;
|
||||
std::string camera_topic_;
|
||||
std::string overlay_topic_;
|
||||
double alpha_; // blend alpha for overlay
|
||||
std::string output_topic_;
|
||||
int jpeg_quality_;
|
||||
|
||||
ros::Subscriber reproj_sub_;
|
||||
ros::Subscriber camera_sub_;
|
||||
ros::Publisher overlay_pub_;
|
||||
ros::Publisher combined_pub_;
|
||||
|
||||
// Cache latest images
|
||||
cv::Mat latest_reproj_img_;
|
||||
cv::Mat latest_camera_img_;
|
||||
std_msgs::Header latest_header_;
|
||||
std_msgs::Header latest_reproj_header_;
|
||||
std_msgs::Header latest_camera_header_;
|
||||
std::mutex mutex_;
|
||||
|
||||
void reprojCallback(const sensor_msgs::ImageConstPtr& msg);
|
||||
void cameraCallback(const sensor_msgs::ImageConstPtr& msg);
|
||||
void publishOverlay();
|
||||
void publishHcatCompressed();
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user