neurapy_ai.utils package
neurapy_ai.utils.logging module
- class neurapy_ai.utils.logging.NeuraLogFormatter(fmt=None, datefmt=None, style='%', validate=True)
Bases:
Formatter- FORMATS = {10: '\x1b[92;20m[%(name)s][%(levelname)s] %(asctime)s: %(message)s\x1b[0m', 20: '\x1b[38;20m[%(name)s][%(levelname)s] %(asctime)s: %(message)s\x1b[0m', 30: '\x1b[33;20m[%(name)s][%(levelname)s] %(asctime)s: %(message)s\x1b[0m', 40: '\x1b[31;20m[%(name)s][%(levelname)s] %(asctime)s: %(message)s\x1b[0m', 50: '\x1b[31;1m[%(name)s][%(levelname)s] %(asctime)s: %(message)s\x1b[0m'}
- bold_red = '\x1b[31;1m'
- format(record)
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- format_string = '[%(name)s][%(levelname)s] %(asctime)s: %(message)s'
- green = '\x1b[92;20m'
- grey = '\x1b[38;20m'
- red = '\x1b[31;20m'
- reset = '\x1b[0m'
- yellow = '\x1b[33;20m'
neurapy_ai.utils.return_codes module
- class neurapy_ai.utils.return_codes.ReturnCode(value: int | None = ReturnCodes.SUCCESS, message: str | None = '')
Bases:
object
- class neurapy_ai.utils.return_codes.ReturnCodes(value)
Bases:
IntEnumAn enumeration.
- DATA_NOT_AVAILABLE = -2
- FUNCTION_NOT_INITIALIZED = -3
- INVALID_ARGUMENT = -1
- LOAD_CATEGORIES_FILE_FAILED = -24
- LOAD_MODEL_FAILED = -25
- MODEL_NOT_EXISTENT = -23
- NO_OBJECT_IN_SCENE = 20
- NO_RESULT_STORED = -21
- OBJECT_NOT_IN_MODEL = -20
- SELECTED_PIXEL_NOT_IN_MASK = -22
- SERVICE_CALL_FAILED = -5
- SERVICE_CALL_RETURN_ERROR = -6
- SERVICE_NOT_AVAILABLE = -4
- SUCCESS = 0
neurapy_ai.utils.transformation_utils module
- neurapy_ai.utils.transformation_utils.rotate_global(pose: Pose, x=0.0, y=0.0, z=0.0) Pose
Rotate the pose in global coordinate frame (robot base coordinates)
- Parameters:
pose (Pose) – The current pose
x (float, optional) – The rotation angle around global axis x in rad, by default 0.0
y (float, optional) – The rotation angle around global axis y in rad, by default 0.0
z (float, optional) – The rotation angle around global axis z in rad, by default 0.0
- Returns:
Rotated pose
- Return type:
- neurapy_ai.utils.transformation_utils.rotate_local(pose: Pose, x: float | None = 0.0, y: float | None = 0.0, z: float | None = 0.0) Pose
Rotate the pose in local coordinate frame (current pose coordinate frame)
- Parameters:
pose (Pose) – The current pose
x (float, optional) – The rotation angle around local axis x in rad, by default 0.0
y (float, optional) – The rotation angle around local axis y in rad, by default 0.0
z (float, optional) – The rotation angle around local axis z in rad, by default 0.0
- Returns:
Rotated pose
- Return type:
- neurapy_ai.utils.transformation_utils.translate_global(pose: Pose, x: float | None = 0.0, y: float | None = 0.0, z: float | None = 0.0) Pose
Translate a pose in global coordinate frame (robot base coordinates)
- Parameters:
pose (Pose) – The current pose
x (float, optional) – Translation in global x direction, by default 0.0
y (float, optional) – Translation in global y direction, by default 0.0
z (float, optional) – Translation in global z direction, by default 0.0
- Returns:
Translated pose
- Return type:
- neurapy_ai.utils.transformation_utils.translate_local(pose: Pose, x: float | None = 0.0, y: float | None = 0.0, z: float | None = 0.0) Pose
Translate a pose in local coordinate frame (current pose coordinate frame)
- neurapy_ai.utils.transformation_utils.type_check(data_in: Any)
Check if the input data has a type Pose
- Parameters:
data_in (any) – The input data
- Raises:
TypeError – If the data is not of type pose
neurapy_ai.utils.types module
- class neurapy_ai.utils.types.ApproachSequence(pre_pose: TCPPose, pose: TCPPose, post_pose: TCPPose | None = None)
Bases:
object
- class neurapy_ai.utils.types.BoundingBox(min_x: int, min_y: int, max_x: int, max_y: int)
Bases:
object- property area
- max_x: int
- max_y: int
- min_x: int
- min_y: int
- to_numpy() ndarray[Any, dtype[int]]
Return the bounding box as numpy array [min_x, min_y, max_x, max_y]
- Returns:
The bounding box as numpy array [min_x, min_y, max_x, max_y]
- Return type:
np.ndarray (shape [4], dtype int)
- class neurapy_ai.utils.types.DetectedObject(object_with_pose: neurapy_ai.utils.types.ObjectWithPose, detection_score: float, pose_confidence: float, mesh_folder_path: str, segmentation_index: int = -1)
Bases:
object- detection_score: float
- mesh_folder_path: str
- property name
- object_with_pose: ObjectWithPose
- property pose
- pose_confidence: float
- segmentation_index: int = -1
- class neurapy_ai.utils.types.EndEffector(name: str, neura_typename: str, tcp_pose: neurapy_ai.utils.types.Pose)
Bases:
object- name: str
- neura_typename: str
- class neurapy_ai.utils.types.Gripper(gripper_name: str, grasped_state: float, released_state: float)
Bases:
object- grasped_state: float
- gripper_name: str
- released_state: float
- class neurapy_ai.utils.types.JointState(positions: List[float])
Bases:
object- is_valid() bool
Check if the joint state is valid.
- Returns:
If this joint state is valid.
- Return type:
bool
- property positions
- class neurapy_ai.utils.types.MarkerParameters(optical_frame: str, marker_detector_type: int, squares_in_x: int, squares_in_y: int, square_size_m: float, marker_size_m: float, dictionary_id: str)
Bases:
object- dictionary_id: str
- marker_detector_type: int
- marker_size_m: float
- optical_frame: str
- square_size_m: float
- squares_in_x: int
- squares_in_y: int
- class neurapy_ai.utils.types.Pick(approach_sequence: neurapy_ai.utils.types.ApproachSequence, quality: float, gripper: neurapy_ai.utils.types.Gripper, object_with_pose: neurapy_ai.utils.types.ObjectWithPose, grasp_id: int)
Bases:
object- approach_sequence: ApproachSequence
- grasp_id: int
- object_with_pose: ObjectWithPose
- quality: float
- class neurapy_ai.utils.types.Place(approach_sequence: neurapy_ai.utils.types.ApproachSequence, gripper: neurapy_ai.utils.types.Gripper, object_name: str = '')
Bases:
object- approach_sequence: ApproachSequence
- object_name: str = ''
- class neurapy_ai.utils.types.Pose(translation: _SupportsArray[dtype] | _NestedSequence[_SupportsArray[dtype]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], orientation: _SupportsArray[dtype] | _NestedSequence[_SupportsArray[dtype]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])
Bases:
object- classmethod from_list(transformation_list: List)
Generate Pose from a list
- Parameters:
transformation_list (List) – Input list, which consist of [x, y, z, rx, ry, rz]
- Returns:
Generated pose
- Return type:
- classmethod from_numpy(transformation_matrix)
Create a Pose object from a numpy array
- Parameters:
transformation_matrix (numpy ndarray (shape [4, 4])) – A homogeneous transformation matrix representing a pose
- Returns:
The created Pose
- Return type:
- get_distance_to(other_pose) Tuple[float, float]
Calculate the distance to another pose. Important: This function does not take into account symmetries of an object when calculating the distance in orientation
- Parameters:
other_pose (Pose) – The pose to which the distances should be calculated
- Returns:
translation_distance (float) – Euclidean distance between the two poses in meter.
orientation_distance (float) – Angular distance between the orientation of the two poses in radian.
- to_list() List[float]
Converts the pose data to a list representation consisting of translation and xyz euler angles
- Returns:
The list representation [x, y, z, rx, ry, rz]
- Return type:
list
- to_numpy() ndarray[Any, dtype[float32]]
Converts the pose data to a homogeneous transfromation matrix
- Returns:
transformation_matrix – The pose as homogeneous transformation matrix
- Return type:
np.array (shape [4, 4], dtype float32)
- class neurapy_ai.utils.types.SegmentedInstance(class_name: str, segmentation_index: int, detection_score: float, bounding_box: neurapy_ai.utils.types.BoundingBox, class_instance_index: int = 0, instance_mask: numpy.__array_like._SupportsArray[numpy.dtype] | numpy.__nested_sequence._NestedSequence[numpy.__array_like._SupportsArray[numpy.dtype]] | bool | int | float | complex | str | bytes | numpy.__nested_sequence._NestedSequence[bool | int | float | complex | str | bytes] = None)
Bases:
object- bounding_box: BoundingBox
- class_instance_index: int = 0
- class_name: str
- detection_score: float
- instance_mask: _SupportsArray[dtype] | _NestedSequence[_SupportsArray[dtype]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = None
- segmentation_index: int
- class neurapy_ai.utils.types.SuctionGripper(gripper_name: str, grasped_state: List)
Bases:
object- grasped_state: List
- gripper_name: str
- class neurapy_ai.utils.types.TCPPose(pose: Pose | None = None, joint_state: JointState | None = None)
Bases:
object
- class neurapy_ai.utils.types.Workspace(pose: neurapy_ai.utils.types.Pose, frame: str, len_x: float, len_y: float, len_z: float, lookat_poses: List[neurapy_ai.utils.types.TCPPose], name: str = '', type: str = 'tabletop', mesh_model: str = '', collision_padding: float = 0.0)
Bases:
object- collision_padding: float = 0.0
- frame: str
- len_x: float
- len_y: float
- len_z: float
- mesh_model: str = ''
- name: str = ''
- type: str = 'tabletop'