Engine Node
- class eagerx.core.entities.EngineNode(params, *args, simulator=None, message_broker=None, **kwargs)[source]
Baseclass for nodes that are only to be used in combination with a specific engine.
Users must call
make()
to make the engine node subclass’ specification.Use this baseclass to implement nodes that will be added to an
EngineGraph
when specifying an engine implementation for anObject
.These nodes can, optionally, be synchronized with respect to the simulator clock by registering “tick” as an input.
Note
Engine nodes only receive a reference to the
simulator
as an argument toinitialize()
when the engine nodes are launched within the same process as the engine. Seeprocess
for more info.Subclasses must implement the following methods:
shutdown()
(optional)
Use baseclass
Node
instead, for nodes that will be added to the (agnostic)Graph
.Use baseclass
ResetNode
instead, for reset routines.- abstract callback(t_n, **inputs)[source]
An abstract method that is called at the specified node rate.
This method should be decorated with:
eagerx.core.register.inputs()
to register the inputs.eagerx.core.register.outputs()
to register the outputs.
- Parameters
t_n (
float
) – Time passed (seconds) since last reset. Increments with 1/rate
.inputs (
Msg
) – Inputs that were registered (& selected) with theeagerx.core.register.inputs()
decorator by the subclass.
- Return type
Dict
[str
,Any
]- Returns
Dictionary with outputs that were registered (& selected) with the
eagerx.core.register.outputs()
decorator by the subclass.
- classmethod info(method=None)
A helper method to get info on a method of the specified subclass.
- Parameters
method (
Union
[List
[str
],str
,None
]) – The registered method we would like to receive info on. If no method is specified, it provides info on the class itself.- Return type
str
- Returns
Info on the subclass’ method.
- abstract initialize(spec, simulator)[source]
An abstract method that initializes the node at run-time.
- abstract classmethod make(*args, **kwargs)
An abstract method that makes the specification (also referred to as spec) of this entity.
- Parameters
args (
Any
) – Arguments to the subclass’ make function.kwargs (
Any
) – Optional Arguments to the subclass’ make function.
- Returns
A (mutable) spec that can be used to build and subsequently initialize the entity (e.g. node, engine, …).
- abstract reset(**states)[source]
An abstract method that resets the node to its initial state before the start of an episode.
This method should be decorated with
eagerx.core.register.states()
to register the states.Warning
Avoid defining states for engine nodes, as you risk making your
Object
non-agnostic to the environment. Instead, try to implement object states as anEngineState
of anObject
.- Parameters
states (
Any
) – States that were registered (& selected) with theeagerx.core.register.states()
decorator by the subclass. The state messages are sent by the environment and can be used to reset the node at the start of an episode. This can be anything from an estimator’s initial state to a hyper-parameter (e.g. delay, control gains).- Return type
None
- set_delay(delay, component, cname)
A method to vary the delay of an input or feedthrough.
- Parameters
delay (
float
) – A non-negative delay that can be varied at the beginning of an episode (during the reset procedure).component (
str
) – Either “inputs” or “feedthroughs”.cname (
str
) – name of the component.
- Return type
None
- shutdown()
A method that can be overwritten to cleanly shutdown (e.g. release resources).
- Return type
None
- backend: eagerx.core.entities.Backend
Responsible for all I/O communication within this process. Nodes inside the same process share the same message broker. Cannot be modified.
- color: str
Specifies the color of logged messages & node color in the GUI. Check-out the termcolor documentation for the supported colors. Can be set in the subclass’
spec()
.
- entity_id: str
A unique entity_id with the structure <module>/<classname>.
- inputs: dict
Parameters for all selected inputs.
- log_level: int
Specifies the log level for this node: {0: SILENT, 10: DEBUG, 20: INFO, 30: WARN, 40: ERROR, 50: FATAL}. Can be set in the subclass’
spec()
.
- log_memory: int
Specifies the log level for logging memory usage over time for this node: {0: SILENT, 10: DEBUG, 20: INFO, 30: WARN, 40: ERROR, 50: FATAL}. Note that log_level has precedent over the memory level set here. Can be set in the subclass’
spec()
.
- name: str
User specified node name. Can be set in
spec()
.
- outputs: dict
Parameters for all selected outputs.
- process: int
Process in which this node is launched. See
process
for all options. Can be set in the subclass’spec()
.
- rate: float
Rate (Hz) at which the callback is called. Can be set in the subclass’
spec()
.
- real_time_factor: float
A specified upper bound on the real_time factor. Wall-clock rate=real_time_factor*rate. If real_time_factor < 1 the simulation is slower than real time. Can be set in the engine’s
spec()
.
- simulate_delays: bool
Flag that specifies whether input delays are simulated. You probably want to set this to False when running in the real-world. Can be set in the engine’s
spec()
.
- states: dict
Parameters for all selected states.
- sync: bool
Flag that specifies whether we run reactive or asynchronous. Can be set in the engine’s
spec()
.