00001 00023 #include "testnc/testnc.h" 00024 00025 // Register the application 00026 PLUGINLIB_EXPORT_CLASS(testnc::TestNC, micros_swarm::Application) 00027 00028 namespace testnc{ 00029 00030 TestNC::TestNC() {} 00031 00032 TestNC::~TestNC() {} 00033 00034 void TestNC::init() {} 00035 00036 void TestNC::stop() {} 00037 00038 void TestNC::callback(const std_msgs::Float32& value) 00039 { 00040 //ROS_INFO("I received the value: %f.", value); 00041 } 00042 00043 void TestNC::start() 00044 { 00045 std::cout<<"TestNC step into start..."<<std::endl; 00046 micros_swarm::Broadcaster<std_msgs::Float32> bc("testkey"); 00047 boost::function<void(const std_msgs::Float32&)> cb=boost::bind(&TestNC::callback, this, _1); 00048 micros_swarm::Listener<std_msgs::Float32> ls("testkey", cb); 00049 //ls.ignore(); 00050 00051 for(int i = 0; i < 10; i++) { 00052 std_msgs::Float32 val; 00053 val.data = 3.141; 00054 bc.broadcast(val); 00055 ros::Duration(1).sleep(); 00056 } 00057 } 00058 }; 00059