Main Page
Namespaces
Classes
Files
File List
File Members
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
main
int main()
Definition:
HelloROS.cpp:18
ros::NodeHandle
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
str_msg
std_msgs::String str_msg
Definition:
HelloROS.cpp:12
chatter
ros::Publisher chatter("chatter",&str_msg)
ros::NodeHandle::advertise
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
hello
char hello[13]
Definition:
HelloROS.cpp:16
ros::Publisher
nh
ros::NodeHandle nh
Definition:
HelloROS.cpp:10
rosSrvrIp
char * rosSrvrIp
Definition:
HelloROS.cpp:15
rosserial_embeddedlinux
Author(s): Paul Bouchier
autogenerated on Mon Jun 10 2019 14:53:23