meilleur squelette de filtre

This commit is contained in:
Louis-Guillaume DUBOIS 2015-04-22 18:31:16 +02:00
parent 0c35151312
commit da3c812832
2 changed files with 13 additions and 7 deletions

View file

@ -8,15 +8,18 @@ class Callback {
public:
void operator()(const PointCloud::ConstPtr& msg)
{
ROS_INFO("PointCloud received");
// pour publier un shared_ptr (mieux)
PointCloud::Ptr pcl;
// copie du nuage de point
PointCloud pcl = *msg;
*pcl = *msg;
// TODO : ôter les mauvais points
publisher.publish(pcl);
ROS_INFO("PointCloud published");
}
Callback(ros::NodeHandle& node)
{
publisher = node.advertise<PointCloud>("output", 1);
}
Callback(ros::Publisher& pub) : publisher(pub) {}
private:
ros::Publisher publisher;
};
@ -25,8 +28,11 @@ int main(int argc, char** argv)
{
ros::init(argc, argv, "filtre");
ros::NodeHandle node;
Callback callback(node);
ros::Subscriber subscriber = node.subscribe<PointCloud>("input", 1, callback);
ros::Publisher publisher = node.advertise<PointCloud>("filtre_output", 1);
Callback callback(publisher);
ros::Subscriber subscriber = node.subscribe<PointCloud>("filtre_input", 1, callback);
ROS_INFO("node started");
ros::spin();
ROS_INFO("exit");
return 0;
}