irsim.world.object_factory#
Classes#
Factory class for creating various objects in the simulation. |
Module Contents#
- class irsim.world.object_factory.ObjectFactory[source]#
Factory class for creating various objects in the simulation.
- create_from_parse(parse: list[dict[str, Any]] | dict[str, Any], obj_type: str = 'robot', group_start_index: int = 0) list[Any][source]#
Create objects from a parsed configuration.
- Parameters:
parse (list or dict) – Parsed configuration data.
obj_type (str) – Type of object to create, ‘robot’ or ‘obstacle’.
group_start_index (int) – Starting index for the group.
- Returns:
List of created objects.
- Return type:
list
- create_from_map(points: numpy.ndarray, reso: float = 0.1, grid_map: numpy.ndarray | None = None, grid_reso: numpy.ndarray | None = None, world_offset: list[float] | None = None) list[Any][source]#
Create map objects from points.
- Parameters:
points (np.ndarray) – Array of points defining the map.
reso (float) – Resolution of the map.
grid_map (np.ndarray, optional) – Grid map array for fast collision detection. If None, no precomputed grid is used.
grid_reso (np.ndarray, optional) – Resolution [x_reso, y_reso] of the grid. If None, the resolution is not specified and grid-based collision is either inferred elsewhere or not used.
world_offset (list[float], optional) – World offset [x, y]. If None, no additional world offset is applied.
- Returns:
List of ObstacleMap objects.
- Return type:
list
- create_object(obj_type: str = 'robot', number: int = 1, distribution: dict[str, Any] | None = None, state: list[float] | None = None, goal: list[float] | None = None, **kwargs: Any) list[Any][source]#
Create multiple objects based on the parameters.
- Parameters:
obj_type (str) – Type of object, ‘robot’ or ‘obstacle’.
number (int) – Number of objects to create.
distribution (dict) – Distribution type for generating states.
state (list) – Initial state for objects.
goal (list) – Goal state for objects.
**kwargs – Additional parameters for object creation.
- Returns:
List of created objects.
- Return type:
list
- create_robot(kinematics: dict[str, Any] | None = None, **kwargs: Any) Any[source]#
Create a robot based on kinematics.
Uses the kinematics registry to look up handler-class metadata (default color, state_dim, description) and creates an
ObjectBasedirectly. Static /Nonekinematics still produce anObjectStatic.- Parameters:
kinematics (dict) – Kinematics configuration.
**kwargs – Additional parameters for robot creation.
- Returns:
An instance of a robot.
- Return type:
- create_obstacle(kinematics: dict[str, Any] | None = None, **kwargs: Any) Any[source]#
Create an obstacle based on kinematics.
Uses the kinematics registry to look up handler-class metadata (default color, state_dim) and creates an
ObjectBasedirectly. Static /Nonekinematics still produce anObjectStatic.- Parameters:
kinematics (dict) – Kinematics configuration.
**kwargs – Additional parameters for obstacle creation.
- Returns:
An instance of an obstacle.
- Return type:
- generate_state_list(number: int = 1, distribution: dict[str, Any] | None = None, state: list[float] | None = None, goal: list[float] | None = None) tuple[list[list[float]], list[list[float]]][source]#
Generate a list of state vectors for multiple objects based on the specified distribution method.
This function creates initial states for multiple objects in the simulation environment. It supports various distribution methods such as ‘manual’, ‘circle’, and ‘random’ to position the objects according to specific patterns or randomness.
- Parameters:
number (int) – Number of state vectors to generate. Default is 1.
distribution (Dict[str, Any]) – Configuration dictionary specifying the distribution method and its parameters. Default is {“name”: “manual”}.
state (List[float]) – Base state vector [x, y, theta] to use as a template for generating states. Default is [1, 1, 0].
goal (List[float]) –
Goal state vector [x, y, theta] for the generated objects. Default is [1, 9, 0].
’name’ (str): Name of the distribution method. Supported values are:
’manual’: States are specified manually.
’circle’: States are arranged in a circular pattern.
’random’: States are placed at random positions.
Additional parameters depend on the distribution method:
For ‘manual’: Manually specified states and goal.
For ‘circle’:
’center’ (List[float]): Center coordinates [x, y] of the circle.
’radius’ (float): Radius of the circle.
For ‘random’:
’range_low’ (List[float]): Lower bounds for random state values.
’range_high’ (List[float]): Upper bounds for random state values.
- Returns:
A pair
(state_list, goal_list)where each element is a list of 3-element state vectors[x, y, theta]for every generated object.- Return type:
tuple[list[list[float]], list[list[float]]]
- Raises:
ValueError – If the distribution method specified in ‘name’ is not supported or if required parameters for a distribution method are missing.