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)[源代码]#

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)[源代码]#

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

参数:

**kwargs -- shape parameters

Returns: Geometry of the object

step(state)[源代码]#

Transform geometry to the new state.

参数:

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

返回:

Transformed geometry.

返回类型:

shapely.geometry.base.BaseGeometry

get_init_Gh()[源代码]#

Generate initial G and h for convex object.

返回:

  • G matrix: (N, 2)

  • h vector: (N, 1)

  • cone_type (str): "norm2" for circle or "Rpositive" for polygon

  • convex_flag (bool): whether convex constraints are valid

返回类型:

tuple[np.ndarray, np.ndarray, str | None, bool | None]

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

Generate G and h for convex polygon.

参数:

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

返回:

  • G matrix: (N, 2)

  • h vector: (N, 1)

  • cone_type (str): "Rpositive" for polygon

  • convex_flag (bool): whether convex constraints are valid

返回类型:

tuple[np.ndarray | None, np.ndarray | None, str | None, bool]

get_circle_Gh(center: numpy.ndarray, radius: float)[源代码]#

Generate G and h for circle.

参数:
  • center -- (2, 1) array of center

  • radius -- float of radius

返回:

  • G matrix: (3, 2)

  • h vector: (3, 1)

  • cone_type (str): "norm2"

  • convex_flag (bool): True

返回类型:

tuple[np.ndarray, np.ndarray, str, bool]

cal_length_width(geometry)[源代码]#
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 | None#

Get the original vertices of the geometry.

property original_centroid: numpy.ndarray#

Get the original centroid of the geometry.

返回:

The original centroid of the geometry.

返回类型:

np.ndarray

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

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 | None = None, random_shape: bool = False, radius_range: list | None = None, wheelbase: float | None = None)[源代码]#

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

参数:

**kwargs -- shape parameters

Returns: Geometry of the object

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

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)[源代码]#

Construct a polygon geometry.

参数:
  • 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()

返回:

Polygon object

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

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)[源代码]#
Args

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

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

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)[源代码]#

Construct a LineString object.

参数:
  • 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()

返回:

LineString object

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

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: numpy.ndarray | float = 0.1, **kwargs)[源代码]#
参数:
  • points -- (2, N) array of points

  • reso -- resolution — either a (2, 1) array [x_reso, y_reso] or a scalar applied to both axes

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

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)[源代码]#
step(state)[源代码]#

Transform geometry to the new state.

参数:

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

返回:

Transformed geometry.

class irsim.lib.handler.geometry_handler.GeometryFactory[源代码]#

Factory class to create geometry handlers.

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