How to check if a message has a header? (c++)
Is there any way program logic around whether a particular message contains a header (std_msgs/Header)? For example:
template <class MsgType>
ros::Time get_message_time(const boost::shared_ptr<MsgType>& msg)
{
if (hasHeader(msg))
{
return msg->header.stamp;
} else
{
return ros::Time::now();
}
}
This code will not compile with messages that do not contain a header. Is there another way?