4.4 Program Information Read and Write
Overview
The ProgramPose interfaces are used to read, write, and convert pose points stored in the robot’s teach-pendant programs.
Via the program_pose module you can locate a specific program and point index, perform CRUD operations, and switch between Cartesian and joint representations—making it easy to batch-maintain program points or perform off-line editing from the host PC.
4.4.1 Get the Value of a Specified Pose in a Program
| Method Name | program_pose.read( program_name : str, index : int, program_type : str = USER_PROGRAM) -> tuple[ProgramPose, StatusCodeEnum] |
|---|---|
| Description | Get the value of a Pose with a specified index in a program. |
| Request Parameters | program_name : str The name of the specified program. index : int The index of the specified Pose. program_type : str The type of the program, default is USER_PROGRAM. |
| Return Value | ProgramPose: Pose information. StatusCodeEnum: Result of the function execution. |
| Compatible robot software version | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
4.4.2 Modify the Value of a Specified Pose in a Program
| Method Name | program_pose.write( program_name : str, index : int, value : ProgramPose, program_type : str = USER_PROGRAM) -> StatusCodeEnum |
|---|---|
| Description | Modify the value of a Pose with a specified index in a user-defined program. |
| Request Parameters | program_name : str The name of the specified program. index : int The index of the specified Pose. value : ProgramPose The new value of the Pose to be updated. program_type : str The type of the program, default is USER_PROGRAM. |
| Return Value | StatusCodeEnum: Result of the function execution. |
| Compatible robot software version | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
4.4.3 Get All Poses in a Specified Program
| Method Name | program_pose.read_all_poses( program_name : str, program_type : str = USER_PROGRAM) -> tuple[list[ProgramPose], StatusCodeEnum] |
|---|---|
| Description | Get all Pose information in a specified program. |
| Request Parameters | program_name : str The name of the specified program. program_type : str The type of the program, default is USER_PROGRAM. |
| Return Value | list[ProgramPose]: List of Pose information. StatusCodeEnum: Result of the function execution. |
| Compatible robot software version | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
4.4.4 Add a Pose Entry to a Program
| Method Name | program_pose.add( program_name : str, index : int, value : ProgramPose, program_type : str = USER_PROGRAM) -> StatusCodeEnum |
|---|---|
| Description | Add a new Pose at the specified index in a program. Returns an error if the index already exists. |
| Request Parameters | program_name : str The name of the specified program. index : int The index of the Pose to add. value : ProgramPose The Pose data to insert. program_type : str The program type, default is USER_PROGRAM. |
| Return Value | StatusCodeEnum: Result of the function execution. |
| Compatible robot software version | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
4.4.5 Write One or More Robot Pose Values in a Program
| Method Name | program_pose.write_poses( program_name : str, poses_to_update : list[ProgramPose]) -> StatusCodeEnum |
|---|---|
| Description | Write one or more robot Pose values in a program. Note: Only existing points can be updated; new points cannot be added. |
| Request Parameters | program_name : str The name of the specified program. poses_to_update : list[ProgramPose] List of poses to be updated. |
| Return Value | StatusCodeEnum: Result of the function execution. |
| Compatible robot software version | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
4.4.6 Robot Program Pose Type Conversion
| Method Name | ProgramPoses.convert_pose( pose : ProgramPose, from_type : PoseType, to_type : PoseType) -> tuple[ProgramPose, StatusCodeEnum] |
|---|---|
| Description | Convert the robot Pose values between joint coordinates and Cartesian space coordinates in a program. |
| Request Parameters | pose : ProgramPose The Pose value to be converted. from_type : PoseType The type before conversion. to_type : PoseType The desired type after conversion. |
| Return Value | ProgramPose: Pose information. StatusCodeEnum: Result of the function execution. |
| Compatible robot software version | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
Example Code
py
#!python
"""
Copyright © 2016 Agilebot Robotics Ltd. All rights reserved.
Instruction: 机器人位姿使用示例 / Example of robot pose usage
"""
from Agilebot import Arm, PoseType, StatusCodeEnum
# [ZH] 初始化捷勃特机器人
# [EN] Initialize the robot
arm = Arm()
# [ZH] 连接捷勃特机器人
# [EN] Connect to the robot
ret = arm.connect("10.27.1.254")
if ret == StatusCodeEnum.OK:
print("机器人连接成功 / Robot connected successfully")
else:
print(f"机器人连接失败,错误代码 / Robot connection failed, error code: {ret.errmsg}")
arm.disconnect()
exit(1)
program_name = "test_prog"
# [ZH] 读取所有位姿
# [EN] Read all poses
poses, ret = arm.program_pose.read_all_poses(program_name)
if ret == StatusCodeEnum.OK:
print("读取所有位姿成功 / Read all poses successfully")
# [ZH] 打印位姿信息
# [EN] Print pose information
for p in poses:
print(f"位姿ID / Pose ID:{p.id}\n位姿名称 / Pose name:{p.name}")
else:
print(f"读取所有位姿失败,错误代码 / Read all poses failed, error code: {ret.errmsg}")
arm.disconnect()
exit(1)
# [ZH] 读取单个位姿
# [EN] Read a single pose
pose, ret = arm.program_pose.read(program_name, 1)
if ret == StatusCodeEnum.OK:
print("读取单个位姿成功 / Read single pose successfully")
# [ZH] 打印位姿信息
# [EN] Print pose information
print(
f"位姿ID / Pose ID:{pose.id}\n"
f"位姿名称 / Pose name:{pose.name}\n"
f"位姿类型 / Pose type:{pose.poseData.pt}\n"
f"X:{pose.poseData.cartData.baseCart.position.x}\n"
f"Y:{pose.poseData.cartData.baseCart.position.y}\n"
f"Z:{pose.poseData.cartData.baseCart.position.z}\n"
f"J1:{pose.poseData.joint.j1}\n"
f"J2:{pose.poseData.joint.j2}\n"
f"J3:{pose.poseData.joint.j3}\n"
)
else:
print(f"读取单个位姿失败,错误代码 / Read single pose failed, error code: {ret.errmsg}")
arm.disconnect()
exit(1)
# [ZH] 修改位姿
# [EN] Modify pose
pose.comment = "SDK_TEST_COMMENT"
ret = arm.program_pose.write(program_name, 1, pose)
if ret == StatusCodeEnum.OK:
print("修改位姿成功 / Modify pose successfully")
else:
print(f"修改位姿失败,错误代码 / Modify pose failed, error code: {ret.errmsg}")
arm.disconnect()
exit(1)
# [ZH] 转换位姿
# [EN] Convert pose
converted_pose, ret = arm.program_pose.convert_pose(pose, PoseType.CART, PoseType.JOINT)
if ret == StatusCodeEnum.OK:
print("转换位姿成功 / Convert pose successfully")
else:
print(f"转换位姿失败,错误代码 / Convert pose failed, error code: {ret.errmsg}")
arm.disconnect()
exit(1)
# [ZH] 打印位姿信息
# [EN] Print pose information
print(
f"位姿ID / Pose ID:{converted_pose.id}\n"
f"位姿名称 / Pose name:{converted_pose.name}\n"
f"位姿类型 / Pose type:{converted_pose.poseData.pt}\n"
f"X:{converted_pose.poseData.cartData.baseCart.position.x}\n"
f"Y:{converted_pose.poseData.cartData.baseCart.position.y}\n"
f"Z:{converted_pose.poseData.cartData.baseCart.position.z}\n"
f"J1:{converted_pose.poseData.joint.j1}\n"
f"J2:{converted_pose.poseData.joint.j2}\n"
f"J3:{converted_pose.poseData.joint.j3}\n"
)
# [ZH] 断开捷勃特机器人连接
# [EN] Disconnect from the robot
arm.disconnect()
print("机器人断开连接成功 / Robot disconnected successfully")