World#
A rectangular region
Overloaded function.
__init__(min_x: float, max_x: float, min_y: float, max_y: float) -> None
Creates a rectangular region
- Parameters:
min_x – Minimal x coordinates
max_x – Maximal x coordinate
min_y – Minimal y coordinate
max_y – Maximal y coordinate
__init__(p1: Vector2, p2: Vector2) -> None
Creates a rectangular region
- Parameters:
p1 – Bottom-left corner
p2 – Top-right corner
Super-class that adds a unique ID to world entities.
This unique ID should not be fed to navigation behaviors, but only used internally by the simulation, for instance, to identify entities in a UI.
Determines if the entity has been in collision at least once since the given time.
- Parameters:
time – The time
- Returns:
True if been in collision since, False otherwise.
- Type:
Returns the last collision time
A static obstacle with circular shape
Overloaded function.
__init__(position: Vector2, radius: float) -> None
Constructs a new instance.
- Parameters:
position – The position of the circle
radius – The radius of the circle
__init__(disc: navground.core.Disc) -> None
Constructs a new instance.
- Parameters:
disc – A disc
Dumps the object to a YAML-string.
- Returns:
The YAML representation
- Return type:
Load a obstacle modulation from a YAML string.
- Returns:
The loaded obstacle or
None
if loading fails.- Return type:
Obstacle| None
Returns the json-schema
- Returns:
json-schema
- Return type:
dict[str, typing.Any]
- Type:
The disc.
A static wall.
Currently, only line segment are valid shapes of walls.
Overloaded function.
__init__(p1: Vector2, p2: Vector2) -> None
Constructs a new instance.
- Parameters:
p1 – The line segment start vertex
p2 – The line segment end vertex
__init__(line: navground.core.LineSegment) -> None
Constructs a new instance.
- Parameters:
ls – A line segment
Dumps the object to a YAML-string.
- Returns:
The YAML representation
- Return type:
Load a wall modulation from a YAML string.
- Returns:
The loaded wall or
None
if loading fails.- Return type:
Wall| None
Returns the json-schema
- Returns:
json-schema
- Return type:
dict[str, typing.Any]
-
The line segment
Constructs a new instance.
Actuate then controllers and perform collisions resolutions.
- Parameters:
time_step – The duration of each time step
Adds an agent to the world.
- Parameters:
agent – The agent
Adds a callback to be executed after each simulation step.
- Parameters:
value – The callback
Overloaded function.
add_obstacle(disc: navground.core.Disc) -> None
Adds a disc the world as a static obstacle
- Parameters:
disc – The disc
add_obstacle(obstacle: navground.sim.Obstacle) -> None
Adds a static obstacle the world
- Parameters:
obstacle – The obstacle
Adds a random obstacles in the world bounding box
It iteratively try to sample a disc that is far enough of any other item. If the sampling fails, it counts as a try and the process stop after either enough obstacles have been added or enough tries performed.
- Parameters:
number – The number of obstacles
min_radius – The minimum radius of obstacles
max_radius – The maximum radius of obstacles
margin – The minimal distance to other obstacles or agents. For agents, it’s additional to their safety margin.
max_tries – The maximum tries before terminating.
Overloaded function.
add_wall(line: navground.core.LineSegment) -> None
Adds a line to the world as a wall
- Parameters:
line – The line
add_wall(wall: navground.sim.Wall) -> None
Adds a wall to the world
- Parameters:
wall – The wall
Check if all agents are idle (i.e., their tasks are done and their controller are idle).
- Returns:
True if all agents are idle
Check if all agents are idle or stuck (i.e., they are no moving because they task is done or they are deadlocked)
- Returns:
True if all agents are idle or stuck
Clear collisions
Calculates the safety violation, i.e. the maximal penetration of a neighbor or obstacle in the safety margin of the agent.
- Parameters:
agent – The agent
safety_margin – The safety margin. If not set, it will default to the agent’s behavior safety margin.
- Returns:
The safety violation or 0 if no violation.
Copy the random generator from another world
- Parameters:
world – The world
Dumps the object to a YAML-string.
- Returns:
The YAML representation
- Return type:
Gets the agents that had a collision after
now - duration
.- Parameters:
duration – The duration
- Returns:
The agents in collision.
Gets the agents that are in stuck since
now - duration
.- Parameters:
duration – The duration
- Returns:
The agents in deadlock.
Gets all agents in a bounding box.
- Parameters:
bb – The bounding box specified in world-fixed coordinates
- Returns:
All agents that lie in a bounding box.
Gets all agents in a bounding box.
- Parameters:
bb – The bounding box specified in world-fixed
ignore_lattice – Whether to ignore the lattice when computing neighbors
- Returns:
All obstacles that lie in a bounding box
Find an entity by identifier
- Parameters:
uid – The entity uid
- Returns:
The entity or nullptr if not found.
Gets the periodic lattice.
- Parameters:
axis – The axis (0 for x, 1 for y)
- Returns:
An optional tuple of points that define a periodic lattice that wraps the selected axis.
The N=0, 1, or 2 vectors that define the lattice, e.g.,
{delta_x, -delta_x}
if only the axis=0 lattice is set.- Parameters:
include_zero – Whether to include the zero vector
c8 – Whether to use 8-connectivity instead of 4-connectivity
- Returns:
A vector of 2D vectors
Gets all walls in a bounding box.
- Parameters:
bb – The bounding box specified in world-fixed
- Returns:
All walls that lie in a bounding box
Gets all neighbor of an agent
- Parameters:
agent – The agent
distance – The radius of the neighborhood
ignore_lattice – Whether to ignore the lattice when computing neighbors
- Returns:
All neighbor within a circle of radius
radius
centered around the agent.
Gets all obstacles in a bounding box.
- Parameters:
bb – The bounding box specified in world-fixed coordinates
- Returns:
All obstacles that lie in a bounding box.
Check if two entities are currently in collision
- Parameters:
e1 – The first entity
e2 – The second entity
- Returns:
True if they are in collision.
Searches for the index of an agent.
- Parameters:
agent – The agent
- Returns:
The index of this agent in the world agents list or null if not found.
Load a world modulation from a YAML string.
- Returns:
The loaded world or
None
if loading fails.- Return type:
World| None
Record the collision between two entities
- Parameters:
e1 – The first entity
e2 – The second entity
Clear all the callbacks
Updates the world for one or more time steps
- Parameters:
steps – The number of steps
time_step – The duration of each time step
Updates the world until a condition is satisfied
- Parameters:
condition – The condition
time_step – The duration of each time step
Returns the json-schema
- Returns:
json-schema
- Return type:
dict[str, typing.Any]
Sets the periodic lattice.
- Parameters:
axis – The axis (0 for x, 1 for y)
value – An optional tuple of points that define a periodic lattice that wraps the selected axis. Pass none to unset the lattice and remove wrapping.
Sets a condition to terminate simulations
- Parameters:
value – The desired condition.
Checks whether the simulation should terminate
- Returns:
True if a termination condition is set and evaluates to true.
Snap agents’ twists smaller than epsilon to zero.
- Parameters:
epsilon – The tolerance
Move agents so that they do not overlap anymore with themselves or with any obstacle
- Parameters:
minimal_distance – The minimal distance
with_safety_margin – Whether the safety margin should be added to the minimal distance
max_iterations – The maximal number of iterations to perform.
Updates world for a single time step.
- Parameters:
time_step – The time step
Updates world for a single time step without actuation and collisions resolution.
- Parameters:
time_step – The time step
advance_time – Whenever to advance time too.
- Type:
All agents in this world.
-
The bounding box.
- Type:
The colliding pairs computed during the last simulation step.
- Type:
All disc shaped static obstacles in this world.
- Parameters:
ignore_lattice – whether to ignore the lattice
- Type:
Returns whether there is a termination condition set.
- Returns:
True if a termination condition has been set.
- Type:
All line obstacles in this world.
-
The bounding box that contains all agents, obstacles and walls.
- Type:
All obstacles in this world.
- Type:
The random generator.
- Return type:
- Type:
The random seed.
- Type:
The simulation step.
- Type:
The simulation time.
- Type:
All walls in this world.