body
Objects used for modular robot bodies.
Subpackages
Package Contents
Classes
An attachment point is a theoretical location on the parent module for the child to be attached to. |
|
Represents a color in RGBA format. |
|
Base class for a module for modular robots. |
|
Standard angles at which some modular robot modules can be attached. |
- class AttachmentPoint
An attachment point is a theoretical location on the parent module for the child to be attached to.
The attachment of a module to its parent is not considered to be a separate AttachmentPoint. This class simply is used for potential children to be placed on the correct positions of the current module.
- orientation: pyrr.Quaternion
The orientation of the attachment point on the module.
- offset: pyrr.Vector3
The offset for the attachment point, with respect to the center of the module.
- class Color
Represents a color in RGBA format.
All values should from 0 to 255.
- red: int
- green: int
- blue: int
- alpha: int
- to_normalized_rgba_list() list[float]
Convert to rgba list where each value is between 0 and 1.
- Returns:
The list.
- 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.