This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.

Dependencies:   rosserial_mbed_lib mbed Servo

examples/HelloWorld.cpp

Committer:
nucho
Date:
2011-11-12
Revision:
3:dff241b66f84
Parent:
0:06fc856e99ca

File content as of revision 3:dff241b66f84:

#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!";

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

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

#endif