Package topo :: Package misc :: Module robotics :: Class RealTimeSimulation
[hide private]
[frames] | no frames]

Class RealTimeSimulation

source code


A (quasi) real-time simulation object.

This subclass of Simulation attempts to maintain a correspondence between simulation time and real time, as defined by the timescale parameter. Real time simulation instances still maintain a nominal, discrete simulation time that determines the order of event delivery.

At the beginning of each simulation time epoch, the simulation marks the actual wall clock time. After event delivery for that epoch has ended, the simulation calculates the amount of computation time used for event processing, and executes a real sleep for the remainder of the epoch. If the computation time for the epoch exceeded the real time, a warning is issued and processing proceeds immediately to the next simulation time epoch.

RUN HOOKS

The simulation includes as parameters two lists of functions/callables, run_start_hooks and run_stop_hooks, that will be called immediately before and after event processing during a call to .run(). This allows, for example, starting and stopping of real-time devices that might use resources while the simulation is not running.

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
__init__(self, **params)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
run(self, *args, **kw)
Process simulation events for the specified duration or until the specified time.
source code
 
real_time(self) source code
 
sleep(self, delay)
Advance the simulator time by the specified amount.
source code

Inherited from base.simulation.Simulation: __delitem__, __getitem__, __iter__, __setitem__, basename, connect, connections, enqueue_event, event_clear, event_pop, event_push, grid_layout, objects, run_and_time, schedule_command, script_repr, set_time_type, state_pop, state_push, time, timestr

Inherited from base.simulation.Simulation (private): _cleanup, _set_time

Inherited from param.parameterized.Parameterized: __getstate__, __repr__, __setstate__, __str__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, set_default, set_dynamic_time_fn, set_param, verbose, warning

Inherited from param.parameterized.OptionalSingleton: __copy__, __deepcopy__, __getnewargs__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Static Methods [hide private]

Inherited from base.simulation.Simulation: __new__

Class Variables [hide private]
  timescale = param.Number(default= 1.0, bounds= (0, None), doc=...
  run_start_hooks = param.HookList(default= [], doc= ...
  run_stop_hooks = param.HookList(default= [], doc= ...

Inherited from base.simulation.Simulation: basename_format, eps_to_start, name, register, startup_commands, time_printing_format, time_type, time_type_args

Inherited from base.simulation.Simulation (private): _inst

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **params)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

run(self, *args, **kw)

source code 

Process simulation events for the specified duration or until the specified time.

Arguments:

duration = length of simulation time to run. Default: run indefinitely while there are still events in the event_queue.

until = maximum simulation time to simulate. Default: run indefinitely while there are still events in the event queue.

If both duration and until are used, the one that is reached first will apply.

Note that duration and until should be specified in a format suitable for conversion (coercion?) into the Simulation's _time_type.

Overrides: base.simulation.Simulation.run
(inherited documentation)

sleep(self, delay)

source code 
Advance the simulator time by the specified amount. By default simply increments the _time value, but subclasses can override this method as they wish, e.g. to wait for an external real time clock to advance first.
Overrides: base.simulation.Simulation.sleep

Class Variable Details [hide private]

timescale

Value:
param.Number(default= 1.0, bounds= (0, None), doc= """
       The desired real length of one simulation time unit, in milliseconds.""")

run_start_hooks

Value:
param.HookList(default= [], doc= """
       A list of callable objects to be called on entry to .run(),
       before any events are processed.""")

run_stop_hooks

Value:
param.HookList(default= [], doc= """
       A list of callable objects to be called on exit from .run()
       after all events are processed.""")