ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/PointCloud2.h>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input) { sensor_msgs::PointCloud2 output; pub.publish (output); }
int main(int argc, char** argv)
{
ros::init (argc, argv, "pub_pcl");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
PointCloud::Ptr msg (new PointCloud);
msg->header.frame_id = "some_tf_frame";
msg->height = msg->width = 1;
msg->points.push_back (pcl::PointXYZ(1.0, 2.0, 3.0));
ros::Rate loop_rate(4);
while (nh.ok())
{
msg->header.stamp = ros::Time::now ();
pub.publish (msg);
ros::spinOnce ();
loop_rate.sleep ();
}
}
2 | No.2 Revision |
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/PointCloud2.h>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
3 | No.3 Revision |
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/PointCloud2.h>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
sensor_msgs::PointCloud2 output;
pub.publish (output);
}
int main(int argc, char** argv)
{
ros::init (argc, argv, "pub_pcl");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
PointCloud::Ptr msg (new PointCloud);
msg->header.frame_id = "some_tf_frame";
msg->height = msg->width = 1;
msg->points.push_back (pcl::PointXYZ(1.0, 2.0, 3.0));
ros::Rate loop_rate(4);
while (nh.ok())
{
msg->header.stamp = ros::Time::now ();
pub.publish (msg);
ros::spinOnce ();
loop_rate.sleep ();
}
}
4 | No.4 Revision |
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/PointCloud2.h>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
sensor_msgs::PointCloud2 output;
pub.publish (output);
}
int main(int argc, char** argv)
{
ros::init (argc, argv, "pub_pcl");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
PointCloud::Ptr msg (new PointCloud);
msg->header.frame_id = "some_tf_frame";
msg->height = msg->width = 1;
msg->points.push_back (pcl::PointXYZ(1.0, 2.0, 3.0));
ros::Rate loop_rate(4);
while (nh.ok())
{
msg->header.stamp = ros::Time::now ();
pub.publish (msg);
ros::spinOnce ();
loop_rate.sleep ();
}
}
5 | No.5 Revision |
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/PointCloud2.h>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
sensor_msgs::PointCloud2 output;
pub.publish (output);
}
int main(int argc, char** argv)
{
ros::init (argc, argv, "pub_pcl");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<sensor_msgs::PointCloud2> ("output", nh.advertise<PointCloud> ("points2", 1);
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
PointCloud::Ptr msg (new PointCloud);
msg->header.frame_id = "some_tf_frame";
msg->height = msg->width = 1;
msg->points.push_back (pcl::PointXYZ(1.0, 2.0, 3.0));
ros::Rate loop_rate(4);
while (nh.ok())
{
msg->header.stamp = ros::Time::now ();
pub.publish (msg);
ros::spinOnce ();
loop_rate.sleep ();
}
}
6 | No.6 Revision |
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/PointCloud2.h>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
int main(int argc, char** argv)
{
ros::init (argc, argv, "pub_pcl");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<PointCloud> ("points2", 1);
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
PointCloud::Ptr msg (new PointCloud);
msg->header.frame_id = "some_tf_frame";
msg->height = msg->width = 1;
msg->points.push_back (pcl::PointXYZ(1.0, 2.0, 3.0));
ros::Rate loop_rate(4);
while (nh.ok())
{
msg->header.stamp = ros::Time::now ();
pub.publish (msg);
ros::spinOnce ();
loop_rate.sleep ();
}
}
7 | No.7 Revision |
#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/PointCloud2.h>
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
int main(int argc, char** argv)
{
{
ros::init (argc, argv, "pub_pcl");
ros::NodeHandle nh;
nh; ros::Publisher pub = nh.advertise<PointCloud> ("points2", 1);
nh.advertise<pointcloud> ("point2", 1);
PointCloud::Ptr msg (new PointCloud);
}