Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

publishing camera point clouds in rviz

Hi all! I used "roslaunch openni_launch openni.launch" and I am trying to subscribe to the "/camera/depth/points" of pointcloud2 datatype, do something to it in the callback function, which is a member function, and then publish it to rviz.

Problem that I am facing is regarding the fixed and target frames under global options of rviz. All the available frames do not work.

I believe I need to subscribe to the tf of the camera and publish it in my program, and rviz will use the publish frame as the fixed frame, and the the processed point cloud can be visualised.

Not sure how to do this though, or if this is even the coorect approach. Appreciate any help thx! I a on Ubuntu 12.04, fuerte btw!

My source code is as below.

ros::Publisher clusterPub; float scene_ss_ (0.03f); class Listener { public:

typedef pcl17::PointCloud<POINT_TYPE> Cloud;
typedef typename Cloud::Ptr CloudPtr;
    typedef typename Cloud::ConstPtr CloudConstPtr;

    boost::mutex mtx_;
CloudPtr scene;
CloudPtr scene_keypoints;
pcl17::UniformSampling<POINT_TYPE> uniform_sampling;
pcl17::PointCloud<int> sampled_indices;
pcl17::search::KdTree<POINT_TYPE>::Ptr cTree;
pcl17::EuclideanClusterExtraction<POINT_TYPE> ec;
std::vector<pcl17::PointIndices> cluster_indices;
CloudPtr cloud_cluster;
sensor_msgs::PointCloud2::Ptr clusteredScene;

Listener()
:   cTree (new pcl17::search::KdTree<POINT_TYPE>)
,   cloud_cluster (new pcl17::PointCloud<POINT_TYPE>)
,   clusteredScene (new sensor_msgs::PointCloud2)
,   scene (new pcl17::PointCloud<POINT_TYPE> ())
,   scene_keypoints (new pcl17::PointCloud<POINT_TYPE> ())
{};

void 
callback (const sensor_msgs::PointCloud2::ConstPtr& input)
{
    boost::mutex::scoped_lock lock (mtx_);

    ////not sure about this part//////
    static tf::TransformBroadcaster br;
    tf::Transform transform;
    transform.setOrigin( tf::Vector3(0.0, 0.0, 0.0) );
    transform.setRotation( tf::Quaternion(0, 0, 0) );
    br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "/camera_link", "/cluster_tf"));
            ///////////////////////////////////     

    pcl17::fromROSMsg(*input, *scene);

            //did some EuclideanClusterExtraction 

    pcl17::toROSMsg(*cloud_cluster, *clusteredScene);
    clusterPub.publish(*clusteredScene);
}

};

int main (int argc, char** argv) {

// Initialize ROS

ros::init (argc, argv, "ExtractClusters");

ros::NodeHandle nh;

Listener listener;

ros::Subscriber sub = nh.subscribe ("/camera/depth/points", 1000, &Listener::callback, &listener);

clusterPub = nh.advertise<sensor_msgs::PointCloud2> ("/cluster", 1000);

// Spin

ros::spin ();

}

publishing camera point clouds in rviz

Hi all! I used "roslaunch openni_launch openni.launch" and I am trying to subscribe to the "/camera/depth/points" of pointcloud2 datatype, do something to it in the callback function, which is a member function, and then publish it to rviz.

Problem that I am facing is regarding the fixed and target frames under global options of rviz. All the available frames do not work.

I am receiving this error:"For frame[]: Frame[] does not exist" under "Transform[sender=/MyNodeName]" under "Status:Error" under "PointCloud2" of Rviz.

I believe I need to subscribe to the tf of the camera and publish it in my program, and rviz will use the publish frame as the fixed frame, and the the processed point cloud can be visualised.

Not sure how to do this though, or if this is even the coorect approach. Appreciate any help thx! I a on Ubuntu 12.04, fuerte btw!

My source code is as below.

