Skip to content

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.

Core Features

  • Support for getting robot IP address
  • Support for getting extension list
  • Support for getting single extension details
  • Support for toggling extension enable/disable status
  • Support for calling extension service commands
  • Support for centralized management of extension life-cycle

Use Cases

  • Management of third-party plug-ins on robot controllers from host PC
  • Extending robot functionality by calling services provided by extensions
  • Monitoring and controlling extension enable status
  • Connecting to robot controllers in extension or teaching pendant environments
  • Integration of robots with third-party systems

4.15.1 Get the Robot's IP Address

Method Nameextension.get_robot_ip() -> str
DescriptionReturns the corresponding robot IP address based on the environment where the SDK is running
Request ParametersNone
Return Valuestr: IP address (may be None)
Compatible robot software versionCollaborative (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:

  1. Industrial Teaching Pendant Environment: Returns the controller's IP address
  2. Collaborative AP Board Environment:
    • DHCP mode: Returns the router's IP address (default gateway)
    • Static IP mode: Returns the configured static IP address
  3. Cloud Environment: Returns the cloud's internal IP address
  4. Other Environments: Returns None

Note

  • This method is primarily used in extension environments where connection to the robot controller is required

Example Code

extension/connect_operation.py
py
"""
Copyright © 2016 Agilebot Robotics Ltd. All rights reserved.

Instruction: 插件系统连接机器人示例
本示例展示如何在插件系统中连接机器人。插件系统会自动识别运行环境:
- 在插件环境中运行时:自动获取机器人IP地址,无需手动配置
- 在本地开发环境中运行时:使用下方的 local_robot_ip 和 local_ap_ip 配置

Example of extension connection:
This example demonstrates how to connect to the robot in the extension system.
The extension system automatically identifies the running environment:
- In extension environment: Automatically obtains the robot IP address
- In local development environment: Uses the local_robot_ip and local_ap_ip configuration below
"""

from Agilebot import Arm, Extension, StatusCodeEnum

extension = Extension()

# ========== 本地开发配置 / Local Development Configuration ==========
# 以下配置仅在本地开发环境中生效,插件环境会自动获取IP
# The following configuration only takes effect in local development environment
local_robot_ip = "10.27.1.254"  # 机器人控制器IP / Robot controller IP (modify to 192.168.110.2 for industrial robot)
local_ap_ip = "10.27.1.254"  # 示教器或AP IP(工业机器人改为 192.168.110.102 或 None)/ Teach pendant IP or AP IP (modify to 192.168.110.102 or None for industrial robot)

# ========== 自动识别运行环境 / Automatically Identify Running Environment ==========
robot_ip = extension.get_robot_ip()
if robot_ip is None:
    # 本地开发环境:使用上方配置的IP / Local development: use configured IP above
    print("本地开发环境 / Local development environment")
    robot_ip = local_robot_ip
    ap_ip = local_ap_ip
else:
    # 插件环境:自动获取机器人IP / Extension environment: auto-obtain robot IP
    print(f"插件环境,自动获取到机器人IP / Extension environment, auto-obtained robot IP: {robot_ip}")
    ap_ip = "127.0.0.1"

print(f"robot_ip: {robot_ip}")
print(f"ap_ip: {ap_ip}")

arm = Arm()
ret = arm.connect(arm_controller_ip=robot_ip, teach_panel_ip=ap_ip)
if ret == StatusCodeEnum.OK:
    print("机器人连接成功 / Robot connected successfully")
else:
    print(f"机器人连接失败,错误代码 / Robot connection failed, error code: {ret.errmsg}")
    arm.disconnect()
    exit(1)

4.15.2 Get Extension List

Method Nameextension.get_list() → tuple[list[ExtensionInfo], StatusCodeEnum]
DescriptionRetrieves information for all extensions installed on the robot
Request ParametersNone
Return Valuelist[ExtensionInfo] : list of extension information.
StatusCodeEnum : execution result of the function.
Compatible robot software versionCollaborative (Copper): v7.7.0.0+
Industrial (Bronze): not supported

4.15.3 Get Extension Details

Method Nameextension.get( name : str) → tuple[ExtensionInfo, StatusCodeEnum]
DescriptionQueries details of a single extension by its name
Request Parametersname : extension name.
Return ValueExtensionInfo : detailed extension information.
StatusCodeEnum : execution result of the function.
Compatible robot software versionCollaborative (Copper): v7.7.0.0+
Industrial (Bronze): not supported

4.15.4 Toggle Extension Enable Status

Method Nameextension.toggle( name : str) → StatusCodeEnum
DescriptionToggles the enabled/disabled state of the specified extension.
Request Parametersname : extension name.
Return ValueStatusCodeEnum : execution result of the function.
Compatible robot software versionCollaborative (Copper): v7.7.0.0+
Industrial (Bronze): not supported

4.15.5 Call Simple-Service Extension Command

Method Nameextension.call_service( name : str, command : str, params : dict = None) → tuple[Any, StatusCodeEnum]
DescriptionInvokes a simple-service command provided by the specified extension and returns its execution result
Request Parametersname : extension name.
command : extension command name.
params : command parameters (optional, default None).
Return ValueAny : execution result of the extension command.
StatusCodeEnum : execution result of the function.
Compatible robot software versionCollaborative (Copper): v7.7.0.0+
Industrial (Bronze): not supported

Example Code

extension/extension_operation.py
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}")