Main Page
Namespaces
Classes
Files
File List
File Members
src
examples
Blink
Blink.cpp
Go to the documentation of this file.
1
/*
2
* rosserial Subscriber Example
3
* Blinks an LED on callback
4
*/
5
#include "mbed.h"
6
#include <ros.h>
7
#include <std_msgs/Empty.h>
8
9
ros::NodeHandle
nh
;
10
DigitalOut
myled
(LED1);
11
12
void
messageCb
(
const
std_msgs::Empty& toggle_msg){
13
myled
= !
myled
;
// blink the led
14
}
15
16
ros::Subscriber<std_msgs::Empty>
sub
(
"toggle_led"
, &
messageCb
);
17
18
int
main
() {
19
nh.initNode();
20
nh.
subscribe
(sub);
21
22
while
(1) {
23
nh.spinOnce();
24
wait_ms(1);
25
}
26
}
27
main
int main()
Definition:
Blink.cpp:18
ros::Subscriber
ros::NodeHandle
sub
ros::Subscriber< std_msgs::Empty > sub("toggle_led",&messageCb)
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
messageCb
void messageCb(const std_msgs::Empty &toggle_msg)
Definition:
Blink.cpp:12
nh
ros::NodeHandle nh
Definition:
Blink.cpp:9
myled
DigitalOut myled(LED1)
rosserial_mbed
Author(s): Gary Servin
autogenerated on Mon Jun 10 2019 14:53:26