components/RobotUnitSimulation: Wrong timestamps in 'RobotState/Proprioception'-memory
When running the ARMAR-7 simulation or ARMAR-6's CeBITSimulation-scenario the entity-snapshots in the 'RobotState/Proprioception/Armar[6/7]/Armar[6/7]'-entity have a wrong timestamp (year is 2078 for me).
This is due to an inconsistency in the used clocks: The simulated RobotUnit generates the according timestamps using a realtime clock while inherited RobotAPI code assumes that the system-wide raw monotonic clock is used.
-
ArmarXSimulation's RobotUnitSimulation uses
TimeUtil::GetTime
to generate timestamps for the (proprioception) data. This returns the time from the used timeserver or the system's realtime. In this scenario, this results in the system's realtime. (Throughout the RobotUnitSimlation only these clocks are used, while the real-robot units consistently use the system's raw monotonic clock witharmarx::rtNow()
.) -
The RobotUnitSimulation inherits from RobotAPI's RobotUnit which implements the RobotUnitLoggingInterface which, among other things, streams the proprioception data. The RobotAPI code therefore processes the timestamps from above:
data.timestampUSec = armarx::mapRtTimestampToNonRtTimestamp(e.sensorValuesTimestamp).toMicroSeconds();
with
inline IceUtil::Time mapRtTimestampToNonRtTimestamp(const IceUtil::Time& time_monotic_raw) { // This is the "real time" clock, i.e. NTP-synchronized and relative to epoch. IceUtil::Time now_real_time = armarx::nonRtNow(); // This is not relative to epoch and not NTP-synchronized. IceUtil::Time now_monotonic_raw = armarx::rtNow(); /* * Assumption for small very small time deltas (i.e. "time" is close to "now"): * * time_real_time - now_real_time == time_monotic_raw - now_monotonic_raw * => * time_real_time = time_monotic_raw - now_monotonic_raw + now_real_time */ // IceUtil::Time time_real_time = time_monotic_raw - now_monotonic_raw + now_real_time; ARMARX_DEBUG << VAROUT(time_monotic_raw) << " vs. " << VAROUT(time_real_time); return time_real_time; }
which assumes that the timestamps generated by, in this case, ArmarXSimulation's RobotUnitSimulation use the system's raw monotonic time. Because that's not the case here and the system's raw monotonic time corresponds to the time since the last reboot (at least on the lab pc) the processed timestamp is ≈ 2 * unix-realtime - time-since-last-reboot ≈ 2078.
-
The RobotStateMemory just receives the stream and commits the data (with the wrong timestamps) into the memory.