ros 同步velodyne camera 两个topic

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include    //image_transport
#include               //cv_bridge
#include     //图像编码格式
#include       //图像处理
#include        //opencv GUI

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 

#include 
#include 
#include 


using namespace std;
using namespace sensor_msgs;
using namespace message_filters;
using namespace geometry_msgs;
using namespace cv;
ros::Publisher pcl_pub;
// global variable
int cnt=0;
int j_num_wall=0;
char szName[200] = {'\0'};
char szName_pcd[200] = {'\0'};

typedef message_filters::sync_policies::ApproximateTime sync_policy_classification;


void callback(const sensor_msgs::ImageConstPtr& msg,const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
{

    cerr << "I should record the pose: "<::Ptr temp_cloud(new pcl::PointCloud);

    pcl::PointCloud::Ptr rgb_cloud(new pcl::PointCloud);


    pcl::fromPCLPointCloud2(pcl_pc2,*temp_cloud);

    std::cout<<"the size of the point cloud is :"<points.size ()<image);
//    j_num_wall++;


}


int main(int argc, char** argv)
{
    ros::init(argc, argv, "ttomchy");

    ros::NodeHandle nh;
    pcl_pub = nh.advertise("/chy/pcl_output",1000, true);

    message_filters::Subscriber info_sub(nh, "/camera_17023549/pg_17023549/image_raw", 2000);
    message_filters::Subscriber pose_sub(nh, "/left_velodyne/velodyne_points",2000);
    message_filters::Synchronizer sync(sync_policy_classification(2000), info_sub, pose_sub);
    //TimeSynchronizer sync(info_sub, pose_sub, 10);
    sync.registerCallback(boost::bind(&callback, _1, _2));

    ros::spin();

    return 0;
}








 

你可能感兴趣的:(ros 同步velodyne camera 两个topic)