Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo roscar_ver_20190501_anglechange_copy ros_lib_kinetic roscar_ver_20190501_copy
Diff: main.cpp
- Revision:
- 0:2595562b0c61
- Child:
- 1:fb8f963047b0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Aug 10 21:02:43 2018 +0000
@@ -0,0 +1,38 @@
+/*
+ * rosserial Subscriber Example
+ * Blinks an LED on callback
+ */
+#include "mbed.h"
+#include <ros.h>
+#include <std_msgs/String.h>
+
+ros::NodeHandle nh;
+DigitalOut myled(LED1);
+
+std_msgs::String commandRead;
+ros::Publisher chatter("chatter", &commandRead);
+
+// /*
+void messageCb(const std_msgs::String& command){
+ myled = 1; // turn on the led
+ commandRead.data = command.data;
+}
+// */
+
+ros::Subscriber<std_msgs::String> sub("toggle_led", &messageCb);
+
+//char message[13] = "012345678910";
+
+int main() {
+ nh.initNode();
+ nh.subscribe(sub);
+ nh.advertise(chatter);
+
+ while (1) {
+ myled = 0; // turn off the led
+ // commandRead.data = message ;
+ chatter.publish( &commandRead);
+ nh.spinOnce();
+ wait_ms(1);
+ }
+}