Open shihaocao opened 3 years ago
Say the config file specifies the control cycle duration to be 100ms. We should sleep if the executed main control loop so far has not yet hit 100ms.
Once the feature works, create a TestInstance to verify that we are hitting the target control cycle time.
need to delete some useless code then done
Problem:
On This Ticket:
The Main Control Loop MUST be locked into a given control cycle, given from the config file:
Create a ControlTask, called TimerEnforcer:
Create a statefield called: 'end_of_last_cycle', with default value: time.time() at default time.
Let's create a statefield called: 'target_control_cycle_duration', with value 100 by default.
In the body of TimerEnforcer, create logic that says: end_of_last = sfr.get('end_of_last_cycle') target_duration = sfr.get('target_control_cycle_duration) while "now" - end_of_last < target_duration: time.sleep(0.001)
This is so that the TimerEnforcer will sleep for as long as it needs to for the entire MainControlLoop to take exactly "target_control_cycle_duration" time.