sub test

Dependencies:   mbed ros_lib_kinetic

Files at this revision

API Documentation at this revision

Comitter:
okapi
Date:
Wed Jun 19 11:16:04 2019 +0000
Commit message:
dsd

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	Wed Jun 19 11:16:04 2019 +0000
@@ -0,0 +1,23 @@
+#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;
+}
+
+ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb);
+
+int main(){
+    nh.getHardware()->setBaud(115200);
+    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	Wed Jun 19 11:16:04 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ros_lib_kinetic.lib	Wed Jun 19 11:16:04 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/garyservin/code/ros_lib_kinetic/#a849bf78d77f