fmi_adapter
fmi_adapter copied to clipboard
Remove (or reduce) warnings that simulation time is greater than timer's time
The FMIAdapterNode
uses a standard ROS timer to advance the FMU simulation. If the timer's period is not much greater than the simulation step-size but close to it, the FMIAdapterNode
frequently emits a warning "Simulation time [..] is greater than timer's time [..]. Is your step size to large?" as an info-level log message.
Explanation
Internally, the timer callback of FMIAdapterNode
calls FMIAdapter::doStepsUntil(..)
with the current ROS time obtained from Node::now()
. Given this current ROS time, the function FMIAdapter::doStepsUntil(..)
performs simulation steps until a time-point between now() - step_size/2
and now() + step_size/2
is reached, i.e., it rounds to the closest step-size.
If in the next invocation of the timer callback the current ROS time now()
is still smaller than the time-point until the FMU simulation was advanced in the previous invocation, then the timer callback emits the warning stated above. This happens especially if the timer period is only slightly larger than the step-size and if the processing of the timer callback is preempted by other processes or threads.
Possible fixes
- Remove the warning completely.
- Reduce the number of warnings (e.g., only a first time and then only once per minute).
Notes
Independent of this warning: If FMIAdapter::doStepsUntil(..)
is called with an older time-point that would cause a backward step, a runtime error is thrown.