_module

Module Contents

Classes

Module

Base class for a module for modular robots.

class Module(orientation: pyrr.Quaternion, color: modular_robot.body._color.Color, attachment_points: dict[int, modular_robot.body._attachment_point.AttachmentPoint], sensors: list[modular_robot.body.sensors.Sensor])

Base class for a module for modular robots.

property uuid: uuid.UUID

Get the uuid.

Returns:

The uuid.

property orientation: pyrr.Quaternion

Get the orientation of this model relative to its parent.

Returns:

The orientation.

property parent: Module | None

Get the parent module of this module.

None if this module has not yet been added to a body or is the origin of the body.

Returns:

The parent module of this module, or None if this module has not yet been added to a body.

property parent_child_index: int | None

Index of this module in the parent modules child list.

None if this module has not yet been added to a body.

Returns:

The index of this module in the parent modules child list, or None if this module has not yet been added to a body.

property children: dict[int, Module]

Get all children on this module.

Returns:

The children and their respective attachment point index.

property color: modular_robot.body._color.Color

Get the color of this module.

Returns:

The color.

property attachment_points: dict[int, modular_robot.body._attachment_point.AttachmentPoint]

Get all attachment points of this module.

Returns:

The attachment points.

property sensors: _AttachedSensors

Get the sensors.

Returns:

The value.

set_child(module: Module, child_index: int) None

Attach a module to certain AttachmentPoint.

Parameters:
  • module – The module to attach.

  • child_index – The index of the AttachmentPoint to attach it to.

Raises:

KeyError – If attachment point is already populated.

can_set_child(child_index: int) bool

Check if a child can be set on a specific attachment point on the module.

Parameters:

child_index – The child index.

Returns:

The boolean value.

neighbours(within_range: int) list[Module]

Get the neighbours of this module with a certain range of the module tree.

Parameters:

within_range – The range in which modules are considered a neighbour. Minimum is 1.

Returns:

The neighbouring modules.

add_sensor(sensor: modular_robot.body.sensors.Sensor) None

Add a sensor to the module.

Parameters:

sensor – The sensor.