rosserial_mbed blink example for Kinetic distribution

Dependencies:   mbed ros_lib_kinetic

Files at this revision

API Documentation at this revision

Comitter:
Jaimelt
Date:
Mon Dec 04 10:07:13 2017 +0000
Commit message:
Initial commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
ros_lib_kinetic.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 04 10:07:13 2017 +0000
@@ -0,0 +1,26 @@
+/*
+ * 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);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 04 10:07:13 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ros_lib_kinetic.lib	Mon Dec 04 10:07:13 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/garyservin/code/ros_lib_kinetic/#a849bf78d77f