I need to transfer from `sensor_msgs::LaserScan` to `sensor_msgs::PointCloud2`. I found laser_geometry package, (http://wiki.ros.org/laser_geometry). Because there is no ROS API, I found a link which helps. The link is (https://answers.ros.org/question/11232/how-to-turn-laser-scan-to-point-cloud-map/). I compiled the .cpp file same to the link:
#include "laser_geometry/laser_geometry.h"
#include
#include
#include
#include
#include "ros/ros.h"
class My_Filter{
public:
My_Filter();
void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan);
private:
ros::NodeHandle node_;
laser_geometry::LaserProjection projector_;
tf::TransformListener tfListener_;
ros::Publisher point_cloud_publisher_;
ros::Subscriber scan_sub_;
};
My_Filter::My_Filter(){
scan_sub_ = node_.subscribe ("/scan", 100, &My_Filter::scanCallback, this);
point_cloud_publisher_ = node_.advertise ("filtered_cloud", 100, false);
tfListener_.setExtrapolationLimit(ros::Duration(0.1));
}
void My_Filter::scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan){
sensor_msgs::PointCloud2 cloud;
projector_.transformLaserScanToPointCloud("base_link", *scan, cloud, tfListener_);
point_cloud_publisher_.publish(cloud);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "my_filter");
My_Filter filter;
ros::spin();
return 0;
}
from my cmakelist.txt and package.xml, I wrote a launch file
`target_link_libraries(laser_geometry ${Boost_LIBRARIES} ${tf_LIBRARIES})`, `laser_geometry `
But I can't launch this node.
ERROR: cannot launch node of type [laser_geometry/laser_geometry]: can't locate node [laser_geometry] in package [laser_geometry]
Could you please give me some hints? How to use the laser_geometry package and launch the node? Thank you!
↧