Unable to visualise PointCloud in Rviz (ROS) from publisher and subscriber node

asked 2019-03-01 03:56:27 -0500

Sanjay gravatar image

updated 2019-03-01 06:20:24 -0500

I am using the below code for publisher and subscriber. I am able to visualise PointCloud on Rviz for input node but failed to visualise output node. As i am quite new in ROS. How i can solve the problem? I have even set in Rviz the Fixed Frame: base_link.

   ros::Subscriber subPointCloud;
    ros::Publisher pubPointCloud;

    void DEM(const sensor_msgs::PointCloud2ConstPtr& input)
      ROS_DEBUG("Point Cloud Received");
      pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
      sensor_msgs::PointCloud2 output;

      // Convert from ROS message to PCL point cloud
      pcl::fromROSMsg(*input, *cloud);
      pcl::toROSMsg(*cloud, output);

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


    int main(int argc, char** argv)
      ROS_INFO("Starting LIDAR Node");
      ros::init(argc, argv, "kitti_lidar_node");
      ros::NodeHandle nh;

      subPointCloud = nh.subscribe<sensor_msgs::PointCloud2>("input", 1, DEM);
      pubPointCloud = nh.advertise<pcl::PointCloud<pcl::PointXYZ> > ("output", 1);


      return 0;
edit retag flag offensive close merge delete


When you say it failed to visualise in RVIZ what exactly do you mean? Does RVIZ show and error? A important first check would be to use the rostopic echo <topic> command to see if any messages are being published on the output topic.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-03-01 06:03:18 -0500 )edit

Rviz does not shows any error, than also i am not able to visualise the output. Further, i can see topics are successfully publishing and subscribing topics: rostopic list -v.

Sanjay gravatar image Sanjay  ( 2019-03-01 06:49:08 -0500 )edit

As i don't have sufficient point to attached Rviz screenshot here. I have post the image on following link may you can check: link text

Sanjay gravatar image Sanjay  ( 2019-03-01 06:52:51 -0500 )edit