Ask Your Question
0

publishing camera point clouds in rviz [closed]

asked 2013-06-21 13:28:32 -0600

VicL gravatar image

updated 2013-06-24 04:48:41 -0600

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);<="" p="">

ros::spin ();

}

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Philip
close date 2013-06-25 11:12:49

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-06-23 21:54:11 -0600

Philip gravatar image

Have you set the frame_id of the header of the pointcloud-message?

clusteredScene->header.frame_id = "my_frame" should probably do the trick.

See pointcloud2 message definition and header message definition for further details on the datatypes.

edit flag offensive delete link more

Comments

Glad to hear :-) As usual, please mark the answer as "accepted" (round check mark on the left) so it can be closed. Thanks!

Philip gravatar imagePhilip ( 2013-06-24 14:17:06 -0600 )edit

it works! thanks Philip!

I placed

clusteredScene->header.frame_id = "my_frame"

before

clusterPub.publish(*clusteredScene);

and broadcasted the transformation with parent frame as "camera_depth_optical_frame" and child frame as "clusteredScene_frame"

VicL gravatar imageVicL ( 2013-06-24 15:23:55 -0600 )edit

Question Tools

Stats

Asked: 2013-06-21 13:28:32 -0600

Seen: 3,242 times

Last updated: Jun 23 '13