![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
rosserial_mbed blink example for Kinetic distribution
Dependencies: mbed ros_lib_kinetic
main.cpp
- Committer:
- Jaimelt
- Date:
- 2017-12-04
- Revision:
- 0:e2b1caa9af4c
File content as of revision 0:e2b1caa9af4c:
/* * rosserial Subscriber Example * Blinks an LED on callback */ #include "mbed.h" #include <ros.h> #include <std_msgs/Empty.h> ros::NodeHandle nh; DigitalOut myled(LED1); void messageCb(const std_msgs::Empty& toggle_msg){ myled = !myled; // blink the led } ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb); int main() { nh.initNode(); nh.subscribe(sub); while (1) { nh.spinOnce(); wait_ms(1); } }