RViz displays "No messages received", what could be the reason?
Hi there, I have a code that goes like this and is very similar to an example code:
#include <ros/ros.h>
//#include <sensor_msgs/PointCloud2.h>
#include <pcl/ros/conversions.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <iostream>
using namespace std;
ros::Publisher pub;
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input){
float x=0,y=0,z=0;
pcl::PointCloud<pcl::PointXYZ>::Ptr msg (new pcl::PointCloud<pcl::PointXYZ>);
msg->header.frame_id = "some_frame";
msg->height = msg->width = 1;
msg->points.push_back (pcl::PointXYZ(x, y, z));
pub.publish (msg);
}
int main (int argc, char** argv){
ros::init (argc, argv, "some_init");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe ("output", 100, cloud_cb);
pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 100);
ros::Rate loop_rate(1);
while (nh.ok()){
ros::spin ();
loop_rate.sleep ();}
}
Don't be concerned about the function's input argument. I just need this later as soon as I am able to process some incoming data, publish and then visualize it with RViz. So far, I'd like to see one single point when I'm using RViz. However, it indicates "No messages received". Does anyone know what the fault is? Kevin
If possible, could you please edit your post and add the complete source code? As far as I can see, everything looks ok.
Hello Martin, thanks for your reply. I finally got your point with the triggering. Unfortunately when I run your code a problem with the transformation appears, stating : Transform [sender=/some_init] For frame [some_frame]: Frame [some_frame] does not exist. How can I fix that?
Don't use the frame id
some_frame
. That was just an example. Instead, use something that is present in your tf tree, for instance input->header.frame_id. Also, don't forget to set the stamp, e.g.: msg->header.stamp = input->header.stamp