TUDelft-CNS-ATM / bluesky

The open source air traffic simulator
GNU General Public License v3.0
365 stars 244 forks source link

Getting Time From Bluesky Sim #481

Closed nl22-nmsu closed 1 year ago

nl22-nmsu commented 1 year ago

Hello,

I am trying to use the sim time in my plugin but I'm not sure how to access it. Based on the wiki I should use "settings.simtclock" I think, however, the only attribute that I am able to access is the "setting.simdt".

The end goal is to have the simulation time that is displayed in the lower left corner.

Thanks in advance

jooste commented 1 year ago

Hi @nl22-nmsu,

I take it you mean the current simulation time? Timing-related variables are members of the Simulation object:

import bluesky as bs

def your_function():
    print('The current simulation time is:', bs.sim.simt)
    print('The current simulation timestep is:', bs.sim.simdt)

There is also bs.sim.simtclock. The difference with simt is that simt starts at zero, but simtclock can have an offset, which can be set with the TIME and DATE stack commands.

nl22-nmsu commented 1 year ago

Perfect, thanks so much!