ros_serial for mbed updated to work with ROS Hydro. Library still needs to be debugged
Library and program still under development!
examples/Logging.cpp@1:225298843679, 2015-02-15 (annotated)
- Committer:
- akashvibhute
- Date:
- Sun Feb 15 10:56:37 2015 +0000
- Revision:
- 1:225298843679
- Parent:
- 0:cb1dffdc7d05
rosserial_mbed for hydro testing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akashvibhute | 0:cb1dffdc7d05 | 1 | //#define COMPILE_LOGGING_CODE_ROSSERIAL |
akashvibhute | 0:cb1dffdc7d05 | 2 | #ifdef COMPILE_LOGGING_CODE_ROSSERIAL |
akashvibhute | 0:cb1dffdc7d05 | 3 | |
akashvibhute | 0:cb1dffdc7d05 | 4 | /* |
akashvibhute | 0:cb1dffdc7d05 | 5 | * rosserial PubSub Example |
akashvibhute | 0:cb1dffdc7d05 | 6 | * Prints "hello world!" and toggles led |
akashvibhute | 0:cb1dffdc7d05 | 7 | */ |
akashvibhute | 0:cb1dffdc7d05 | 8 | |
akashvibhute | 0:cb1dffdc7d05 | 9 | #include <ros.h> |
akashvibhute | 0:cb1dffdc7d05 | 10 | #include <std_msgs/String.h> |
akashvibhute | 0:cb1dffdc7d05 | 11 | #include <std_msgs/Empty.h> |
akashvibhute | 0:cb1dffdc7d05 | 12 | |
akashvibhute | 0:cb1dffdc7d05 | 13 | ros::NodeHandle nh; |
akashvibhute | 0:cb1dffdc7d05 | 14 | |
akashvibhute | 0:cb1dffdc7d05 | 15 | std_msgs::String str_msg; |
akashvibhute | 0:cb1dffdc7d05 | 16 | ros::Publisher chatter("chatter", &str_msg); |
akashvibhute | 0:cb1dffdc7d05 | 17 | |
akashvibhute | 0:cb1dffdc7d05 | 18 | char hello[13] = "hello world!"; |
akashvibhute | 0:cb1dffdc7d05 | 19 | |
akashvibhute | 0:cb1dffdc7d05 | 20 | char debug[]= "debug statements"; |
akashvibhute | 0:cb1dffdc7d05 | 21 | char info[] = "infos"; |
akashvibhute | 0:cb1dffdc7d05 | 22 | char warn[] = "warnings"; |
akashvibhute | 0:cb1dffdc7d05 | 23 | char error[] = "errors"; |
akashvibhute | 0:cb1dffdc7d05 | 24 | char fatal[] = "fatalities"; |
akashvibhute | 0:cb1dffdc7d05 | 25 | |
akashvibhute | 0:cb1dffdc7d05 | 26 | int main() { |
akashvibhute | 0:cb1dffdc7d05 | 27 | nh.initNode(); |
akashvibhute | 0:cb1dffdc7d05 | 28 | nh.advertise(chatter); |
akashvibhute | 0:cb1dffdc7d05 | 29 | |
akashvibhute | 0:cb1dffdc7d05 | 30 | while (1) { |
akashvibhute | 0:cb1dffdc7d05 | 31 | str_msg.data = hello; |
akashvibhute | 0:cb1dffdc7d05 | 32 | chatter.publish( &str_msg ); |
akashvibhute | 0:cb1dffdc7d05 | 33 | |
akashvibhute | 0:cb1dffdc7d05 | 34 | nh.logdebug(debug); |
akashvibhute | 0:cb1dffdc7d05 | 35 | nh.loginfo(info); |
akashvibhute | 0:cb1dffdc7d05 | 36 | nh.logwarn(warn); |
akashvibhute | 0:cb1dffdc7d05 | 37 | nh.logerror(error); |
akashvibhute | 0:cb1dffdc7d05 | 38 | nh.logfatal(fatal); |
akashvibhute | 0:cb1dffdc7d05 | 39 | |
akashvibhute | 0:cb1dffdc7d05 | 40 | nh.spinOnce(); |
akashvibhute | 0:cb1dffdc7d05 | 41 | wait_ms(500); |
akashvibhute | 0:cb1dffdc7d05 | 42 | } |
akashvibhute | 0:cb1dffdc7d05 | 43 | } |
akashvibhute | 0:cb1dffdc7d05 | 44 | |
akashvibhute | 0:cb1dffdc7d05 | 45 | #endif |