swarmsim.sensors.BinaryFOVSensor#
Binary Field of View Sensor
- class swarmsim.sensors.BinaryFOVSensor.BinaryFOVSensor(agent=None, parent=None, theta=10.0, distance=100.0, bias=0.0, false_positive=0.0, false_negative=0.0, walls=None, goal_sensing_range=10.0, wall_sensing_range=10.0, time_step_between_sensing=1, invert=False, store_history=False, detect_goal_with_added_state=False, show=True, seed=None, target_team=None, detect_only_origins=False, **kwargs)[source]#
A binary sensor for whether there are matching agents within the sensor’s cone of vision.
- Parameters:
theta (float, default=10.0) – The half-angle of the sensor cone. The effective FOV is \(2 \theta\).
distance (float, default=100.0) – The maximum distance from the sensor to look for targets.
bias (float, default=0.0) – The angle offset of the sensor cone. Positive values shift the cone to the same direction as a positive turn.
false_positive (float, default=0.0) – The probability of a negative detection being reported as a positive detection.
false_negative (float, default=0.0) – The probability of a positive detection being reported as a negative detection.
time_step_between_sensing (int, default=1) – The number of time steps between sensory perceptions.
invert (bool, default=False) – Whether to invert the sensor’s output. If True, a positive detection will be reported as a negative detection, and vice versa.
store_history (bool, default=False) – Whether to store the history of targets.
show (bool, default=True) – Whether to draw the sensory vector.
seed (int | None, default=None) – The seed for the random number generator. If None, the parent’s RNG is used.
target_team (int | str | None, default=None) – The team to look for agents or objects in. If None, any team is considered.
detect_only_origins (bool, default=False) – Whether to only detect the origin of the agent.
- Attributes:
- position
Methods
getAARectContainingSector(world)point_orientation(p1, p2, p3)Used in calculating Line Segment Intersection See: https://www.geeksforgeeks.org/orientation-3-ordered-points/amp/%C2%A0/ Motivation: https://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/
as_config_dict
checkForLOSCollisions
determineState
draw
from_dict
getBiasedSightAngle
getLOSVector
getSectorVectors
get_state
line_seg_int_point
lines_segments_intersect
set_agent
set_parent
set_seed
state_pretty
step
withinRadiusExclusiveFast
- checkForLOSCollisions(world: RectangularWorld) None[source]#
- config_vars = ['static_position', 'n_possible_states', 'show', 'theta', 'distance', 'bias', 'false_positive', 'false_negative', 'walls', 'wall_sensing_range', 'time_step_between_sensing', 'invert', 'store_history', 'detect_goal_with_added_state', 'show', 'target_team', 'seed'][source]#
- getAARectContainingSector(world: RectangularWorld)[source]#
- point_orientation(p1, p2, p3)[source]#
Used in calculating Line Segment Intersection See: https://www.geeksforgeeks.org/orientation-3-ordered-points/amp/%C2%A0/ Motivation: https://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/
- swarmsim.sensors.BinaryFOVSensor.vectorize(angle)[source]#
Convert an angle to a representative unit vector.
- Parameters:
angle (float) – Angle in radians
- Returns:
Vector
- Return type:
np.ndarray
- swarmsim.sensors.BinaryFOVSensor.turn(p1, p2)[source]#
Compute the vector turn value from origin→p1 to origin→p2.
This value is positive if a left turn is the fastest way to go from p1 to p2, zero if p1 and p2 are colinear, and negative otherwise
- swarmsim.sensors.BinaryFOVSensor.lineCircleIntersect(line, center, radius)[source]#
Determine if the line in the direction of the first argument intersects the circle defined by the second and third arguments.
Functions
|
Determine if the line in the direction of the first argument intersects the circle defined by the second and third arguments. |
|
Project vector a onto vector b. |
|
Compute the vector turn value from origin→p1 to origin→p2. |
|
Convert an angle to a representative unit vector. |
Classes
|
A binary sensor for whether there are matching agents within the sensor's cone of vision. |