image_test.cpp
Go to the documentation of this file.
00001 #include "ros/ros.h"
00002 
00003 #include "sensor_msgs/Image.h"
00004 
00005 int main( int argc, char** argv )
00006 {
00007   ros::init( argc, argv, "cloud_test" );
00008 
00009   ros::NodeHandle n;
00010 
00011   ros::Publisher rgb_pub = n.advertise<sensor_msgs::Image>( "red_image", 0 );
00012 
00013   ros::Duration(0.1).sleep();
00014 
00015   sensor_msgs::Image red_image;
00016   red_image.header.frame_id = "/base_link";
00017   red_image.header.stamp = ros::Time::now();
00018   red_image.height = 100;
00019   red_image.width = 100;
00020   red_image.encoding = "rgb8";
00021   red_image.step = 3 * red_image.height;
00022 
00023   red_image.data.resize(3 * red_image.height * red_image.width);
00024   for (uint32_t i = 0; i < 3 * red_image.height * red_image.width; ++i)
00025   {
00026     if (i % 3 == 0)
00027     {
00028       red_image.data[i] = 255;
00029     }
00030     else
00031     {
00032       red_image.data[i] = 0;
00033     }
00034   }
00035 
00036   int i = 0;
00037   while (n.ok())
00038   {
00039     ROS_INFO("Publishing");
00040 
00041     rgb_pub.publish(red_image);
00042 
00043     ++i;
00044 
00045     ros::Duration(1.0).sleep();
00046   }
00047 }


rviz_qt
Author(s): Dave Hershberger
autogenerated on Fri Dec 6 2013 20:56:52