Skip to content

Instantly share code, notes, and snippets.

@michalpelka
Created July 15, 2021 19:09
Show Gist options
  • Select an option

  • Save michalpelka/a71cfec6fac6d9193ae88307d5452fe8 to your computer and use it in GitHub Desktop.

Select an option

Save michalpelka/a71cfec6fac6d9193ae88307d5452fe8 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <ros/ros.h>
#include <ros/subscriber.h>
#include <ros/publisher.h>
#include <pcl_ros/point_cloud.h>
std::unique_ptr<ros::Publisher> publisher;
void cloud_callback (const pcl::PointCloud<pcl::PointXYZI>& cloud_msg){
ROS_INFO("inside callback");
pcl::PointCloud<pcl::PointXYZI> cloud_out = cloud_msg;
publisher->publish(cloud_out);
}
int main (int argc, char** argv) {
ros::init (argc, argv, "cloud_sub");
ros::NodeHandle nh;
ros::Rate loop_rate(10);
ros::Subscriber sub;
sub = nh.subscribe ("/livox/lidar", 1, cloud_callback);
publisher = std::make_unique<ros::Publisher>(nh.advertise<pcl::PointCloud<pcl::PointXYZI>>("/livox/mirror", 1));
ros::spin();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment