Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
main.cpp
- Committer:
- scarter1
- Date:
- 2019-10-16
- Revision:
- 0:bd7941d8c490
File content as of revision 0:bd7941d8c490:
/*
* 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);
}
}