j

Dependencies:   mbed ros_lib_indigo

Fork of rosserial_mbed_hello_world_publisher by Gary Servin

Committer:
zylofsiat
Date:
Fri Jun 16 13:42:17 2017 +0000
Revision:
1:1ae95f856d6e
Parent:
0:17fd7572aedb
y

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garyservin 0:17fd7572aedb 1 /*
garyservin 0:17fd7572aedb 2 * rosserial Publisher Example
garyservin 0:17fd7572aedb 3 * Prints "hello world!"
garyservin 0:17fd7572aedb 4 */
garyservin 0:17fd7572aedb 5
garyservin 0:17fd7572aedb 6 #include"mbed.h"
zylofsiat 1:1ae95f856d6e 7 #include <ros.h>
garyservin 0:17fd7572aedb 8 #include <std_msgs/String.h>
garyservin 0:17fd7572aedb 9
garyservin 0:17fd7572aedb 10 ros::NodeHandle nh;
garyservin 0:17fd7572aedb 11
garyservin 0:17fd7572aedb 12 std_msgs::String str_msg;
garyservin 0:17fd7572aedb 13 ros::Publisher chatter("chatter", &str_msg);
garyservin 0:17fd7572aedb 14
garyservin 0:17fd7572aedb 15 char hello[13] = "hello world!";
garyservin 0:17fd7572aedb 16
garyservin 0:17fd7572aedb 17 DigitalOut led = LED1;
garyservin 0:17fd7572aedb 18
garyservin 0:17fd7572aedb 19 int main() {
garyservin 0:17fd7572aedb 20 nh.initNode();
garyservin 0:17fd7572aedb 21 nh.advertise(chatter);
garyservin 0:17fd7572aedb 22
garyservin 0:17fd7572aedb 23 while (1) {
garyservin 0:17fd7572aedb 24 led = !led;
garyservin 0:17fd7572aedb 25 str_msg.data = hello;
garyservin 0:17fd7572aedb 26 chatter.publish( &str_msg );
garyservin 0:17fd7572aedb 27 nh.spinOnce();
garyservin 0:17fd7572aedb 28 wait_ms(1000);
garyservin 0:17fd7572aedb 29 }
garyservin 0:17fd7572aedb 30 }