larvaworld.lib.model.envs.obstacle

Classes

Obstacle

Base class for obstacles in simulation environment.

Box

Rectangular box obstacle.

Wall

Linear wall obstacle between two points.

Border

Complex border obstacle from vertex list.

Module Contents

class larvaworld.lib.model.envs.obstacle.Obstacle(model: Any | None = None, edges: Any | None = None, **kwargs: Any)

Bases: larvaworld.lib.model.GroupedObject, larvaworld.lib.param.ViewableLine

Base class for obstacles in simulation environment.

Combines grouped object properties with viewable line visualization for rendering obstacles (walls, boxes, borders) in the arena.

Attributes:

model: Reference to simulation model edges: List of edge line segments defining obstacle boundaries

Example:
>>> obstacle = Obstacle(model=sim_model, edges=[[p1, p2], [p2, p3]])
edges = None
class larvaworld.lib.model.envs.obstacle.Box(x: float = 0, y: float = 0, size: float = 1, **kwargs: Any)

Bases: Obstacle, larvaworld.lib.param.Pos2D

Rectangular box obstacle.

Creates a square or rectangular obstacle centered at position (x, y) with specified size. Useful for creating containment areas or barriers.

Attributes:

x: Center x-coordinate y: Center y-coordinate size: Box side length closed: Whether box forms closed boundary (default: True)

Example:
>>> box = Box(x=0.5, y=0.5, size=0.2, color="black")
closed
size = 1
class larvaworld.lib.model.envs.obstacle.Wall(point1: shapely.geometry.Point = geometry.Point(0, 0), point2: shapely.geometry.Point = geometry.Point(-1, 1), **kwargs: Any)

Bases: Obstacle

Linear wall obstacle between two points.

Creates a straight wall segment from point1 to point2. Does not form closed boundary. Useful for maze construction and partial barriers.

Attributes:

point1: Starting point of wall segment point2: Ending point of wall segment closed: Whether wall forms closed boundary (default: False)

Example:
>>> wall = Wall(point1=Point(0, 0), point2=Point(1, 0), color="gray")
closed
point1
point2
class larvaworld.lib.model.envs.obstacle.Border(vertices: list[Any] = [], points: Any | None = None, **kwargs: Any)

Bases: Obstacle

Complex border obstacle from vertex list.

Creates multi-segment border from sequence of vertices. Each consecutive vertex pair forms an edge. Supports scaling and coordinate transformations via define_lines method.

Attributes:

vertices: List of vertex coordinates defining border path points: Alternative point specification (optional) border_xy: Transformed vertex coordinates border_lines: LineString objects for each border segment closed: Whether border forms closed loop (default: False)

Example:
>>> border = Border(vertices=[(0, 0), (1, 0), (1, 1), (0, 1)])
>>> is_inside = border.contained((0.5, 0.5))
closed
points = None
define_lines(vertices: list[Any], s: float = 1) tuple[list[Any], list[shapely.geometry.LineString]]
contained(p: Any) bool