Bardo.Examples.Benchmarks.Dpb.DpbSensor (Bardo v0.1.0)

View Source

Sensor implementation for the Double Pole Balancing (DPB) benchmark.

This module provides sensors that agents can use to perceive the state of the cart and poles in the pole balancing simulation.

Summary

Functions

Create a cart position sensor configuration.

Create a cart velocity sensor configuration.

Initialize a new sensor for the DPB simulation.

Initialize a new sensor for the DPB simulation.

Process sensory data based on sensor type.

Create a pole1 angle sensor configuration.

Create a pole1 angular velocity sensor configuration.

Create a pole2 angle sensor configuration.

Create a pole2 angular velocity sensor configuration.

Read data from the sensor.

Send a sensing request to the scape.

Functions

cart_position(id, fanout, cortex_id, scape_name)

@spec cart_position(integer(), integer(), atom(), atom()) :: map()

Create a cart position sensor configuration.

Parameters:

  • id: Sensor ID
  • fanout: Number of output elements (typically 1)
  • cortex_id: ID of the cortex
  • scape_name: Name of the scape

Returns a sensor specification map.

cart_velocity(id, fanout, cortex_id, scape_name)

@spec cart_velocity(integer(), integer(), atom(), atom()) :: map()

Create a cart velocity sensor configuration.

Parameters:

  • id: Sensor ID
  • fanout: Number of output elements (typically 1)
  • cortex_id: ID of the cortex
  • scape_name: Name of the scape

Returns a sensor specification map.

init(params)

Initialize a new sensor for the DPB simulation.

This is the implementation of the Sensor behavior's init/1 callback.

init(id, sensor_type, fanout, cortex_pid, scape_pid, agent_id)

Initialize a new sensor for the DPB simulation.

Parameters:

  • id: Sensor ID
  • sensor_type: :cart_position, :pole1_angle, :pole2_angle, :cart_velocity,
            :pole1_angular_velocity, or :pole2_angular_velocity
  • fanout: Number of output elements (typically 1)
  • cortex_pid: PID of the cortex process
  • scape_pid: PID of the scape process
  • agent_id: ID of the agent

percept(state, data)

Process sensory data based on sensor type.

This is the implementation of the Sensor behavior's percept/2 callback.

pole1_angle(id, fanout, cortex_id, scape_name)

@spec pole1_angle(integer(), integer(), atom(), atom()) :: map()

Create a pole1 angle sensor configuration.

Parameters:

  • id: Sensor ID
  • fanout: Number of output elements (typically 1)
  • cortex_id: ID of the cortex
  • scape_name: Name of the scape

Returns a sensor specification map.

pole1_angular_velocity(id, fanout, cortex_id, scape_name)

@spec pole1_angular_velocity(integer(), integer(), atom(), atom()) :: map()

Create a pole1 angular velocity sensor configuration.

Parameters:

  • id: Sensor ID
  • fanout: Number of output elements (typically 1)
  • cortex_id: ID of the cortex
  • scape_name: Name of the scape

Returns a sensor specification map.

pole2_angle(id, fanout, cortex_id, scape_name)

@spec pole2_angle(integer(), integer(), atom(), atom()) :: map()

Create a pole2 angle sensor configuration.

Parameters:

  • id: Sensor ID
  • fanout: Number of output elements (typically 1)
  • cortex_id: ID of the cortex
  • scape_name: Name of the scape

Returns a sensor specification map.

pole2_angular_velocity(id, fanout, cortex_id, scape_name)

@spec pole2_angular_velocity(integer(), integer(), atom(), atom()) :: map()

Create a pole2 angular velocity sensor configuration.

Parameters:

  • id: Sensor ID
  • fanout: Number of output elements (typically 1)
  • cortex_id: ID of the cortex
  • scape_name: Name of the scape

Returns a sensor specification map.

read(state)

Read data from the sensor.

This function sends a sensing request to the scape and processes the response.

sense(state, processed_input)

Send a sensing request to the scape.

This is the implementation of the Sensor behavior's sense/2 callback.