Reset Node
- class eagerx.core.entities.ResetNode(params, *args, **kwargs)[source]
Baseclass for nodes that perform a reset routine.
Use this baseclass to implement reset nodes that will be added to the (agnostic)
Graph
.Users must call
make()
to make the reset node subclass’ specification.Note
Subclasses must always have at least one target registered with the
eagerx.core.register.targets()
decorator.Subclasses must implement the following methods:
shutdown()
(optional)
Use baseclass
EngineNode
instead, for nodes that will be added toEngineGraph
when specifying an engine implementation for anObject
.Use baseclass
Node
instead, for regular nodes that will be added to the agnosticGraph
.- abstract callback(t_n, **inputs_and_targets)[source]
An abstract method that is called at the specified node rate during the environment reset.
This method should be decorated with:
eagerx.core.register.inputs()
to register the inputs.eagerx.core.register.outputs()
to register the outputs.eagerx.core.register.targets()
to register the targets.
Note
This callback is skipped until the user calls
reset()
. Until then, the messages coming in via the connected feedthroughs are fed through as the outputs instead. For every registered output that was registered (& selected) with theeagerx.core.register.outputs()
decorator by the subclass, there must be a connected feedthrough.- Parameters:
t_n (
float
) – Time passed (seconds) since last reset. Increments with 1/rate
.inputs_and_targets (
Msg
) – Inputs and targets that were registered (& selected) with theeagerx.core.register.inputs()
andeagerx.core.register.targets()
decorators 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. In addition, the dictionary must contain message of type bool that specifies whether the requested target was reached.
- 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 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:
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>.
-
feedthroughs:
dict
Parameters for all feedthroughs corresponding to the selected outputs.
-
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()
.
-
targets:
dict
Parameters for all selected targets.