全局路点管理接口

1 set_global_position - 新增全局路点

方法: set_global_position(socket_fd, pos_name, pos_value)

参数:

  • socket_fd:连接句柄
  • pos_name:坐标名称
  • pos_value:坐标值向量

返回值:

  • int:执行结果
    • 0:成功
    • 非0:失败,错误码见错误码详情

使用示例:

Python
import nrc_interface as nrc
import time
#建立连接
socket_fd = nrc.connect_robot("192.168.1.13", "6001")
#坐标名称
posName = "test_point"
#创建接收坐标的vector
move_cmd = nrc.MoveCmd()
#设置坐标值
target_pos = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
for pos in target_pos:
    move_cmd.targetPosValue.append(pos)
#调用函数设置全局坐标
#ret = nrc.set_global_position(socket_fd, posName, move_cmd.targetPosValue)
#if ret == 0:
#    print(f"设置全局坐标返回值(ret)={ret}")
#    print(f"全局坐标{posName}设置成功")
#else:
#    print(f"设置全局坐标失败,错误码:{ret}")
print("新增全局路点接口使用示例")
print(f"路点名称:{posName}")
print(f"路点位置:{target_pos}")
time.sleep(1)

2 set_global_position - 设置全局路点

方法: set_global_position(socket_fd, pos_name, pos_value)

参数:

  • socket_fd:连接句柄
  • pos_name:坐标名称
  • pos_value:坐标值向量

返回值:

  • int:执行结果
    • 0:成功
    • 非0:失败,错误码见错误码详情

使用示例:

Python
import nrc_interface as nrc
import time
#建立连接
socket_fd = nrc.connect_robot("192.168.1.13", "6001")
#坐标名称
posName = "test_point"
#创建接收坐标的vector
move_cmd = nrc.MoveCmd()
#设置新的坐标值
new_pos = [10.0, 20.0, 30.0, 0.0, 0.0, 0.0, 0.0]
for pos in new_pos:
    move_cmd.targetPosValue.append(pos)
#调用函数更新全局坐标
#ret = nrc.set_global_position(socket_fd, posName, move_cmd.targetPosValue)
#if ret == 0:
#    print(f"更新全局坐标返回值(ret)={ret}")
#    print(f"全局坐标{posName}更新成功")
#else:
#    print(f"更新全局坐标失败,错误码:{ret}")
print("更新全局路点接口使用示例")
print(f"路点名称:{posName}")
print(f"新路点位置:{new_pos}")
time.sleep(1)

3 get_global_position - 查询全局GP点位

方法: get_global_position(socket_fd, pos_name, pos_value)

参数:

  • socket_fd:连接句柄
  • pos_name:坐标名称
  • pos_value:输出参数,用于存储坐标值的向量

返回值:

  • int:执行结果
    • 0:成功
    • 非0:失败,错误码见错误码详情

使用示例:

Python
import nrc_interface as nrc
import time
#建立连接
socket_fd = nrc.connect_robot("192.168.1.13", "6001")
#坐标名称
posName = "test_point"
#创建接收坐标的vector
move_cmd = nrc.MoveCmd()
#调用函数
ret = nrc.get_global_position(socket_fd, posName, move_cmd.targetPosValue)
if ret == 0:
    print(f"获取全局坐标返回值(ret)={ret}")
    print(f"全局坐标位置={list(move_cmd.targetPosValue)}")
else:
    print(f"获取全局坐标失败,错误码:{ret}")
time.sleep(1)