00001 /* 00002 * rosserial Subscriber Example 00003 * Blinks an LED on callback 00004 */ 00005 #include "mbed.h" 00006 #include <ros.h> 00007 #include <std_msgs/Empty.h> 00008 00009 ros::NodeHandle nh; 00010 DigitalOut myled(LED1); 00011 00012 void messageCb(const std_msgs::Empty& toggle_msg){ 00013 myled = !myled; // blink the led 00014 } 00015 00016 ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb); 00017 00018 int main() { 00019 nh.initNode(); 00020 nh.subscribe(sub); 00021 00022 while (1) { 00023 nh.spinOnce(); 00024 wait_ms(1); 00025 } 00026 } 00027