#include <iostream>
#include "ros/ros.h"
#include "demo_msgs/Team.h"
using namespace std;
void callback(const demo_msgs::Team::ConstPtr &message) {
cout << message->name << endl;
cout << message->leader.name << endl;
cout << message->leader.age << endl;
cout << message->intro.data << endl;
cout << message->location.linear.x << endl;
cout << message->location.linear.y << endl;
cout << message->location.linear.z << endl;
cout << message->location.angular.x << endl;
cout << message->location.angular.y << endl;
cout << message->location.angular.z << endl;
cout << "-----------------------" << endl;
}
int main(int argc, char **argv) {
// 创建节点
string nodeName = "my_subscriber4";
ros::init(argc, argv, nodeName);
ros::NodeHandle node;
//创建订阅者
string topicName = "my_topic4";
const ros::Subscriber &subscriber = node.subscribe(topicName, 1000, callback);
ros::spin();
return 0;
}