Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timed Main Control Loop #3

Open
shihaocao opened this issue Sep 28, 2021 · 4 comments
Open

Timed Main Control Loop #3

shihaocao opened this issue Sep 28, 2021 · 4 comments
Assignees

Comments

@shihaocao
Copy link
Collaborator

shihaocao commented Sep 28, 2021

Problem:

  • Sensors and estimators must expect to get updates at a fixed time step

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.

@shihaocao
Copy link
Collaborator Author

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.

@shihaocao
Copy link
Collaborator Author

Once the feature works, create a TestInstance to verify that we are hitting the target control cycle time.

@shihaocao shihaocao mentioned this issue Nov 1, 2021
Merged
@ezh20
Copy link
Collaborator

ezh20 commented Nov 13, 2021

Screen Shot 2021-11-13 at 4 27 32 PM

@ezh20 ezh20 closed this as completed Feb 17, 2022
@ezh20 ezh20 reopened this Feb 17, 2022
@ezh20
Copy link
Collaborator

ezh20 commented Feb 17, 2022

need to delete some useless code then done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants