# Revision history [back]

So I'll admit that your question as written isn't entirely clear to me what you're trying to accomplish. What I do gather from it is you're interesting in how to use an array type in a ros message, where the example you want is a Pose. I can help with that. Though looking at your code you don't actually use the vector of Poses variable you create at the beginning. See sample below.

geometry_msgs::PoseArray my_poses;

// my_poses.poses is going to be your array of pose messages. In C++ its a vector.

for (uint i = 0; i != 7; i++) {
geometry_msgs::Pose curr_pose;
curr_pose.position.x = 42.0;
my_poses.poses.push_back(curr_pose);
}


so as you can see, its just a vector object your working with where the vector starts with size 0, so you have to either push_back new elements or reserve/resize with your known number of elements.

So I'll admit that your question as written isn't entirely clear to me what you're trying to accomplish. What I do gather from it is you're interesting in how to use an array type in a ros message, where the example you want is a Pose. I can help with that. Though looking at your code you don't actually use the vector of Poses variable you create at the beginning. See sample below.

geometry_msgs::PoseArray my_poses;

// my_poses.poses is going to be your array of pose messages. In C++ its a vector.

for (uint i = 0; i != 7; i++) {
geometry_msgs::Pose curr_pose;
curr_pose.position.x = 42.0;
my_poses.poses.push_back(curr_pose);
}


so as you can see, its just a vector object your working with where the vector starts with size 0, so you have to either push_back new elements or reserve/resize with your known number of elements.

If you look at it, the definition of a geometry_msgs/PoseArray is

std_msgs/Header header
uint32 seq
time stamp
string frame_id
geometry_msgs/Pose[] poses
geometry_msgs/Point position
float64 x
float64 y
float64 z
geometry_msgs/Quaternion orientation
float64 x
float64 y
float64 z
float64 w


so this shows on a general basis has to use a variable[] type as a ros message.