Main Page
Namespaces
Namespace List
Namespace Members
All
Functions
Variables
Typedefs
Classes
Class List
Class Members
All
Functions
Variables
Files
File List
File Members
All
b
c
d
e
g
h
i
m
n
r
s
u
Functions
Variables
c
g
h
i
m
n
r
s
Macros
src
examples
HelloRos
HelloROS.cpp
Go to the documentation of this file.
1
/*
2
* rosserial Publisher Example
3
* Prints "hello ROS!"
4
*/
5
6
#include <ros.h>
7
#include <std_msgs/String.h>
8
#include <stdio.h>
9
10
ros::NodeHandle
nh
;
11
12
std_msgs::String
str_msg
;
13
ros::Publisher
chatter
(
"chatter"
, &
str_msg
);
14
15
char
*
rosSrvrIp
=
"192.168.15.121"
;
16
char
hello
[13] =
"Hello ROS!"
;
17
18
int
main
()
19
{
20
//nh.initNode();
21
nh
.initNode(
rosSrvrIp
);
22
nh
.
advertise
(
chatter
);
23
while
(1) {
24
str_msg
.data =
hello
;
25
chatter
.
publish
( &
str_msg
);
26
nh
.spinOnce();
27
printf(
"chattered\n"
);
28
sleep(1);
29
}
30
}
31
ros::Publisher
main
int main()
Definition:
HelloROS.cpp:18
str_msg
std_msgs::String str_msg
Definition:
HelloROS.cpp:12
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
chatter
ros::Publisher chatter("chatter", &str_msg)
nh
ros::NodeHandle nh
Definition:
HelloROS.cpp:10
hello
char hello[13]
Definition:
HelloROS.cpp:16
ros::NodeHandle
rosSrvrIp
char * rosSrvrIp
Definition:
HelloROS.cpp:15
rosserial_embeddedlinux
Author(s): Paul Bouchier
autogenerated on Wed Mar 2 2022 00:58:06