Demo for rosserial working with ROS2

Dependencies:   mbed ros_lib_melodic

Files at this revision

API Documentation at this revision

Comitter:
stivending
Date:
Fri Oct 29 12:36:50 2021 +0000
Commit message:
a working sample keeping to publish data;

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_melodic.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 91fdcf1ce3aa main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 29 12:36:50 2021 +0000
@@ -0,0 +1,36 @@
+/*
+ * rosserial Publisher Example
+ * Prints "hello world!"
+ */
+
+#include "mbed.h"
+#include "string.h"
+#include <ros.h>
+#include <std_msgs/String.h>
+
+ros::NodeHandle  nh;
+
+std_msgs::String str_msg;
+ros::Publisher chatter("chatter", &str_msg);
+
+char hello[] = "Hello from Nucleo";
+DigitalOut led = LED1;
+DigitalIn but(USER_BUTTON);
+
+int main() {
+    nh.initNode();
+    nh.advertise(chatter);
+
+    while (1) {
+        //if(but == 0) {
+        //    while(but == 0);
+            led = !led;
+            str_msg.data = hello;
+            chatter.publish( &str_msg );
+            nh.spinOnce();
+            
+        //}
+        
+        wait_ms(100);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 91fdcf1ce3aa mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 29 12:36:50 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
diff -r 000000000000 -r 91fdcf1ce3aa ros_lib_melodic.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ros_lib_melodic.lib	Fri Oct 29 12:36:50 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/garyservin/code/ros_lib_melodic/#da82487f547e