ros::Publisher clusterPub; float scene_ss_ (0.03f); class Listener { public:

typedef pcl17::PointCloud<POINT_TYPE> Cloud;
typedef typename Cloud::Ptr CloudPtr;
    typedef typename Cloud::ConstPtr CloudConstPtr;

    boost::mutex mtx_;
CloudPtr scene;
CloudPtr scene_keypoints;
pcl17::UniformSampling<POINT_TYPE> uniform_sampling;
pcl17::PointCloud<int> sampled_indices;
pcl17::search::KdTree<POINT_TYPE>::Ptr cTree;
pcl17::EuclideanClusterExtraction<POINT_TYPE> ec;
std::vector<pcl17::PointIndices> cluster_indices;
CloudPtr cloud_cluster;
sensor_msgs::PointCloud2::Ptr clusteredScene;

Listener()
:   cTree (new pcl17::search::KdTree<POINT_TYPE>)
,   cloud_cluster (new pcl17::PointCloud<POINT_TYPE>)
,   clusteredScene (new sensor_msgs::PointCloud2)
,   scene (new pcl17::PointCloud<POINT_TYPE> ())
,   scene_keypoints (new pcl17::PointCloud<POINT_TYPE> ())
{};

void 
callback Listener::callback (const sensor_msgs::PointCloud2::ConstPtr& input)
{
    boost::mutex::scoped_lock lock (mtx_);

    ////not sure about this part//////
    static tf::TransformBroadcaster br;
    tf::Transform transform;
    transform.setOrigin( tf::Vector3(0.0, 0.0, 0.0) );
    transform.setRotation( tf::Quaternion(0, 0, 0) );
    br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "/camera_link", "/cluster_tf"));
            ///////////////////////////////////     

    pcl17::fromROSMsg(*input, *scene);

            //did some EuclideanClusterExtraction 

    pcl17::toROSMsg(*cloud_cluster, *clusteredScene);
    clusterPub.publish(*clusteredScene);
}

};

int main (int argc, char** argv) argv)

{

// Initialize ROS

ros::init (argc, argv, "ExtractClusters");

"ExtractClusters");

ros::NodeHandle nh; nh;

Listener listener; listener;

ros::Subscriber sub = nh.subscribe ("/camera/depth/points", 1000, &Listener::callback, &listener); &listener);

clusterPub = nh.advertise<sensor_msgs::PointCloud2> nh.advertise<sensor_msgs::pointcloud2> ("/cluster", 1000); // Spin 1000);

ros::spin ();

();

}

publishing camera point clouds in rviz

Hi all! I used "roslaunch openni_launch openni.launch" and I am trying to subscribe to the "/camera/depth/points" of pointcloud2 datatype, do something to it in the callback function, which is a member function, and then publish it to rviz.

Problem that I am facing is regarding the fixed and target frames under global options of rviz. All the available frames do not work.

I am receiving this error:"For frame[]: Frame[] does not exist" under "Transform[sender=/MyNodeName]" under "Status:Error" under "PointCloud2" of Rviz.

I believe I need to subscribe to the tf of the camera and publish it in my program, and rviz will use the publish frame as the fixed frame, and the processed point cloud can be visualised.

Not sure how to do this though, or if this is even the coorect approach. Appreciate any help thx! I a on Ubuntu 12.04, fuerte btw!

My source code is as below.

void 
Listener::callback (const sensor_msgs::PointCloud2::ConstPtr& input)
{
    boost::mutex::scoped_lock lock (mtx_);

    pcl17::fromROSMsg(*input, *scene);

            //did some EuclideanClusterExtraction 

    pcl17::toROSMsg(*cloud_cluster, *clusteredScene);
    clusterPub.publish(*clusteredScene);
}

int main (int argc, char** argv)

{

ros::init (argc, argv, "ExtractClusters");"MyNodeName");

ros::NodeHandle nh;

Listener listener;

ros::Subscriber sub = nh.subscribe ("/camera/depth/points", 1000, &Listener::callback, &listener);

clusterPub = nh.advertise<sensor_msgs::pointcloud2> ("/cluster", 1000);

ros::spin ();

}

publishing camera point clouds in rviz

Hi all! I used "roslaunch openni_launch openni.launch" and I am trying to subscribe to the "/camera/depth/points" of pointcloud2 datatype, do something to it in the callback function, which is a member function, and then publish it to rviz.

Problem that I am facing is regarding the fixed and target frames under global options of rviz. All the available frames do not work.

I am receiving this error:"For frame[]: Frame[] does not exist" under "Transform[sender=/MyNodeName]" under "Status:Error" under "PointCloud2" of Rviz.

I believe I need to subscribe to the tf of the camera and publish it in my program, and rviz will use the publish frame as the fixed frame, and the processed point cloud can be visualised.

Not sure how to do this though, or if this is even the coorect approach. Appreciate any help thx! I a on Ubuntu 12.04, fuerte btw!

My source code is as below.

void 
Listener::callback (const sensor_msgs::PointCloud2::ConstPtr& input)
{
    boost::mutex::scoped_lock lock (mtx_);

    pcl17::fromROSMsg(*input, *scene);

            //did some EuclideanClusterExtraction 

    pcl17::toROSMsg(*cloud_cluster, *clusteredScene);
    clusterPub.publish(*clusteredScene);
}

int main (int argc, char** argv)

{

ros::init (argc, argv, "MyNodeName");

ros::NodeHandle nh;

Listener listener;

ros::Subscriber sub = nh.subscribe ("/camera/depth/points", 1000, &Listener::callback, &listener);

clusterPub = nh.advertise<sensor_msgs::pointcloud2> ("/cluster", 1000);

ros::spin ();

}