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

Get the IMSim execution control method working #133

Open
ezcrues opened this issue Jan 14, 2024 · 3 comments
Open

Get the IMSim execution control method working #133

ezcrues opened this issue Jan 14, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@ezcrues
Copy link
Contributor

ezcrues commented Jan 14, 2024

The IMSim execution control method is not working. This needs to be fixed. This implementation will be based off of the IMSim document in the docs/IMSim directory.

@ezcrues ezcrues added the bug Something isn't working label Jan 14, 2024
@simtheverse
Copy link
Contributor

We are basing our TSFOM implementation off of the IMSim. We'd be interested in the inclusion of the CTE that the SpaceFOM examples just got too :)

@dandexter
Copy link
Contributor

You can already use the CTE Timeline classes provided your ExecutionControl class extends the TrickHLA::ExecutionControlBase class that has the cte_timeline instance variable defined. The default IMSim ExecutionControl class already does this.

However, I have not tested that IMSim is using the CTE Timeline correctly though.

We kind of gloss over why CTE would be used and what the constraints are for running with multiple simulations with realtime clocks and not causing overruns and the requirement that all clocks must be synchronized. Although we cover HLA time management and how it is used for ensuring a deterministic and repeatable simulation I don't think we dive into the details about using CTE without HLA time management and how you are not guaranteed to get repeatable sim runs, which is not what you want when doing verification and validation. This may be adequate for other uses of the distributed simulation though.

For SpaceFOM we use HLA Time Management in conjunction with CTE (when needed) to ensure a deterministic and repeatable distributed simulation even when running faster than realtime. Perhaps there is a paper we could write some day to cover the fundamentals.

Looking at the sims/SpaceFOM/SIM_sine_cte simulation as an example:

  • In your S_define file, add the CTE Timeline instance you want your simulation to use an an external Trick clock.
    • There are two CTE implementations provided by TrickHLA and they are TrickHLA::TimeOfDayCTETimeline and TrickHLA::TSyncCTETimeline.
    • TimeOfDayCTETimeline assumes the system clock is synchronized by either PTP or NTP. NTP will only be good to less than 10 milliseconds of jitter worst case so keep your realtime software frame much larger than this and you should have at least that amount of margin in your realtime frame. For an NTP server on a local network, the time sync is usually much better than 10 milliseconds.
    • TSyncCTETimeline uses the TSync hardware clock for CTE and is only supported on Linux.
    • In the example SpaceFOM/SIM_sine_cte simulation in the THLAInitSimObject simulation object (as the THLA_INIT instance) you will see "TrickHLA::TimeOfDayCTETimeline cte_timeline;" defined and instantiated in the THLAInitSimObject sim-object constructor.
  • input.py file configuration
    • Configure TrickHLA to use the CTE timeline in the input.py file.
      • THLA.execution_control.cte_timeline = THLA_INIT.cte_timeline
    • Make sure to set a time padding to offset the go to run CTE time the federates wait for to go to run on the CTE timeline. It needs to be large enough that the go to run message arrives and they CTE go to run time has not happened yet so it is a coordinated wait then go to run.
      • federate.set_time_padding( 1.0 )
    • If you don't set a Trick freeze frame time then the default of 1 second will be used, which will cause the coordination to go to run to take up to 2 seconds. You can set a more reasonable value for the freeze frame time for the Trick Executive. For this example simulation I use a freeze frame time that is half that of the Trick software frame (i.e. realtime frame) time.
      • trick.exec_set_freeze_frame( 0.125 )

@simtheverse
Copy link
Contributor

Awesome. I'll be implementing something like this in both our SpaceFOM and TSFOM versions of the sim in the coming months and really appreciate the steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants