Sensors
Sensors provide a way for node to interact with its environment.
Sensors can also be used to satisfy algorithm prerequisites.
Generally sensors should incorporate some model of measurement insecurity that
is inherent in real world sensors. This is implemented as a
ProbabilityFunction.
Basic usage:
>>> node.compositeSensor = ('DistSensor','AoASensor')
>>> node.compositeSensor.sensors
(<pydistsim.network.sensor.DistSensor at 0x6d3fbb0>,
<pydistsim.network.sensor.AoASensor at 0x6d3f950>)
To manually set sensor parameters first make an sensor instance:
>>> import scipy.stats
>>> aoa_sensor = AoASensor({'pf': scipy.stats.norm, 'scale': 10*pi/180 })
>>> node.compositeSensor = (aoa_sensor,)
- class Sensor[source]
Abstract base class for all Sensors.
Sensor provides a certain capability for a node, providing information about the outside world. It could be a capability to detect neighbors, measure distance to them, or retrieve the environment temperature.
- Parameters:
dict_args (dict) – A dictionary containing the scale and probability function.
scale (float) – The scale parameter for the probability function.
pf (rv_continuous or rv_discrete) – The probability function (e.g.
scipy.stats.norm).
Real world sensors
Provides azimuth between node and its neighbors. |
|
Provides distance between node and its neighbors. |
Knowledge sensors
Provides node's true position. |
Composite sensor
- class CompositeSensor(node: Node, componentSensors: tuple[type[Sensor] | str] | None = None)[source]
Wrap multiple sensors, coalesce results and return composite readout.
This class is not a sensor itself, i.e. subclass of
Sensor, instead it serves as a placeholder for multiple sensors that can be attached to aNode.- Parameters:
- get_sensor(name: str) Sensor[source]
Get a sensor by its name.
- Parameters:
name (str) – The name of the sensor.
- Returns:
The sensor object.
- Return type:
- Raises:
SensorError – If multiple or no sensors are found with the given name.