First time here? Check out the FAQ!


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

PointCloud library publishing

I have a pcl::PointCloud<pointxyz> cloud and I need to publish it. It is NOT a kinect camera. Does anyone know how to do this? Is there some good sample code out there? I really need help here....

Thanks in advance, -Hunter A.

click to hide/show revision 2
No.2 Revision

PointCloud library publishing

I have a pcl::PointCloud<pointxyz> cloud and I need to publish it. It is NOT a kinect camera. Does anyone know how to do this? Is there some good sample code out there? I really need help here....

Thanks in advance, -Hunter A.

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

    ros::NodeHandle handler;

    ros::Subscriber laserReader = handler.subscribe("scan", 10000, scanCallBack);
    ros::Publisher  laserOutput = handler.advertise<pcl::PointCloud<pcl::PointXYZ> >("/cloud_pcl", 100);

    laserOutput.publish(correctedCloud.makeShared());
    ros::spin();

    return 0;
}//end main.

correctedCloud is declared above. It is modified after the scan call back is called.

click to hide/show revision 3
added more info.

PointCloud library publishing

I have a pcl::PointCloud<pointxyz> cloud and I need to publish it. It is NOT a kinect camera. Does anyone know how to do this? Is there some good sample code out there? I really need help here....

Thanks in advance, -Hunter A.

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

    ros::NodeHandle handler;

    ros::Subscriber laserReader = handler.subscribe("scan", 10000, scanCallBack);
    ros::Publisher  laserOutput = handler.advertise<pcl::PointCloud<pcl::PointXYZ> >("/cloud_pcl", 100);

    laserOutput.publish(correctedCloud.makeShared());
    ros::spin();

    return 0;
}//end main.

correctedCloud is declared above. It is modified after the scan call back is called.

called.

This is the RVIZ error

This is the output for rostopic echo cloud_pcl

I am publishing the topic here (This is my research, so I'm afraid the whole code cannot be posted publicly)

    void makeOneCloud()
{
    PointCloud combined;
    //matchSlopes();

    for (unsigned int x = 0; x < scans.size(); ++x)
    {
        PointCloud currentCorrected = scans.at(x).getCorrections();
        for (unsigned int y = 0; y < currentCorrected.points.size(); ++y)
        {
            double py = currentCorrected.points.at(y).y;
            double px = currentCorrected.points.at(y).x;
            double pZ = Z;

            pcl::PointXYZ toPush;
            toPush.x = px; toPush.y = py; toPush.z = pZ;

            combined.points.push_back(toPush);
        }//end for y
    }//end for x.

    correctedCloud = combined;
    combined.height = 1;
    combined.width = combined.points.size();

    pcl::PCDWriter writer;
    writer.write<pcl::PointXYZ> ("FinalCorrections.pcd", combined, false);
    laserOutput.publish(combined.makeShared());
    ROS_INFO("Corrections Saved!");

    scans.clear();
}//this method combines all the corrected shapes to a single point cloud.