00001 #include <nodelet/nodelet.h> 00002 #include <pluginlib/class_list_macros.hpp> 00003 #include <string> 00004 #include <ros/ros.h> 00005 #include <std_msgs/Bool.h> 00006 #include <std_msgs/Byte.h> 00007 #include <std_msgs/Time.h> 00008 00009 namespace test_nodelet 00010 { 00011 00012 class NodehandleTest : public nodelet::Nodelet 00013 { 00014 public: 00015 NodehandleTest(){}; 00016 virtual void onInit() 00017 { 00018 ros::NodeHandle nh = this->getNodeHandle(); 00019 ros::NodeHandle pnh = this->getPrivateNodeHandle(); 00020 global_pub_ = nh.advertise<std_msgs::Time>("/global", 1000); 00021 namespaced_pub_ = nh.advertise<std_msgs::Byte>("namespaced", 1000); 00022 private_pub_ = pnh.advertise<std_msgs::Bool>("private", 1000); 00023 } 00024 private: 00025 ros::Publisher global_pub_, namespaced_pub_, private_pub_; 00026 }; 00027 00028 } // namespace test_nodelet 00029 00030 PLUGINLIB_EXPORT_CLASS(test_nodelet::NodehandleTest, nodelet::Nodelet);