Main Page
Namespaces
Classes
Files
File List
File Members
src
examples
HelloWorld
HelloWorld.cpp
Go to the documentation of this file.
1
/*
2
* rosserial Publisher Example
3
* Prints "hello world!"
4
*/
5
6
#include"mbed.h"
7
#include <ros.h>
8
#include <std_msgs/String.h>
9
10
ros::NodeHandle
nh
;
11
12
std_msgs::String
str_msg
;
13
ros::Publisher
chatter
(
"chatter"
, &
str_msg
);
14
15
char
hello
[13] =
"hello world!"
;
16
17
DigitalOut
led
= LED1;
18
19
int
main
() {
20
nh.initNode();
21
nh.
advertise
(
chatter
);
22
23
while
(1) {
24
led
= !
led
;
25
str_msg
.data =
hello
;
26
chatter
.
publish
( &
str_msg
);
27
nh.spinOnce();
28
wait_ms(1000);
29
}
30
}
31
ros::NodeHandle
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
hello
char hello[13]
Definition:
HelloWorld.cpp:15
nh
ros::NodeHandle nh
Definition:
HelloWorld.cpp:10
led
DigitalOut led
Definition:
HelloWorld.cpp:17
main
int main()
Definition:
HelloWorld.cpp:19
ros::NodeHandle::advertise
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
chatter
ros::Publisher chatter("chatter",&str_msg)
str_msg
std_msgs::String str_msg
Definition:
HelloWorld.cpp:12
ros::Publisher
rosserial_mbed
Author(s): Gary Servin
autogenerated on Mon Jun 10 2019 14:53:26