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/Blink.cpp

Committer:
nucho
Date:
2012-02-29
Revision:
4:2cbca0ac2569
Parent:
0:06fc856e99ca

File content as of revision 4:2cbca0ac2569:

//#define COMPILE_BLINK_CODE_ROSSERIAL
#ifdef COMPILE_BLINK_CODE_ROSSERIAL

/*
 * rosserial Subscriber Example
 * Blinks an LED on callback
 */
#include "mbed.h"
#include <ros.h>
#include <std_msgs/Empty.h>

ros::NodeHandle  nh;
DigitalOut myled(LED1);

void messageCb( const std_msgs::Empty& toggle_msg) {
    myled = !myled;   // blink the led
}

ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb );

int main() {
    nh.initNode();
    nh.subscribe(sub);

    while (1) {
        nh.spinOnce();
        wait_ms(1);
    }
}

#endif