Defining Sensors
Sensors take measurements of the world around us. They serve as senses for your intelligent autonomous agent, providing the feedback from which it learns and reports the results of its actions, step by step. Sensors report data to agents using sensor variables.
Defining Sensor Variables
state1 = Sensor("state1", "the counter")
time_counter = Sensor("time_counter", "the time counter")
sensors = [state1, time_counter]
Creating a Sensor Definition File (Optional)
A cleaner agent.py
file helps keep your agent organized. So, we recommend creating a separate file (e.g. sensors.py
) to contain the sensor definitions. Alternatively, you can include the sensor definitions in the agent Python file. Use the Sensor()
method to create each sensor. The first argument is the sensor name that you can use to identify the variable during machine teaching and the second argument is a description. Create a list that contains each sensor variable.
from composabl import Sensor
state1 = Sensor("state1", "the counter")
time_counter = Sensor("time_counter", "the time counter")
sensors = [state1, time_counter]
Adding Sensors to your Agent
Add the list of sensors you created above to the agent with the add_sensors()
method.
from composabl import Agent, Skill, Sensor, Perceptor, Scenario, Runtime
from .sensors import sensors
config = {
"target": {
"docker": {
"image": "composabl/sim-demo:latest"
}
},
"env": {
"name": "sim-demo",
},
"license": "<This is your license key>",
"training": {},
}
runtime = Runtime(config)
agent = Agent()
agent.add_sensors(sensors)