Skip to content

Safety

This module contains the functions and decorator for implementing safety measures in the robot. The decorator function is used to create guardrails for functions and functions, especially involving movement. The module also contains functions to set and reset the safety level for the safety measures.

ATTRIBUTE DESCRIPTION
safety_mode

Safety mode for the safety measures

TYPE: int

SafetyLevel

Enum for safety levels - DEBUG (int): Safety mode that logs the function call [0] - DELAY (int): Safety mode that waits for a few seconds before executing.[3] - SUPERVISED (int): Safety mode that requires user input before executing. [-10]

TYPE: Enum

FUNCTION DESCRIPTION
guard

Decorator for creating guardrails for functions and functions, especially involving movement

set_level

Set the safety level for the safety measures

reset_level

Reset the safety level to None

Documentation last updated: 2025-06-11

safety_mode module-attribute

safety_mode = None

Safety mode for the safety measures

SafetyLevel

Bases: IntEnum

Enum for safety levels

DEBUG class-attribute instance-attribute

DEBUG = 0

Safety mode that logs the function call

DELAY class-attribute instance-attribute

DELAY = 3

Safety mode that waits for a few seconds before executing. Defaults to 3.

SUPERVISED class-attribute instance-attribute

SUPERVISED = -10

Safety mode that requires user input before executing

get_safety_level

get_safety_level() -> int | None

Get the current safety level

RETURNS DESCRIPTION
int | None

int|None: current safety level

get_safety_mode

get_safety_mode(mode: int | None) -> int

Get the effective safety mode

PARAMETER DESCRIPTION
mode

safety mode

TYPE: int | None

RETURNS DESCRIPTION
int

effective safety mode

TYPE: int

guard

guard(mode: int = DEBUG) -> Callable

Decorator for creating guardrails for functions and functions, especially involving movement

PARAMETER DESCRIPTION
mode

mode for implementing safety measure. Defaults to SafetyLevel.DEBUG. - DEBUG (0): logs the function call - DELAY (>=1): waits for a few seconds before executing. Defaults to 3. - SUPERVISED (-10): requires user input before executing

TYPE: int DEFAULT: DEBUG

RETURNS DESCRIPTION
Callable

wrapped function

TYPE: Callable

reset_safety_level

reset_safety_level()

Reset the safety level to None

set_safety_level

set_safety_level(mode: int)

Set the safety level for the safety measures

PARAMETER DESCRIPTION
mode

safety mode - DEBUG (0): logs the function call - DELAY (>=1): waits for a few seconds before executing. Defaults to 3. - SUPERVISED (-10): requires user input before executing

TYPE: int