Dependencies: mbed ros_lib_kinetic
Diff: main.cpp
- Revision:
- 0:4d4dbac79356
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); + } +}