Node

class eagerx.core.entities.Node(ns, message_broker, sync, real_time_factor, simulate_delays, params, call_init=True)[source]

Baseclass for nodes.

Use this baseclass to implement nodes that will be added to the (agnostic) Graph.

Users must call make() to make the node subclass’ specification.

Subclasses must implement the following methods:

Use baseclass EngineNode instead, for nodes that will be added to EngineGraph when specifying an engine implementation for an Object.

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:

Parameters
  • t_n (float) – Time passed (seconds) since last reset. Increments with 1/rate.

  • inputs (Msg) – Inputs that were registered (& selected) with the eagerx.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)

An abstract method that initializes the node at run-time.

Parameters

spec (Union[NodeSpec, EngineSpec, ResetNodeSpec]) – Specification of the node/engine.

Return type

None

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.

Parameters

states (Any) – States that were registered (& selected) with the eagerx.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)[source]

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().

ns: str

Namespace of the environment. Can be set with the name argument to BaseEnv.

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().