ros_serial for mbed updated to work with ROS Hydro. Library still needs to be debugged

Dependencies:   rosserial_hydro

Library and program still under development!

Committer:
akashvibhute
Date:
Sun Feb 15 10:56:37 2015 +0000
Revision:
1:225298843679
Parent:
0:cb1dffdc7d05
rosserial_mbed for hydro testing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:cb1dffdc7d05 1 //#define COMPILE_BLINK_CODE_ROSSERIAL
akashvibhute 0:cb1dffdc7d05 2 #ifdef COMPILE_BLINK_CODE_ROSSERIAL
akashvibhute 0:cb1dffdc7d05 3
akashvibhute 0:cb1dffdc7d05 4 /*
akashvibhute 0:cb1dffdc7d05 5 * rosserial Subscriber Example
akashvibhute 0:cb1dffdc7d05 6 * Blinks an LED on callback
akashvibhute 0:cb1dffdc7d05 7 */
akashvibhute 0:cb1dffdc7d05 8 #include "mbed.h"
akashvibhute 0:cb1dffdc7d05 9 #include <ros.h>
akashvibhute 0:cb1dffdc7d05 10 #include <std_msgs/Empty.h>
akashvibhute 0:cb1dffdc7d05 11
akashvibhute 0:cb1dffdc7d05 12 ros::NodeHandle nh;
akashvibhute 0:cb1dffdc7d05 13 DigitalOut myled(LED1);
akashvibhute 0:cb1dffdc7d05 14
akashvibhute 0:cb1dffdc7d05 15 void messageCb( const std_msgs::Empty& toggle_msg) {
akashvibhute 0:cb1dffdc7d05 16 myled = !myled; // blink the led
akashvibhute 0:cb1dffdc7d05 17 }
akashvibhute 0:cb1dffdc7d05 18
akashvibhute 0:cb1dffdc7d05 19 ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb );
akashvibhute 0:cb1dffdc7d05 20
akashvibhute 0:cb1dffdc7d05 21 int main() {
akashvibhute 0:cb1dffdc7d05 22 nh.initNode();
akashvibhute 0:cb1dffdc7d05 23 nh.subscribe(sub);
akashvibhute 0:cb1dffdc7d05 24
akashvibhute 0:cb1dffdc7d05 25 while (1) {
akashvibhute 0:cb1dffdc7d05 26 nh.spinOnce();
akashvibhute 0:cb1dffdc7d05 27 wait_ms(1);
akashvibhute 0:cb1dffdc7d05 28 }
akashvibhute 0:cb1dffdc7d05 29 }
akashvibhute 0:cb1dffdc7d05 30
akashvibhute 0:cb1dffdc7d05 31 #endif