![](/media/cache/profiles/2019-02-17_Foto_de_perfil_014_03.jpg.50x50_q85.jpg)
Personal fork
Dependencies: Servo mbed rosserial_mbed_lib
Fork of rosserial_mbed by
examples/HelloWorld.cpp@0:06fc856e99ca, 2011-08-19 (annotated)
- Committer:
- nucho
- Date:
- Fri Aug 19 09:06:16 2011 +0000
- Revision:
- 0:06fc856e99ca
- Child:
- 3:dff241b66f84
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:06fc856e99ca | 1 | //#define COMPILE_HELLOWORLD_CODE_ROSSERIAL |
nucho | 0:06fc856e99ca | 2 | #ifdef COMPILE_HELLOWORLD_CODE_ROSSERIAL |
nucho | 0:06fc856e99ca | 3 | |
nucho | 0:06fc856e99ca | 4 | /* |
nucho | 0:06fc856e99ca | 5 | * rosserial Publisher Example |
nucho | 0:06fc856e99ca | 6 | * Prints "hello world!" |
nucho | 0:06fc856e99ca | 7 | */ |
nucho | 0:06fc856e99ca | 8 | |
nucho | 0:06fc856e99ca | 9 | #include"mbed.h" |
nucho | 0:06fc856e99ca | 10 | #include <ros.h> |
nucho | 0:06fc856e99ca | 11 | #include <std_msgs/String.h> |
nucho | 0:06fc856e99ca | 12 | |
nucho | 0:06fc856e99ca | 13 | ros::NodeHandle nh; |
nucho | 0:06fc856e99ca | 14 | |
nucho | 0:06fc856e99ca | 15 | std_msgs::String str_msg; |
nucho | 0:06fc856e99ca | 16 | ros::Publisher chatter("chatter", &str_msg); |
nucho | 0:06fc856e99ca | 17 | |
nucho | 0:06fc856e99ca | 18 | char hello[13] = "hello world!"; |
nucho | 0:06fc856e99ca | 19 | |
nucho | 0:06fc856e99ca | 20 | int main() { |
nucho | 0:06fc856e99ca | 21 | nh.initNode(); |
nucho | 0:06fc856e99ca | 22 | nh.advertise(chatter); |
nucho | 0:06fc856e99ca | 23 | |
nucho | 0:06fc856e99ca | 24 | while (1) { |
nucho | 0:06fc856e99ca | 25 | str_msg.data = hello; |
nucho | 0:06fc856e99ca | 26 | chatter.publish( &str_msg ); |
nucho | 0:06fc856e99ca | 27 | nh.spinOnce(); |
nucho | 0:06fc856e99ca | 28 | wait_ms(1000); |
nucho | 0:06fc856e99ca | 29 | } |
nucho | 0:06fc856e99ca | 30 | } |
nucho | 0:06fc856e99ca | 31 | |
nucho | 0:06fc856e99ca | 32 | #endif |