Realtime implementation - Not working as expected
[Comments left by BZ during the testing statistics of RT_PREEMPT and Xenomai]
The WAM control loop is contained in a single Posix thread- probably wrapped by Boost.
Xenomai uses a proper “periodic task”: (rt_task_set_periodic) https://git.barrett.com/software/libbarrett/blob/devel/src/os.cpp#L153
Non-RT simply tries to “sleep” for the proper amount of time: https://git.barrett.com/software/libbarrett/blob/devel/src/os.cpp#L188 Note that non-RT sleep can/is woken up early due to many types of signals, so it will try to re-sleep for the remainder of the loop time if woken too soon. Also, Non-RT sleep can over-sleep if the scheduler is busy with other tasks. This is really a pretty cheesy way to make a task periodic. We should be using a Posix timer and signals for non-RT: http://www.2net.co.uk/tutorial/periodic_threads
Actual control loop code: https://git.barrett.com/software/libbarrett/blob/devel/src/systems/real_time_execution_manager.cpp#L153
As long as the tests are performed consistently (same examples, same duration, same user-input & timing), the actual (avg) loop time does not matter much. I would expect the avg time spent in the [ask for pos, recv pos, calculate fwkin, calculate trq, send trq] loop to be reduced slightly in PREEMPT_RT due to the scheduler staying on-task (literally) when running an lbt app.
I really care about the stdev of the execution cycle time. It looks like we are reporting the time spent in the execution cycle, not the time remaining before the next loop iteration. So the stdev of this cycle time should be extremely low- signifying a very consistent, uninterrupted control cycle.