Dependencies:   mbed ros_lib_kinetic

Files at this revision

API Documentation at this revision

Comitter:
Malan005
Date:
Sat May 11 22:59:18 2019 +0000
Commit message:
robosub_led_communication

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
diff -r 000000000000 -r 4d4dbac79356 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat May 11 22:59:18 2019 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+//#include "Servo.h", not neccesary 
+#include <ros.h>
+#include <std_msgs/Int16.h>
+#include <std_msgs/Bool.h>
+
+
+ros::NodeHandle nh;// create node handle(executalbe file/object)
+
+DigitalOut my_led(LED1); //trouble shootong, test led blink
+ 
+
+RawSerial device(PA_15,PB_7); //begin communication on these pins on stm32,(connect to Rx1 and Tx1 (18,19) communication bus, on arduino mega 2560
+
+//std_msgs::Int16 led_msg;
+
+int light_state= 0; // creat varaible 
+
+void led_state_callback(const std_msgs::Int16& msg)
+{
+   
+   //DigitalOut 
+   light_state = msg.data; //
+   //device.putc(light_state); //value that gets sent to th ctream
+ }
+
+
+ros::Subscriber<std_msgs::Int16> led_state_subscriber("light_state", led_state_callback);
+
+int main() {
+  nh.initNode();  // start node
+  nh.subscribe(led_state_subscriber); 
+  my_led = 0;
+while(1){
+     device.putc(light_state);
+     my_led = !my_led;
+     nh.spinOnce();// calls all subscriber 
+     wait_ms(5);
+    }
+}
diff -r 000000000000 -r 4d4dbac79356 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat May 11 22:59:18 2019 +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 4d4dbac79356 ros_lib_kinetic.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ros_lib_kinetic.lib	Sat May 11 22:59:18 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/garyservin/code/ros_lib_kinetic/#a849bf78d77f