4.15 Extension Management
Overview
The Extension module manages third-party plug-ins on the robot controller. It can retrieve the controller’s IP, list/view installed plug-ins, enable/disable them, and invoke their services.
Using the extension interface you can centrally control plug-in life-cycle from the host PC and send commands to extend robot functionality.
4.15.1 Get the Robot's IP Address
| Method Name | extension.get_robot_ip() -> str |
|---|---|
| Description | Returns the corresponding robot IP address based on the environment where the SDK is running |
| Request Parameters | None |
| Return Value | str: IP address (may be None) |
| Compatible robot software version | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
IP Acquisition Logic:
This method automatically determines and returns the appropriate IP address based on the environment where the SDK is running:
- Industrial Teaching Pendant Environment: Returns the controller's IP address
- Collaborative AP Board Environment:
- DHCP mode: Returns the router's IP address (default gateway)
- Static IP mode: Returns the configured static IP address
- Cloud Environment: Returns the cloud's internal IP address
- Other Environments: Returns
None
Note
- This method is primarily used in extension or teaching pendant environments where connection to the robot controller is required
4.15.2 Get Extension List
| Method Name | extension.get_list() → tuple[list[ExtensionInfo], StatusCodeEnum] |
|---|---|
| Description | Retrieves information for all extensions currently installed on the robot. |
| Request Parameters | None |
| Return Value | list[ExtensionInfo] : list of extension information.StatusCodeEnum : execution result of the function. |
| Compatible robot software version | Collaborative (Copper): v7.7.0.0+ Industrial (Bronze): not supported |
4.15.3 Get Extension Details
| Method Name | extension.get( name : str) → tuple[ExtensionInfo, StatusCodeEnum] |
|---|---|
| Description | Queries detailed information of a single extension by its name. |
| Request Parameters | name : extension name. |
| Return Value | ExtensionInfo : detailed extension information.StatusCodeEnum : execution result of the function. |
| Compatible robot software version | Collaborative (Copper): v7.7.0.0+ Industrial (Bronze): not supported |
4.15.4 Toggle Extension Enable Status
| Method Name | extension.toggle( name : str) → StatusCodeEnum |
|---|---|
| Description | Toggles the enabled/disabled state of the specified extension. |
| Request Parameters | name : extension name. |
| Return Value | StatusCodeEnum : execution result of the function. |
| Compatible robot software version | Collaborative (Copper): v7.7.0.0+ Industrial (Bronze): not supported |
4.15.5 Call Simple-Service Extension Command
| Method Name | extension.call_service( name : str, command : str, params : dict = None) → tuple[Any, StatusCodeEnum] |
|---|---|
| Description | Invokes a simple-service command provided by the specified extension and returns its execution result. |
| Request Parameters | name : extension name.command : extension command name.params : command parameters (optional, defaults to None). |
| Return Value | Any : execution result of the extension command.StatusCodeEnum : execution result of the function. |
| Compatible robot software version | Collaborative (Copper): v7.7.0.0+ Industrial (Bronze): not supported |
Example Code
py
#!python
"""
Copyright © 2016 Agilebot Robotics Ltd. All rights reserved.
Instruction: 插件使用示例 / Example of extension usage
"""
from Agilebot import Arm, StatusCodeEnum
# [ZH] 初始化捷勃特机器人
# [EN] Initialize the Agilebot robot
arm = Arm()
# [ZH] 连接捷勃特机器人
# [EN] Connect to the Agilebot robot
ret = arm.connect("10.27.1.254")
# [ZH] 检查是否连接成功
# [EN] Check if the connection is successful
if ret == StatusCodeEnum.OK:
print("机器人连接成功 / Robot connection successful")
else:
print(f"机器人连接失败,错误代码 / Robot connection failed, error code: {ret.errmsg}")
arm.disconnect()
exit(1)
res, ret = arm.extension.get("MathService")
if ret == StatusCodeEnum.OK:
print("获取插件信息成功 / Get extension information successfully")
print(f"插件信息 / Extension information: {res}")
else:
print(f"获取插件信息失败,错误代码 / Get extension information failed, error code: {ret.errmsg}")
ret = arm.extension.toggle("MathService")
if ret == StatusCodeEnum.OK:
print("切换插件状态成功 / Toggle extension status successfully")
else:
print(f"切换插件状态失败,错误代码 / Toggle extension status failed, error code: {ret.errmsg}")
res, ret = arm.extension.call_service("MathService", "add", dict([["a", 1], ["b", 2]]))
if ret == StatusCodeEnum.OK:
print("调用插件服务成功 / Call extension service successfully")
print(f"调用插件服务结果 / Call extension service result: {res}")
else:
print(f"调用插件服务失败,错误代码 / Call extension service failed, error code: {ret.errmsg}")