I am trying to subscribe to two topics from radar and lidar using message_filters, the code is working but the callback is not running, just wait! my code as next:
”’
class SensorFusion : public rclcpp::Node {
public:
message_filters::Subscriber<my_msgs::msg::Mypointcloud> radar_subscription_;
message_filters::Subscriber<visualization_msgs::msg::Marker> lidar_subscription_;
SensorFusion() : Node(“sensor_fusion”)
{
std::cout<<“Hello1″<<std::endl;
radar_subscription_.subscribe(this,”/radar_data_front_pointcloud”);
lidar_subscription_.subscribe(this,”/cluster_bboxes”);
typedef message_filters::sync_policies::ApproximateTime<my_msgs::msg::Mypointcloud, visualization_msgs::msg::Marker> approximate_policy;
message_filters::Synchronizer<approximate_policy> syncApproximate(approximate_policy(10), radar_subscription_, lidar_subscription_);
syncApproximate.registerCallback(&SensorFusion::sync_callback,this);
std::cout<<"Hello2"<<std::endl;
}
”’
I tried all the solution on the internet, but nothing is working. Always gives me hello1 and hello2 and nothing for the sync_callback. I will be thankfull for any helo or recommendations!
I tried all these solutions:
- https://answers.ros.org/question/291876/how-can-i-subscribe-to-2-different-topics-in-a-synchronised-manner-in-ros2/
- https://answers.ros.org/question/404578/callback-not-being-called-using-message-filters/
- ROS2 Callback not being called using Message Filters C++
But nothing worked, also I tried to run codes from github but also it didnot work.