Ask Your Question

Unable to point cloud visualize in RVIZ

asked 2018-05-11 06:33:11 -0500

Ajay gravatar image

Hello All, I very new to ROS, I am using pcl in ROS. And I am trying to render sample point cloud in the RVIZ. But i am unable to render it due to some issues. A program executing successfully, but in RVIZ point cloud not rendering.

In Displays Tab: (Settings) Fixed Frame : map Global Status: Warn Fixed Frame: No tf data. Actual error: Fixed Frame [map] does not exist Point cloud: Status: OK Topic: /point_cloud

#include <ros/ros.h>
#include <sensor_msgs/PointCloud.h>
#include <string>
#include <random>
 void getRandomPointCloud(sensor_msgs::PointCloud& pc,double centerX, double centerY, int& sizeOfCloud) {
  std::random_device rd;
  std::mt19937 gen(rd());
  std::normal_distribution<> distX(centerX, 2.);
  std::normal_distribution<> distY(centerY, 2.);
  for (int i = 0; i < pc.points.size(); i++) {
        double xValue = distX(gen);
        double yValue = distY(gen);
        pc.points[i].x = xValue;
        pc.points[i].y = yValue;
        pc.points[i].z =
        std::exp(-((xValue * xValue) + (yValue * yValue)) / 4.);
  sensor_msgs::ChannelFloat32 depth_channel; = "distance";
  for (int i = 0; i < pc.points.size(); i++) {
    depth_channel.values.push_back(pc.points[i].z); // or set to a random value if you like
 // add channel to point cloud
int main(int argc, char** argv) {
  ros::init(argc, argv, "point_cloud_test");
  auto nh = ros::NodeHandle();    
  int sizeOfCloud = 100000;
  sensor_msgs::PointCloud keypoints;
  getRandomPointCloud(keypoints, 0.5, 0.5, sizeOfCloud);

  keypoints.header.frame_id = "base_link";
  keypoints.header.stamp = ros::Time::now();

  auto keypoints_publisher =

      nh.advertise<sensor_msgs::PointCloud>("point_cloud", 10);
  ros::Rate rate(30);
  while (ros::ok()) {
    keypoints.header.stamp = ros::Time::now();
  return 0;

It would be a great help for me if you anyone give some suggestions to fix this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-05-11 06:37:33 -0500

NEngelhard gravatar image

updated 2018-05-11 06:38:39 -0500

Fixed Frame : map Warn Fixed Frame: No tf data.
Actual error: Fixed Frame [map] does not exist

keypoints.header.frame_id = "base_link";

You tell RVIZ to show all data in the map-frame, but you publish in "base_link" without telling RVIZ how these frame are connected ("no tf data"). So either publish the transform base_link <-> map on /tf or set the Fixed Frame to base_link.

(Welcome to answers.ros :) Good first question, you provided all data needed to find the error)

edit flag offensive delete link more


Thank you So much your response NEngelhard , It worked for me.

Ajay gravatar image Ajay  ( 2018-05-12 02:00:04 -0500 )edit

please mark the Answer as Right.

sudo_melvinyesudas gravatar image sudo_melvinyesudas  ( 2018-05-12 02:09:48 -0500 )edit

i had the same issue but then changed my fixed frame to "webcam". Rviz is now receiving messages from thepoints2 topic, but all the points are in the origin at 0,0,0. I looked at rostopic echo /points2 and it is mostly 192, 127 and a lot of zeros - but some random numbers too. As far as I know these are not NaN values and not all of them have 0,0,0 as coordinates. I already changed the style and size of the pointcloud, but nothing changes. Really would appreciate any help!

DFFHTW gravatar image DFFHTW  ( 2019-07-24 03:23:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-05-11 06:33:11 -0500

Seen: 954 times

Last updated: May 11 '18