talker.cpp
Go to the documentation of this file.
1 
11 /*****************************************************************************
12 ** Includes
13 *****************************************************************************/
14 
15 #include "ros/ros.h"
16 #include "std_msgs/String.h"
17 
18 #include <sstream>
19 
23 int main(int argc, char **argv)
24 {
35  ros::init(argc, argv, "talker");
36 
43 
61 // %Tag(PUBLISHER)%
62  ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
63 // %EndTag(PUBLISHER)%
64 
65 // %Tag(LOOP_RATE)%
66  ros::Rate loop_rate(10);
67 // %EndTag(LOOP_RATE)%
68 
73 // %Tag(ROS_OK)%
74  int count = 0;
75  while (ros::ok())
76  {
77 // %EndTag(ROS_OK)%
81 // %Tag(FILL_MESSAGE)%
82  std_msgs::String msg;
83 
84  std::stringstream ss;
85  ss << "hello world " << count;
86  msg.data = ss.str();
87 // %EndTag(FILL_MESSAGE)%
88 
89 // %Tag(ROSCONSOLE)%
90  ROS_INFO("%s", msg.data.c_str());
91 // %EndTag(ROSCONSOLE)%
92 
99 // %Tag(PUBLISH)%
100  chatter_pub.publish(msg);
101 // %EndTag(PUBLISH)%
102 
103 // %Tag(SPINONCE)%
104  ros::spinOnce();
105 // %EndTag(SPINONCE)%
106 
107 // %Tag(RATE_SLEEP)%
108  loop_rate.sleep();
109 // %EndTag(RATE_SLEEP)%
110  ++count;
111  }
112 
113 
114  return 0;
115 }
116 // %EndTag(FULLTEXT)%
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
#define ROS_INFO(...)
int main(int argc, char **argv)
Definition: talker.cpp:23
ROSCPP_DECL bool ok()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ROSCPP_DECL void spinOnce()


rocon_unreliable_experiments
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 14:40:17