ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Your first code example is a point cloud filter not a point cloud generator, you have a node which is subscribing to a sensor_msgs/PointCloud2
(a ROS message type) filters it and then re-publishes it in the same message type on a different topic. This node isn't producing any point clouds and unless you are running another node which produces point clouds then it will not do anything. It is listening for point clouds on the input
topic, so if nothing is publishing on that topic then the callback will never be executed.
Your second code example is closer but for some reason still has a subscriber listening for point clouds on the input
topic. Because nothing is being published on input again this callback will never be executed. The error messages you posted appear to show you trying to execute the cpp source file directly. Do you build the node using catkin make
and execute it using rosrun
or roslaunch
?
You'll want to get rid of the subscriber and callback completely and setup a while loop inside main, with a sensible rate such as 1 second and publish the point cloud from within that loop. The Pseudo code for you node should look something like this:
main()
{
init node
create pointcloud publisher
create rate object with 1 second duration
load point cloud from file
while(ros::ok())
{
rate.sleep
publish point cloud message
}
}