00001 /* 00002 * rosserial PubSub Example 00003 * Prints "hello world!" and toggles led 00004 */ 00005 00006 #include <ros.h> 00007 #include <std_msgs/String.h> 00008 #include <std_msgs/Empty.h> 00009 00010 ros::NodeHandle nh; 00011 00012 std_msgs::String str_msg; 00013 ros::Publisher chatter("chatter", &str_msg); 00014 00015 char hello[13] = "hello world!"; 00016 00017 char debug[]= "debug statements"; 00018 char info[] = "infos"; 00019 char warn[] = "warnings"; 00020 char errors[] = "errors"; 00021 char fatal[] = "fatalities"; 00022 00023 int main() { 00024 nh.initNode(); 00025 nh.advertise(chatter); 00026 00027 while (1) { 00028 str_msg.data = hello; 00029 chatter.publish( &str_msg ); 00030 00031 nh.logdebug(debug); 00032 nh.loginfo(info); 00033 nh.logwarn(warn); 00034 nh.logerror(errors); 00035 nh.logfatal(fatal); 00036 00037 nh.spinOnce(); 00038 wait_ms(500); 00039 } 00040 } 00041