irsim.lib.handler.geometry_handler#

Classes#

geometry_handler

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

CircleGeometry

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

PolygonGeometry

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

RectangleGeometry

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

LinestringGeometry

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

PointsGeometry

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

geometry_handler3d

This class is used to handle the 3D geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

GeometryFactory

Factory class to create geometry handlers.

Module Contents#

class irsim.lib.handler.geometry_handler.geometry_handler(name: str, **kwargs)[source]#

Bases: abc.ABC

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

name#
geometry#
wheelbase#
abstractmethod construct_original_geometry(**kwargs)[source]#

Construct the original geometry of the object when the state is in the origin of coordinates.

Parameters:

**kwargs – shape parameters

Returns: Geometry of the object

step(state)[source]#

Transform geometry to the new state.

Parameters:

state (np.ndarray) – State vector [x, y, theta].

Returns:

Transformed geometry.

get_init_Gh()[source]#

Generate initial G and h for convex object.

Returns:

(N, 2) h vector: (N, 1) cone_type (str): “norm2” for circle or “Rpositive” for polygon convex_flag (bool): for convex or not

Return type:

G matrix

get_Gh(**kwargs)[source]#
get_polygon_Gh(vertices: numpy.ndarray | None = None)[source]#

Generate G and h for convex polygon.

Parameters:

vertices – (2, N), N: Edge number of the object

Returns:

(N, 2) h vector: (N, 1) cone_type (str): “norm2” for circle or “Rpositive” for polygon convex_flag (bool): for convex or not

Return type:

G matrix

get_circle_Gh(center: numpy.ndarray, radius: float)[source]#

Generate G and h for circle.

Parameters:
  • center – (2, 1) array of center

  • radius – float of radius

Returns:

(3, 2) h vector: (3, 1) cone_type (str): “norm2” convex_flag (bool): True

Return type:

G matrix

cal_length_width(geometry)[source]#
property vertices#
property init_vertices#

[[x1, y1], [x2, y2]…. [[x1, y1]]]; [x1, y1] will repeat twice

Type:

return original_vertices

property original_vertices: numpy.ndarray#

Get the original vertices of the geometry.

property original_centroid: numpy.ndarray#

Get the original centroid of the geometry.

Returns:

The original centroid of the geometry.

Return type:

np.ndarray

property radius#
class irsim.lib.handler.geometry_handler.CircleGeometry(name: str = 'circle', **kwargs)[source]#

Bases: geometry_handler

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

construct_original_geometry(radius: float = 0.2, center: list = [0, 0], random_shape: bool = False, radius_range: list = [0.1, 1.0], wheelbase: float | None = None)[source]#

Construct the original geometry of the object when the state is in the origin of coordinates.

Parameters:

**kwargs – shape parameters

Returns: Geometry of the object

class irsim.lib.handler.geometry_handler.PolygonGeometry(name: str = 'polygon', **kwargs)[source]#

Bases: geometry_handler

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

construct_original_geometry(vertices=None, random_shape: bool = False, is_convex: bool = False, **kwargs)[source]#

Construct a polygon geometry.

Parameters:
  • vertices – [[x1, y1], [x2, y2]..]

  • random_shape – whether to generate random shape, default is False

  • is_convex – whether to generate convex shape, default is False

  • **kwargs – see random_generate_polygon()

Returns:

Polygon object

class irsim.lib.handler.geometry_handler.RectangleGeometry(name: str = 'rectangle', **kwargs)[source]#

Bases: geometry_handler

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

construct_original_geometry(length: float = 1.0, width: float = 1.0, wheelbase: float | None = None)[source]#
Args

length: in x axis width: in y axis wheelbase: for ackermann robot

class irsim.lib.handler.geometry_handler.LinestringGeometry(name: str = 'linestring', **kwargs)[source]#

Bases: geometry_handler

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

construct_original_geometry(vertices, random_shape: bool = False, is_convex: bool = True, **kwargs)[source]#

Construct a LineString object.

Parameters:
  • vertices – [[x1, y1], [x2, y2]..]

  • random_shape – whether to generate random shape, default is False

  • is_convex – whether to generate convex shape, default is False

  • **kwargs – see random_generate_polygon()

Returns:

LineString object

class irsim.lib.handler.geometry_handler.PointsGeometry(name: str = 'map', **kwargs)[source]#

Bases: geometry_handler

This class is used to handle the geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

construct_original_geometry(points: numpy.ndarray, reso: float = 0.1)[source]#
Parameters:
  • points – (2, N) array of points

  • reso – resolution for the buffer

class irsim.lib.handler.geometry_handler.geometry_handler3d(name: str, **kwargs)[source]#

Bases: abc.ABC

This class is used to handle the 3D geometry of the object. It reads the shape parameters from yaml file and constructs the geometry of the object.

name#
geometry#
wheelbase#
abstractmethod construct_original_geometry(**kwargs)[source]#
step(state)[source]#

Transform geometry to the new state.

Parameters:

state (np.ndarray 6*1) – [x, y, z, roll, pitch, roll].

Returns:

Transformed geometry.

class irsim.lib.handler.geometry_handler.GeometryFactory[source]#

Factory class to create geometry handlers.

static create_geometry(name: str = 'circle', **kwargs) geometry_handler[source]#