How to create a ros::MessageEvent object
Hi,
I want to test a method which is called after a callback, receiving as argument a ros::MessageEvent<std_msgs::float32> variable. I looked at the documentation here, but couldn't see a clear way to create such object.
Based on my callback function:
void NodeSubscriber::topicCallback(const ros::MessageEvent<std_msgs::Float32 const>& message)
{
nodeObject_.updateObjectData(message);
}
and following the public method of the class MessageEvent:
MessageEvent (const ConstMessagePtr &message, ros::Time receipt_time);
I tried something along the lines of:
double value = 1.5;
ros::Time timestamp(5);
ros::MessageEvent<std_msgs::Float32> message(value, timestamp);
without success.
What am I missing here ?
Thanks for your help.
Just a note: a
MessagEvent
!= a message. It's more than that.I know, this is semantics (ie: naming), but important.
Could you clarify why you pass the
MessageEvent
itself, and not theFloat32
?The topic I'm listening doesn't have an header with a timestamp. I do need to have an approximate idea of when the message is published. I am aware that with MessageEvent I'll be getting a timestamp when the node received the message and not when it was published.