电机与关节监控接口

头文件:include/tl_interface.h

1. get_current_motor_speed - 获取各关节电机当前转速

方法:get_current_motor_speed(socketFd, motor_speed, motor_speed_sync);

功能描述:获取当前电机转速。

参数:

  • socketFd:已连接的句柄。
  • motor_speed:输出参数,机器人本体电机转速,长度 7,单位 [RPM](需传入 VectorInt 实例)。
  • motor_speed_sync:输出参数,外部轴电机转速,长度 5,单位 [RPM](需传入 VectorInt 实例)。

返回值:

  • 0:成功。
  • 非 0:失败。

使用示例:

Python
import tl_interface as tl

# 建立连接

socket_fd = tl.connect_robot("192.168.1.13", "6001")

motor_speed = tl.VectorInt()        # 机器人本体电机转速,长度 7

motor_speed_sync = tl.VectorInt()   # 外部轴电机转速,长度 5

ret = tl.get_current_motor_speed(socket_fd, motor_speed, motor_speed_sync)

# 打印结果

print(f"返回值: {ret}")

print(f"本体电机转速: {list(motor_speed)}")

print(f"外部轴电机转速: {list(motor_speed_sync)}")

2. get_current_motor_torque - 获取各关节电机当前扭矩

方法:get_current_motor_torque(socketFd, motor_torque, motor_torque_sync);

功能描述:获取当前电机扭矩。

参数:

  • socketFd:已连接的句柄。
  • motor_torque:输出参数,机器人本体电机扭矩,长度 7,单位 [%](需传入 VectorInt 实例)。
  • motor_torque_sync:输出参数,外部轴电机扭矩,长度 5,单位 [%](需传入 VectorInt 实例)。

返回值:

  • 0:成功。
  • 非 0:失败。

使用示例:

Python
import tl_interface as tl

# 建立连接

socket_fd = tl.connect_robot("192.168.1.13", "6001")

motor_torque = tl.VectorInt()        # 机器人本体电机扭矩,长度 7

motor_torque_sync = tl.VectorInt()   # 外部轴电机扭矩,长度 5

ret = tl.get_current_motor_torque(socket_fd, motor_torque, motor_torque_sync)

# 打印结果

print(f"返回值: {ret}")

print(f"本体电机扭矩: {list(motor_torque)}")

print(f"外部轴电机扭矩: {list(motor_torque_sync)}")

3. get_current_motor_current - 获取各关节电机当前电流

方法:get_current_motor_current(socketFd, motor_current, motor_current_sync);

功能描述:获取当前电机电流。

参数:

  • socketFd:已连接的句柄。
  • motor_current:输出参数,机器人本体电机电流,长度 7,单位 ‰(需传入 VectorDouble 实例)。
  • motor_current_sync:输出参数,外部轴电机电流,长度 5,单位 ‰(需传入 VectorDouble 实例)。

返回值:

  • 0:成功。
  • 非 0:失败。

使用示例:

Python
import tl_interface as tl

# 建立连接

socket_fd = tl.connect_robot("192.168.1.13", "6001")

motor_current = tl.VectorDouble()        # 机器人本体电机电流,长度 7

motor_current_sync = tl.VectorDouble()   # 外部轴电机电流,长度 5

ret = tl.get_current_motor_current(socket_fd, motor_current, motor_current_sync)

# 打印结果

print(f"返回值: {ret}")

print(f"本体电机电流: {list(motor_current)}")

print(f"外部轴电机电流: {list(motor_current_sync)}")

4. get_current_motor_payload - 获取各关节电机当前负载

方法:get_current_motor_payload(socketFd, motor_payload, motor_payload_sync);

功能描述:获取当前电机负载。

参数:

  • socketFd:已连接的句柄。
  • motor_payload:输出参数,机器人本体电机负载,长度 7,单位 [%](需传入 VectorDouble 实例)。
  • motor_payload_sync:输出参数,外部轴电机负载,长度 5,单位 [%](需传入 VectorDouble 实例)。

返回值:

  • 0:成功。
  • 非 0:失败。

使用示例:

Python
import tl_interface as tl

# 建立连接

socket_fd = tl.connect_robot("192.168.1.13", "6001")

motor_payload = tl.VectorDouble()        # 机器人本体电机负载,长度 7

motor_payload_sync = tl.VectorDouble()   # 外部轴电机负载,长度 5

ret = tl.get_current_motor_payload(socket_fd, motor_payload, motor_payload_sync)

# 打印结果

print(f"返回值: {ret}")

print(f"本体电机负载: {list(motor_payload)}")

print(f"外部轴电机负载: {list(motor_payload_sync)}")

5. get_joint_voltage - 获取各关节电压

方法:get_joint_voltage(socketFd, joint_voltage, positioner_voltage);

功能描述:获取关节电压。

参数:

  • socketFd:已连接的句柄。
  • joint_voltage:输出参数,机器人本体各关节电压(需传入 VectorDouble 实例)。
  • positioner_voltage:输出参数,外部轴各关节电压(需传入 VectorDouble 实例)。

返回值:

  • 0:成功。
  • 非 0:失败。

使用示例:

Python
import tl_interface as tl

# 建立连接

socket_fd = tl.connect_robot("192.168.1.13", "6001")

joint_voltage = tl.VectorDouble()        # 机器人本体各关节电压

positioner_voltage = tl.VectorDouble()   # 外部轴各关节电压

ret = tl.get_joint_voltage(socket_fd, joint_voltage, positioner_voltage)

# 打印结果

print(f"返回值: {ret}")

print(f"本体关节电压: {list(joint_voltage)}")

print(f"外部轴关节电压: {list(positioner_voltage)}")

6. get_joint_temperature - 获取关节电机温度

方法:get_joint_temperature(socketFd, temperatures);

功能描述:获取关节温度。

参数:

  • socketFd:已连接的句柄。
  • temperatures:输出参数,用于存储输出的信息。

返回值:

  • 0:成功
  • 非 0:失败

使用示例:

Python
import tl_interface as tl

# 建立连接

socket_fd = tl.connect_robot("192.168.1.13", "6001")

joint_temperature = tl.VectorDouble()

ret = tl.get_joint_temperature(socket_fd, joint_temperature)

# 打印结果

print(f"返回值: {ret}")

print(f"关节温度: {list(joint_temperature)}")