码迷,mamicode.com
首页 > 编程语言 > 详细

std_msgs::UInt8MultiArray发布数组

时间:2014-12-25 16:28:08      阅读:1269      评论:0      收藏:0      [点我收藏+]

标签:ros

#include "ros/ros.h"
#include "std_msgs/Float32.h"
#include <sstream>
#include <iostream>
#include "std_msgs/UInt8MultiArray.h"
#include "std_msgs/MultiArrayDimension.h"
using namespace std;
int main(int argc, char **argv)
{

  ros::init(argc, argv, "talker");
  ros::NodeHandle n;


  ros::Publisher chatter_pub = n.advertise<std_msgs::UInt8MultiArray>("chatter", 1000);
  ros::Rate loop_rate(10);
  while (ros::ok())
  {
	std_msgs::MultiArrayLayout msg;
 
const unsigned int data_sz = 10;
std_msgs::UInt8MultiArray m;

m.layout.dim.push_back(std_msgs::MultiArrayDimension());
m.layout.dim[0].size = data_sz;
m.layout.dim[0].stride = 1;
m.layout.dim[0].label = "bla";
cout<<"==========================="<<endl;

// only needed if you don't want to use push_back
m.data.resize(data_sz);
m.data[0] = 2;
m.data[1] = 1;



 chatter_pub.publish(m);  
 ros::spinOnce();

 loop_rate.sleep();

  }


  return 0;
}



std_msgs::UInt8MultiArray发布数组

标签:ros

原文地址:http://blog.csdn.net/dxuehui/article/details/42146933

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!