_body

Module Contents

Classes

Body

Body of a modular robot.

Attributes

TModule

TModuleNP

TModule
TModuleNP
class Body(core: modular_robot.body.base._core.Core)

Body of a modular robot.

property core: modular_robot.body.base._core.Core

Get the core of the Body.

Returns:

The core.

classmethod grid_position(module: modular_robot.body._module.Module) pyrr.Vector3

Calculate the position of this module in a 3d grid with the core as center.

The distance between all modules is assumed to be one grid cell. All module angles must be multiples of 90 degrees.

Parameters:

module – The module to calculate the position for.

Returns:

The calculated position.

Raises:

KeyError – In case an attachment point is not found.

find_modules_of_type(module_type: Type[TModule], exclude: list[Type[TModule]] | None = None) list[TModule]

Find all Modules of a certain type in the robot.

Parameters:
  • module_type – The type.

  • exclude – Module types to be excluded in search.

Returns:

The list of Modules.

to_grid() tuple[numpy.typing.NDArray[TModuleNP], pyrr.Vector3[numpy.int_]]

Convert the tree structure to a grid.

The distance between all modules is assumed to be one grid cell. All module angles must be multiples of 90 degrees.

The grid is indexed depth, width, height, or x, y, z, from the perspective of the core.

Returns:

The created grid with cells set to either a Module or None and a position vector of the core. The position Vector3 is dtype: int.