Personal fork

Dependencies:   Servo mbed rosserial_mbed_lib

Fork of rosserial_mbed by nucho

examples/HelloWorld.cpp

Committer:
garyservin
Date:
2014-05-01
Revision:
5:e52b44294b2b
Parent:
3:dff241b66f84

File content as of revision 5:e52b44294b2b:

//#define COMPILE_HELLOWORLD_CODE_ROSSERIAL
#ifdef  COMPILE_HELLOWORLD_CODE_ROSSERIAL

/*
 * rosserial Publisher Example
 * Prints "hello world!"
 */

#include"mbed.h"
#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle  nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

//char hello[13] = "hello world!";
char hello[13] = "Gary Servin!";
DigitalOut led = LED1;

int main() {
    nh.initNode();
    nh.advertise(chatter);

    while (1) {
        led = !led;
        str_msg.data = hello;
        chatter.publish( &str_msg );
        nh.spinOnce();
        wait_ms(1000);
    }
}

#endif