Horje
c++ ros publisher Code Example
c++ ros publisher
#include "ros/ros.h"
#include "std_msgs/String.h"

#include <sstream>

/**
 * This tutorial demonstrates simple sending of messages over the ROS system.
 */
int main(int argc, char **argv)
{
  ros::init(argc, argv, "talker");

  ros::NodeHandle n;

  ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);

  ros::Rate loop_rate(10);

  int count = 0;
  while (ros::ok())
  {
    std_msgs::String msg;

    std::stringstream ss;
    ss << "hello world " << count;
    msg.data = ss.str();

    ROS_INFO("%s", msg.data.c_str());

    chatter_pub.publish(msg);

    ros::spinOnce();

    loop_rate.sleep();
    ++count;
  }

  return 0;
}
Source: wiki.ros.org




Cpp

Related
format string cpp Code Example format string cpp Code Example
convert string to number c++ Code Example convert string to number c++ Code Example
get first element of tuple c++ Code Example get first element of tuple c++ Code Example
typedef vector c++ Code Example typedef vector c++ Code Example
how to convert int to string c++ Code Example how to convert int to string c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10