irsim.world.object_factory#

Classes#

ObjectFactory

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') 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’.

Returns:

List of created objects.

Return type:

list

create_from_map(points: numpy.ndarray, reso: float = 0.1) list[Any][source]#

Create map objects from points.

Parameters:
  • points (list) – List of points.

  • reso (float) – Resolution of the map.

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.

Parameters:
  • kinematics (dict) – Kinematics configuration.

  • **kwargs – Additional parameters for robot creation.

Returns:

An instance of a robot.

Return type:

Robot

create_obstacle(kinematics: dict[str, Any] | None = None, **kwargs: Any) Any[source]#

Create a obstacle based on kinematics.

Parameters:
  • kinematics (dict) – Kinematics configuration.

  • **kwargs – Additional parameters for robot creation.

Returns:

An instance of an obstacle.

Return type:

Obstacle

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.