dynamic ros message
Hello, I search a way to dynamically create message handling. That means i want a function:
//main.h
createHandler(GENERALMSGTYPE geo_msg,std::vector(double) array){
for(int i=0;i<array.size();i++){
geo_msg.data[i]=array[i];
}
}
That takes any type of message and writes serially to the data.
//int main()
vector<double> array; //Global array
array.push_back(0.1);
array.push_back(0.2);
array.push_back(0.3);
array.push_back(0.4);
array.push_back(0.5);
array.push_back(0.6);
geometry_msgs::PoseStamped geo_msg;
createHandler(geo_msg,std::vector(double) array);
Is it possible to access the message dynamically, to be able to use a function that can get any message type?! I would like to generate code in respect to the given message type. Do you have any ideas, how to do this?