Skip to content

Get Safety Status Bits

SUMMARY

Get Safety Status Bits returns the current safety system state as a packed integer bitmask. Each bit corresponds to a specific safety state. Use bitwise operations to check individual safety conditions.

This is the most granular way to inspect the safety system state programmatically, giving more detail than the higher-level Get Safety Mode skill.

UNITS

Returns an integer bitmask (no units). Each bit encodes a safety flag - see the bit layout in the explanation.

The Skill

python
bits = robot.get_safety_status_bits()

The Code

Example: Read and Decode the Safety Status Bitmask

Connect to the robot, read the safety status bits, and log them.

python
"""
Logs the controller's raw safety status bitmask.

Supports Universal Robots (UR).

Usage:
    python get_safety_status_bits.py [--ip <ROBOT_IP>]
"""

import argparse

from loguru import logger

from telekinesis.synapse.robots.manipulators import universal_robots


def main(ip: str | None) -> None:
    """Log the raw safety status bitmask."""

    #===================== Create Robot ==========================================
    robot = universal_robots.UniversalRobotsUR10E(name='UR10e')

    try:
        #===================== Connect Robot ==========================================
        if ip:
            robot.connect(ip=ip)

        # ==================== Run Skill ============================================
        logger.success(f"safety_status_bits: {robot.get_safety_status_bits():#013b}")
    except (ConnectionError, OSError) as e:
        logger.error(f"Error occurred: {e}")
    finally:
        robot.disconnect()
        robot.shutdown()


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Read safety status bits Synapse example")
    parser.add_argument("--ip", type=str, default=None,
                         help="UR robot IP address for real hardware, e.g. 192.168.1.100")
    args = parser.parse_args()

    main(ip=args.ip)

Running the Example

bash
python get_safety_status_bits.py --ip 192.168.1.100

For all options:

bash
python get_safety_status_bits.py --help

Parameter Configuration

This skill takes no input parameters.

Returns

TypeDescription
intSafety system status bitmask. Bits 0-10 correspond to individual safety states.

Bit layout:

BitSafety Condition
0Normal mode active
1Reduced mode active
2Protective stopped
3Recovery mode active
4Safeguard stopped
5System emergency stop
6Robot emergency stop
7Emergency stop
8Violation
9Fault
10Stopped due to safety

Raises

ExceptionCondition
RuntimeErrorThe robot is not connected. Call connect() before reading the safety status bits.
NotImplementedErrorCalled on a manipulator brand other than Universal Robots, where this getter is not yet implemented.

How to Tune the Parameters

get_safety_status_bits takes no parameters, but reading the result correctly requires bitwise decoding: use bits & (1 << n) to test whether a specific bit from the layout above is set, since multiple safety conditions can be active at once.

Where to Use the Skill

  • Safety monitoring - Log full safety state in each control cycle for post-hoc diagnostics
  • Condition-specific handling - Detect individual safety states and trigger appropriate recovery procedures

When Not to Use the Skill

Do not use Get Safety Status Bits when:

  • A high-level summary is sufficient - use Get Safety Mode for a simpler integer safety mode code