Python#

本指南详细介绍了如何在 VEXcode CTE 中使用 Python 方法。您将在此学习如何阅读和理解每个方法,包括其全面的描述、参数和使用示例。

了解方法条目#

API 参考文档中的每个方法条目都包含以下组件:

  • 命令名称 – 该命令的正式名称。

  • 描述 – 简要说明该命令的作用以及它可能返回的结果。

  • 定义 – 命令的语法,展示如何在代码中编写该命令。

  • 参数表 – 列出该命令接受的所有输入。

  • 示例代码 – 提供一个可复制粘贴的代码块作为使用示例。

示例方法输入#

move_inc#

move_inc moves the 6-Axis Arm by a specified distance along the x, y, and z axes.

此方法将返回一个布尔值,指示六轴机械臂是否已到达请求的位置:

  • True — The 6-Axis Arm has reached the requested position.

  • False — The 6-Axis Arm cannot reach the requested position.

Usage:
arm.move_inc(x, y, z, wait)

范围

描述

x

沿 x 轴移动的距离(单位:毫米)。

沿 y 轴移动的距离(单位:毫米)。

z

沿 z 轴移动的距离,单位为毫米。

wait

Optional.

  • wait=True (default) – The project waits until move_inc is complete before executing the next line of code.
  • wait=False – The project starts the action and moves on to the next line of code right away, without waiting for move_inc to finish.

# Move the Arm +100 millimeters on the y-axis
arm.move_inc(0, 100, 0)