cognition.cogent.env

Environments

Attributes

SensorReader

Represents a function to extract a sensor type from an io container

ActuatorInvoker

Represents a function to invoke an actuator on an io container

Classes

BaseSensor

Base interface for external input (of

Sensor

Useful implementation of a sensor

BaseActuator

Base interface for external output from

Actuator

Useful implementation of an actuator

Functions

perceive(sensor, dp)

Route sensing for a single time point to

read_sensor_data(sensor, io)

Retrieve sensed data from io cache.

create_sensor(name, sense_f)

Dynamically constructs a sensor instance.

install(actuator, dp)

Provide persistent access to the actuator

invoke_actuator(actuator, io, param)

Invokes an actuator via io.

create_actuator(name, actuate_f)

Dynamically constructs an actuator instance.

Module Contents

class cognition.cogent.env.BaseSensor[T]

Bases: Protocol

Base interface for external input (of type T) to a cogent

property name: str
Abstractmethod:

Return type:

str

Sensor name, which corresponds to access location on io: IOContainer.i.<name>

Returns:

this sensor’s name

Return type:

str

abstractmethod sense()

Retrieve the current sensor value.

Generally this should NOT be called directly, but rather synchronized via perception across all sensors, in an agent (where results are cached within an IOContainer).

Returns:

current sensor value

Return type:

T

cognition.cogent.env.perceive[ST](sensor, dp)

Route sensing for a single time point to the IOContainer of a decision process.

Parameters:
Return type:

None

cognition.cogent.env.read_sensor_data[ST](sensor, io)

Retrieve sensed data from io cache.

Parameters:
Returns:

most recent sensed data

Return type:

ST

type cognition.cogent.env.SensorReader = Function[IOContainer, T]

Represents a function to extract a sensor type from an io container

class cognition.cogent.env.Sensor[T]

Bases: abc.ABC, BaseSensor[T]

Useful implementation of a sensor

property name: str
Abstractmethod:

Return type:

str

Sensor name, which corresponds to access location on io: IOContainer.i.<name>

Returns:

this sensor’s name

Return type:

str

abstractmethod sense()

Retrieve the current sensor value.

Generally this should NOT be called directly, but rather synchronized via perception across all sensors, in an agent (where results are cached within an IOContainer).

Returns:

current sensor value

Return type:

T

perceive(dp)

See perceive()

Parameters:

dp (cognition.decision.core.BaseDecisionProcess[Any])

Return type:

None

read(io)

See read_sensor_data()

Parameters:

io (cognition.decision.core.IOContainer)

Return type:

T

property reader: SensorReader[T]

Produces an easy-to-call function to extract sensor data from an io container

Returns:

associated sensor reader

Return type:

SensorReader[T]

cognition.cogent.env.create_sensor[ST](name, sense_f)

Dynamically constructs a sensor instance.

Parameters:
Returns:

sensor

Return type:

Sensor[ST]

class cognition.cogent.env.BaseActuator[P, F]

Bases: Protocol

Base interface for external output from a cogent; actuation is parameterized via type P and result feeback via F

property name: str
Abstractmethod:

Return type:

str

Actuator name, which corresponds to access location on io: IOContainer.o.<name>

Returns:

this actuator’s name

Return type:

str

abstractmethod actuate(param)

Function exposed via IOContainer to invoke the actuator and receive feedback

Parameters:

param (P) – typed parameter

Returns:

typed actuator feedback

Return type:

F

cognition.cogent.env.install[AP, AF](actuator, dp)

Provide persistent access to the actuator via the IOContainer of the decision process

Parameters:
Return type:

None

cognition.cogent.env.invoke_actuator[AP, AF](actuator, io, param)

Invokes an actuator via io.

Parameters:
Returns:

actuator feedback from invocation

Return type:

AF

type cognition.cogent.env.ActuatorInvoker = BiFunction[IOContainer, P, F]

Represents a function to invoke an actuator on an io container

class cognition.cogent.env.Actuator[P, F]

Bases: abc.ABC, BaseActuator[P, F]

Useful implementation of an actuator

property name: str
Abstractmethod:

Return type:

str

Actuator name, which corresponds to access location on io: IOContainer.o.<name>

Returns:

this actuator’s name

Return type:

str

abstractmethod actuate(param)

Function exposed via IOContainer to invoke the actuator and receive feedback

Parameters:

param (P) – typed parameter

Returns:

typed actuator feedback

Return type:

F

install(dp)

See install()

Parameters:

dp (cognition.decision.core.BaseDecisionProcess[Any])

Return type:

None

invoke(io, param)

See invoke_actuator()

Parameters:
Return type:

F

property invoker: ActuatorInvoker[P, F]

Produces an easy-to-call function to invoke an actuator on an io container

Returns:

associated sensor reader

Return type:

ActuatorInvoker[P, F]

cognition.cogent.env.create_actuator[AP, AF](name, actuate_f)

Dynamically constructs an actuator instance.

Parameters:
Returns:

actuator

Return type:

Actuator[AP, AF]