Best way to deal with diagnostic message compatibility
I recently upgraded to ROS hydro, and I can no longer read the /diagnostics message from bag files created prior to hydro. The sample code is:
rosbag::View view(bag, rosbag::TopicQuery(string("/diagnostics")));
for (rosbag::View::iterator viter = view.begin(); viter != view.end(); ++viter)
{
rosbag::MessageInstance const m = *viter;
if (m.getTopic() == string("/diagnostics"))
{
diagnostic_msgs::DiagnosticArray::ConstPtr diagnosticArray = m.instantiate<diagnostic_msgs::DiagnosticArray>();
diagnosticArray now returns NULL as there is an md5sum mismatch, which can be verified by calling rosbag check on the bag file.
My question is, what is the most appropriate way to deal with this change? I can think of several options:
- save a migration rule and call rosbag fix on every bag file we have ever saved
- make the application which is trying to read the diagnostics message call a system call to rosbag fix if/when the diagnosticArray variable is NULL. Warning the user and saving a backup of the bag file.
- Is it possible that the diagnostic message change was minor and I could somehow still access the diagnostic information at a lower level without requiring a migration? (rosbag_wrapper for matlab seems like it might be capable of this)
Is there some other way to migrate a bagfile through C++ API rather than system("rosbag fix ...")?
Many thanks,
Tom.