I am telling the following to you in a good way: DO NOT EXPECT PEOPLE TO SPOON-FEED YOU THE ANSWERS
If you want to be good at programming you must start to research, learn and practice.
Do basic Google searches. I am sure you know how to do a simple google search.
Answer:
You should use vector.push_back() instead of vector.insert().
You should add the entire Point32 message as an item into the vectors, NOT x, y and z separately.
Define a vector as vector<geometry_msgs::Point32> list_of_odoms;
Use the odometry subscriber callback to store current odometry values into a class variable of type Point32 (you just use position x and y along with theta[yaw] from orientation quaternion).
Append each odometry point data as an item into the vector list_of_odoms.push_back(current_odom_point32) where current_odom_point32 is a Point32 message that you just got from odom subscriber.
You can then get the vector item by index for calculating distance between this value and the previous value.
In case you cannot get anything working, try to break it down to simpler steps and solve that. Later incorporate what you did into the main code.
How to do it simple you ask?
Create a vector with Point32 messages.
Add / remove / modify existing items to that vector you created in step 1.
Print the current contents of the vector with a loop of your choice.
If something goes wrong then fix and redo until you get it right.
This will not work. Why? Because your vector contains items that are Point type. When you do P1.insert(P1.end(), P.z); You are trying to insert a float into a vector containing Point. Obviously, it will throw an error.
Again, same thing for P1.push_back(P.x);. You are trying to add float into a vector with Point type data. It will throw an error.
Finally, result_.list_of_odoms.insert(result_.list_of_odoms.end(), P1.begin(), P1.end());
You can just do push_back() - why are you using a function of that complexity? insert() is usually used to insert an item somewhere in-between the vector.
All you need is practice! Just a little bit, enough to understand the concept. Don’t get sucked into the entire topic.
I was confused about the geometry_msgs::Point type and how he interact with vector, cause when I put the push_back() appears " " so, I was thinking more than the interact, no like a C++ problem. Thanks for change my perspective.