Personal fork

Dependencies:   Servo mbed rosserial_mbed_lib

Fork of rosserial_mbed by nucho

Committer:
garyservin
Date:
Thu May 01 06:20:36 2014 +0000
Revision:
5:e52b44294b2b
Parent:
3:dff241b66f84
Fixed some issues to run on hydro and Freescale KL25Z

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garyservin 5:e52b44294b2b 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
garyservin 5:e52b44294b2b 18 //char hello[13] = "hello world!";
garyservin 5:e52b44294b2b 19 char hello[13] = "Gary Servin!";
garyservin 5:e52b44294b2b 20 DigitalOut led = LED1;
nucho 0:06fc856e99ca 21
nucho 0:06fc856e99ca 22 int main() {
nucho 0:06fc856e99ca 23 nh.initNode();
nucho 0:06fc856e99ca 24 nh.advertise(chatter);
nucho 0:06fc856e99ca 25
nucho 0:06fc856e99ca 26 while (1) {
garyservin 5:e52b44294b2b 27 led = !led;
nucho 0:06fc856e99ca 28 str_msg.data = hello;
nucho 0:06fc856e99ca 29 chatter.publish( &str_msg );
nucho 0:06fc856e99ca 30 nh.spinOnce();
nucho 0:06fc856e99ca 31 wait_ms(1000);
nucho 0:06fc856e99ca 32 }
nucho 0:06fc856e99ca 33 }
nucho 0:06fc856e99ca 34
nucho 0:06fc856e99ca 35 #endif