Emergency Stop Button Monitoring APIs
EStopMonitor
Section titled “EStopMonitor”EStopMonitor is an emergency stop button monitor that provides active querying of the emergency stop button state and supports setting event callbacks.
Constructor
Section titled “Constructor”-
Method:
__init__(self, cfg: EStopMConfig = ...) -> None -
Parameters:
ParameterDescription cfgConfiguration parameter. For details, please refer to EStopMConfig. -
Return Value:
None.
Start Monitoring
Section titled “Start Monitoring”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:
Trueif started successfully,Falseotherwise.
Pause Monitoring
Section titled “Pause Monitoring”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:
Trueif paused successfully,Falseotherwise.
Check if Monitoring Is Running
Section titled “Check if Monitoring Is Running”-
Method:
is_running(self) -> bool -
Return Value:
Trueif monitoring is running,Falseotherwise.
Get Current Emergency Stop Button State
Section titled “Get Current Emergency Stop Button State”-
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:
ParameterDescription callbackCallback function triggered when the emergency stop button is pressed. Multiple callback functions are allowed if EStopMConfig.allow_multicb_istrue. -
Return Value:
0or1indicates success (where1means an existing callback was replaced, which only occurs when only one callback is allowed).-1indicates 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:
ParameterDescription callbackCallback function triggered when the emergency stop button is released. Multiple callback functions are allowed if EStopMConfig.allow_multicb_istrue. -
Return Value:
0or1indicates success (where1means an existing callback was replaced, which only occurs when only one callback is allowed).-1indicates failure.
EStopMConfig
Section titled “EStopMConfig”Attributes
Section titled “Attributes”| Attribute | Data Type | Description |
|---|---|---|
pressed_level_ | int | GPIO 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_ | bool | Whether multiple callback functions are allowed. - True: Multiple callbacks are allowed.- False: Only one callback is allowed. |
name_ | str | Name |
Static Functions
Section titled “Static Functions”| Static function | Description |
|---|---|
ApacheOrin | Returns a configured EStopMConfig instance (gpiochip0 + pin 2 + Active-Low), suitable for robots equipped with the ApacheOrin chip. |
NvidiaOrin | Returns a configured EStopMConfig instance (gpiochip1 + pin 9 + Active-High), suitable for robots equipped with the NvidiaOrin chip. |
ESState
Section titled “ESState”The ESState class is an enumerator representing the state of the emergency stop button.
| Constant Member | Value | Description |
|---|---|---|
Invalid | -1 | Unable to get status |
Pressed | 1 | Emergency stop button is pressed |
Released | 0 | Emergency stop button is released |