Skip to content

Emergency Stop Button Monitoring APIs

EStopMonitor is an emergency stop button monitor that provides active querying of the emergency stop button state and supports setting event callbacks.

  • Method:

    __init__(self, cfg: EStopMConfig = ...) -> None
  • Parameters:

    Parameter
    Description
    cfgConfiguration parameter. For details, please refer to EStopMConfig.
  • Return Value:

    None.

If EStopMConfig.auto_start_ is set to True (default), the monitoring process will start automatically, and there is no need to manually call run().

Calling run() multiple times has no effect.

Once monitoring is started, the registered event callback functions may be triggered.

  • Method:

    run(self) -> bool
  • Return Value:

    True if started successfully, False otherwise.

After monitoring is paused, the registered event callback functions will not be triggered.

Calling pause() multiple times has no effect.

  • Method:

    pause(self) -> bool
  • Return Value:

    True if paused successfully, False otherwise.

  • Method:

    is_running(self) -> bool
  • Return Value:

    True if monitoring is running, False otherwise.

  • Method:

    get_state(self) -> ESState
  • Return Value:

    The emergency stop button state. For details, please refer to ESState.

Register Emergency Stop Button Pressed Callback Function

Section titled “Register Emergency Stop Button Pressed Callback Function”
  • Method:

    set_pressed_event_callback(self, callback: typing.Callable[[], None]) -> int
  • Parameter:

    Parameter
    Description
    callbackCallback function triggered when the emergency stop button is pressed. Multiple callback functions are allowed if EStopMConfig.allow_multicb_ is true.
  • Return Value:

    0 or 1 indicates success (where 1 means an existing callback was replaced, which only occurs when only one callback is allowed). -1 indicates failure.

Register Emergency Stop Button Released Callback Function

Section titled “Register Emergency Stop Button Released Callback Function”
  • Method:

    set_released_event_callback(self, callback: typing.Callable[[], None]) -> int
  • Parameter:

    Parameter
    Description
    callbackCallback function triggered when the emergency stop button is released. Multiple callback functions are allowed if EStopMConfig.allow_multicb_ is true.
  • Return Value:

    0 or 1 indicates success (where 1 means an existing callback was replaced, which only occurs when only one callback is allowed). -1 indicates failure.

AttributeData TypeDescription
pressed_level_intGPIO level polarity when the emergency stop button is pressed.
- 0: Active-Low. The pin level is low when the button is pressed.
- 1: Active-High. The pin level is high when the button is pressed.
allow_multicb_boolWhether multiple callback functions are allowed.
- True: Multiple callbacks are allowed.
- False: Only one callback is allowed.
name_strName
Static functionDescription
ApacheOrinReturns a configured EStopMConfig instance (gpiochip0 + pin 2 + Active-Low), suitable for robots equipped with the ApacheOrin chip.
NvidiaOrinReturns a configured EStopMConfig instance (gpiochip1 + pin 9 + Active-High), suitable for robots equipped with the NvidiaOrin chip.

The ESState class is an enumerator representing the state of the emergency stop button.

Constant MemberValueDescription
Invalid-1Unable to get status
Pressed1Emergency stop button is pressed
Released0Emergency stop button is released