ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

My solution for this problem : class SubscribeAndPublish { public: SubscribeAndPublish():sync2(image_sub,image_sub2,500){ //https://gist.github.com/tdenewiler/e2172f628e49ab633ef2786207793336 image_sub.subscribe(n, "/camera/color/image_raw", 1); image_sub2.subscribe(n, "/camera/aligned_depth_to_color/image_raw", 1); sync2.registerCallback(boost::bind(&SubscribeAndPublish::callback,this, _1, _2)); odom_pub = n.advertise<nav_msgs::odometry>("RGBDodom", 50); } void callback(const sensor_msgs::ImageConstPtr& msg,const sensor_msgs::ImageConstPtr& msg2){ } private: ros::NodeHandle n; ros::Publisher odom_pub; message_filters::Subscriber<image> image_sub; message_filters::Subscriber<image> image_sub2; TimeSynchronizer<image, image=""> sync2; };

My solution for this problem : :

class SubscribeAndPublish
{
public:
SubscribeAndPublish { public:  SubscribeAndPublish():sync2(image_sub,image_sub2,500){

SubscribeAndPublish():sync2(image_sub,image_sub2,500){    //https://gist.github.com/tdenewiler/e2172f628e49ab633ef2786207793336

//https://gist.github.com/tdenewiler/e2172f628e49ab633ef2786207793336    image_sub.subscribe(n, "/camera/color/image_raw", 1);
1);  
image_sub2.subscribe(n, "/camera/aligned_depth_to_color/image_raw", 1);  image_sub2.subscribe(n, "/camera/aligned_depth_to_color/image_raw", 1);
  
sync2.registerCallback(boost::bind(&SubscribeAndPublish::callback,this,
_1, _2));  
odom_pub = n.advertise<nav_msgs::Odometry>("RGBDodom", 50);
}  sync2.registerCallback(boost::bind(&SubscribeAndPublish::callback,this, _1, _2));
        odom_pub = n.advertise<nav_msgs::odometry>("RGBDodom", 50);
    }
     void callback(const sensor_msgs::ImageConstPtr& msg,const sensor_msgs::ImageConstPtr& msg2){
msg2){ }
private:
 private:   
 ros::NodeHandle n;  ros::NodeHandle n;

 ros::Publisher odom_pub;   
 message_filters::Subscriber<Image> image_sub;  
 message_filters::Subscriber<Image> image_sub2;  ros::Publisher odom_pub;
     message_filters::Subscriber<image> image_sub;
    message_filters::Subscriber<image> image_sub2;
    TimeSynchronizer<image, image=""> TimeSynchronizer<Image, Image> sync2;

};

My solution for this problem :

class SubscribeAndPublish {  public:     
SubscribeAndPublish():sync2(image_sub,image_sub2,500){       
//https://gist.github.com/tdenewiler/e2172f628e49ab633ef2786207793336       
image_sub.subscribe(n, "/camera/color/image_raw", 1);       
image_sub2.subscribe(n, "/camera/aligned_depth_to_color/image_raw", 1);     
sync2.registerCallback(boost::bind(&SubscribeAndPublish::callback,this,
_1, _2));       
odom_pub = n.advertise<nav_msgs::Odometry>("RGBDodom", 50);
}   
void callback(const sensor_msgs::ImageConstPtr& msg,const sensor_msgs::ImageConstPtr& msg2){ }
 private:   
 ros::NodeHandle n;     
 ros::Publisher odom_pub;   
 message_filters::Subscriber<Image> image_sub;  
 message_filters::Subscriber<Image> image_sub2;     
 TimeSynchronizer<Image, Image> sync2;

};