Why is header.stamp truncated as a C++ class member?
I want to store pointers to various ROS sensor messages inside a C++ class, E.g.
class MetaData {
public:
sensor_msgs::NavSatFix::Ptr navsat;
// some other variables I want to associate with this NavSatFix
}
However, when I then go to print the header stamp on the NavSatFix message, it's type changes and it gets truncated. So that the following code:
// Original message
cout << "Stamp " << msgPtr->header.stamp << " is of type: "
<< typeid(msgPtr->header.stamp).name() << endl;
// Same message but now called from inside a class as a member variable.
MetaData myMetaData;
myMetaData.navsat = msgPtr
cout << "Stamp " << myMetaData.navsat->header.stamp
<< " is of type: " << typeid(myMetaData.navsat->header.stamp).name() << endl;
Returns:
Stamp 1505942380.370968000 is of type N3ros4TimeE
Stamp 1505942380370968 is of type m
So my questions are:
- Why has the type changed from ros::Time (I assume that's what "N3ros4TimeE" stands for) to m? (for "member variable" I think)
- Why has
cout
then truncated one but not the other? (usingstd::setprecision()
has no effect) - What syntax should I use to get the full header stamp when outputting the stamp from the class member?
- Will the answer to 1 likely affect variables in other ROS messages? (I'm not at the stage where I can test this for myself)
Thanks in advance for any help or advice. If this questions is more relevant to general C++ than ROS, let me know and I will shift it to StackOverflow.
The standard seems non-specific on the implementation of
std::type_info::name()
: http://en.cppreference.com/w/cpp/type... .