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