标签: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; }
标签:ros
原文地址:http://blog.csdn.net/dxuehui/article/details/42146933