Create a std::vector of msgs
Hello all,
I'm trying to create a vector of a custom msg that I have declared. The msgs contains the following line:
float64[] LuT //where LuT is a look up table I want to publish as a msg.
But when I'm trying to create a std::vector of msgs like so:
std::vector < parse_and_pub::Lookuptable::LuT> tables;
Of course including the generated header:
#include "parse_and_pub/Lookuptable.h"
I get the following errors:
/home/name/hydro_ws/src/parse_and_pub/src/ParseAndPub.h:32: error: ‘parse_and_pub::Lookuptable_<std::allocator<void> >::LuT’ cannot appear in a constant-expression
/home/name/hydro_ws/src/parse_and_pub/src/ParseAndPub.h:32: error: template argument 1 is invalid
/home/name/hydro_ws/src/parse_and_pub/src/ParseAndPub.h:32: error: template argument 2 is invalid
Any idea If I'm doing something wrong, or if this is intended ?
Edit: creating a:
std::vector < parse_and_pub::LookuptableConstPtr> tables;
works. But how can I access and fill this vector? tables[index].push_back() doesn't work.
Edit2: Thank you all for your answers, but it's not quite what I wanted. I tried a different approach and seems to work for now.
1) declared the vector of msgs as:
std::vector <parse_and_pub::Lookuptable> tables;
2) populate the vectors like so:
for(...;...;....){ //iterate the outer std::vector
parse_and_pub::Lookuptable temp; //a temp to store the i-th look up table
for(...;...;....){ //iterate the inner vector
//fill the temp variable
temp.LuT.push_back(some_value);
}
tables.push_back(temp);//push back the temp variable in the outer vector
}
Do you want to create a vector of your message or a vector of doubles?
std::vector < parse_and_pub::LookuptableConstPtr> tables;
is a vector of messages.std::vector<double> tables
would be the equivalent tofloat64[] LuT
@BennyRe , thanks for answering. I want to create a vector of messages. But by using
I don't know how to fill the message array.