Engine Graph

class eagerx.core.graph_engine.EngineGraph(state)[source]
add(nodes)[source]

Add nodes to the graph.

Parameters

nodes (Union[NodeSpec, List[NodeSpec]]) – Nodes/objects to add.

Return type

None

add_component(entry)[source]

Selects an available component entry (e.g. input, output, etc…) that was not already selected.

Parameters

entry (SpecView) – Selects the entry, so that it can be connected.

Return type

None

connect(source=None, target=None, actuator=None, sensor=None, window=None, delay=None, skip=None)[source]

Connect an actuator/source to a sensor/target.

Parameters
  • source (Optional[SpecView]) – Compatible source type is outputs.

  • target (Optional[SpecView]) – Compatible target type is inputs.

  • actuator (Optional[str]) – String name of the actuator.

  • sensor (Optional[str]) – String name of the sensor.

  • window (Optional[int]) –

    A non-negative number that specifies the number of messages to pass to the node’s callback().

    • window = 1: Only the last received input message.

    • window = x > 1: The trailing last x received input messages.

    • window = 0: All input messages received since the last call to the node’s callback().

    Note

    With window = 0, the number of input messages may vary and can even be zero.

  • delay (Optional[float]) – A non-negative simulated delay (seconds). This delay is ignored if simulate_delays = True in the engine’s spec().

  • skip (Optional[bool]) – Skip the dependency on this input during the first call to the node’s callback(). May be necessary to ensure that the connected graph is directed and acyclic.

Return type

None

disconnect(source=None, target=None, actuator=None, sensor=None)[source]

Disconnect an actuator/source from a sensor/target.

Parameters
  • source (Optional[SpecView]) – Compatible source type is outputs.

  • target (Optional[SpecView]) – Compatible target type is inputs.

  • actuator (Optional[str]) – String name of the actuator.

  • sensor (Optional[str]) – String name of the sensor.

Return type

None

get(entry=None, actuator=None, sensor=None, parameter=None)[source]

Fetches the parameters of a node/actuator/sensor.

Parameters
  • entry (Union[SpecView, EntitySpec, None]) – The entry whose parameters are fetched.

  • actuator (Optional[str]) – Actuator name whose parameters are fetched.

  • sensor (Optional[str]) – Sensor name whose parameters are fetched.

  • parameter (Optional[str]) – If only a single parameter needs to be fetched.

Return type

Any

Returns

Parameters

get_spec(name)[source]

Get Spec from the graph

Parameters

name (str) – Name

Return type

NodeSpec

Returns

The specification of the entity.

gui(interactive=True, resolution=None, filename=None)[source]

Opens a graphical user interface of the graph.

Note

Requires eagerx-gui:

pip3 install eagerx-gui
Parameters
  • interactive (Optional[bool]) – If True, an interactive application is launched. Otherwise, an RGB render of the GUI is returned. This could be useful when using a headless machine.

  • resolution (Optional[List[int]]) – Specifies the resolution of the returned render when interactive is False. If interactive is True, this argument is ignored.

  • filename (Optional[str]) – If provided, the GUI is rendered to an svg file with this name. If interactive is True, this argument is ignored.

Return type

Optional[ndarray]

Returns

RGB render of the GUI if interactive is False.

is_valid(plot=True)[source]

Checks the validity of the graph.

  • Checks if all selected inputs are connected.

  • Checks if the graph is directed and acyclic.

Parameters

plot – Flag to plot the graph. Can be helpful to identify cycles in the graph that break the required acyclic property.

Return type

bool

Returns

flag that specifies the validity of the graph.

register()[source]

Returns the nodes that make up this subgraph, and their relation to the registered actuators and sensors.

remove(names)[source]

Removes a node from the graph.

  • First, all associated connections are disconnected.

  • Then, removes the nodes/objects.

Parameters

names (Union[str, EntitySpec, List[Union[str, EntitySpec]]]) – Either the name or spec of the node/object that is to be removed.

Return type

None

remove_component(entry)[source]

Deselects a component entry (e.g. input, output, etc…) that was selected.

  • First, all associated connections are disconnected.

  • Then, deselects the component entry.

Parameters

entry (SpecView) – Deselects the entry.

Return type

None

set(mapping, entry, parameter=None)[source]

Sets the parameters of a node.

Parameters
  • mapping (Any) – Either a mapping with key = parameter, or a single value that corresponds to the optional parameter argument.

  • entry (Optional[SpecView]) – The entry whose parameters are mutated.

  • parameter (Optional[str]) – If only a single value needs to be set. See documentation for mapping.

Return type

None