cognition.cogent.env¶
Environments
Attributes¶
Represents a function to extract a sensor type from an io container |
|
Represents a function to invoke an actuator on an io container |
Classes¶
Base interface for external input (of |
|
Useful implementation of a sensor |
|
Base interface for external output from |
|
Useful implementation of an actuator |
Functions¶
|
Route sensing for a single time point to |
|
Retrieve sensed data from io cache. |
|
Dynamically constructs a sensor instance. |
|
Provide persistent access to the actuator |
|
Invokes an actuator via io. |
|
Dynamically constructs an actuator instance. |
Module Contents¶
- class cognition.cogent.env.BaseSensor[T]¶
Bases:
ProtocolBase 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:
sensor (BaseSensor[ST]) – source sensor
dp (cognition.decision.core.BaseDecisionProcess[Any]) – destination decision process
- Return type:
None
- cognition.cogent.env.read_sensor_data[ST](sensor, io)¶
Retrieve sensed data from io cache.
- Parameters:
sensor (BaseSensor[ST]) – source sensor
io (cognition.decision.core.IOContainer) – io cache
- 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:
- Return type:
None
- read(io)¶
-
- Parameters:
- 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:
name (str) – sensor name
sense_f (cognition.util.functypes.Supplier[ST]) – function to produce input data
- Returns:
sensor
- Return type:
Sensor[ST]
- class cognition.cogent.env.BaseActuator[P, F]¶
Bases:
ProtocolBase interface for external output from a cogent; actuation is parameterized via type
Pand result feeback viaF- 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:
actuator (BaseActuator[AP, AF]) – actuator to install
dp (cognition.decision.core.BaseDecisionProcess[Any]) – destination decision process
- Return type:
None
- cognition.cogent.env.invoke_actuator[AP, AF](actuator, io, param)¶
Invokes an actuator via io.
- Parameters:
actuator (BaseActuator[AP, AF]) – actuator to invoke
io (cognition.decision.core.IOContainer) – io container
param (AP) – input to the actuator
- 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
- invoke(io, param)¶
-
- Parameters:
param (P)
- 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:
name (str) – actuator name
sense_f – function to handle actuation
actuate_f (cognition.util.functypes.Function[AP, AF])
- Returns:
actuator
- Return type:
Actuator[AP, AF]