Modify contents of a custom message pointer?
I have a custom message I've created, I want to pass a pointer to this message from one function to another and modify the contents of the message, however ROS doesn't seem to want to allow me to do this. Is there a way to do it without having to pass the message and use the function return to overwrite the original message?
I would imagine something like this:
void change_value(my::custom_message::Ptr &msg){
msg->value = msg->value + 1;
}
int main(){
my::custom_message original;
change_value(&original);
}
Rather than this:
my::custom_message change_value(my::custom_message msg){
my::custom_message ret;
ret.value = msg.value + 1;
return ret;
}
int main(){
my::custom_message original;
original = change_value(original);
}
Asked by MWrock on 2017-07-08 11:46:23 UTC
Comments
This reads more like a C++ problem than a ROS problem, but without you telling us why "ROS doesn't seem to want to allow [you] to do this" it's going to be hard to help you.
Asked by gvdhoorn on 2017-07-08 16:05:48 UTC