publish_screenpoint.cpp
Go to the documentation of this file.
00001 // http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29
00002 #include "ros/ros.h"
00003 #include "geometry_msgs/PointStamped.h"
00004 
00005 #include <math.h>
00006 
00007 int main(int argc, char **argv)
00008 {
00009   ros::init(argc, argv, "publish_screenpoint");
00010 
00011   ros::NodeHandle n;
00012   ros::Publisher pub = n.advertise<geometry_msgs::PointStamped>("/image_painted/screenpoint", 1000);
00013 
00014   ros::Rate loop_rate(10);
00015   double i = 0;
00016   while (ros::ok())
00017     {
00018       geometry_msgs::PointStamped msg;
00019       msg.header.stamp = ros::Time().now();
00020       msg.point.x = 320 + 180*sin(i);
00021       msg.point.y = 240 + 180*cos(i);
00022       i += 0.1;
00023       ROS_INFO("%5.1f %5.1f", msg.point.x, msg.point.y);
00024       pub.publish(msg);
00025       ros::spinOnce();
00026       loop_rate.sleep();
00027     }
00028 
00029   return 0;
00030 }


opencv_ros_bridge_tutorial
Author(s): Kei Okada
autogenerated on Mon Oct 6 2014 12:08:15