六轴机械臂#

介绍#

VEX 6轴机械臂可在三维空间中移动末端执行器,控制末端执行器的姿态,并可与磁性拾取工具或笔架工具等附件工具配合使用。

以下是所有可用方法的列表:

动作——将六轴机械臂移动到指定位置或方向。

  • move_to — 将末端执行器移动到指定的 x、y 和 z 坐标。

  • move_inc — 将末端执行器从其当前位置移动指定的距离。

  • move_end_effector_to — 将末端执行器旋转到指定的偏航角、横滚角和俯仰角方向。

  • move_end_effector_inc — 将末端执行器旋转指定的偏航角、横滚角和俯仰角。

变异器 — 配置移动、工具和控制设置。

获取器 — 返回运动状态、位置、方向和连接值。

  • is_done — 返回 6 轴机械臂是否已完成移动。

  • get_x — 返回末端执行器的当前 x 位置。

  • get_y — 返回末端执行器的当前 y 位置。

  • get_z — 返回末端执行器的当前 z 位置。

  • get_pitch — 返回末端执行器的当前俯仰角。

  • get_roll — 返回末端执行器的当前滚动角度。

  • get_yaw — 返回末端执行器的当前偏航角。

  • can_arm_reach_to — 返回 6 轴机械臂是否可以到达指定位置。

  • can_arm_reach_inc — 返回 6 轴机械臂是否可以移动指定的距离。

  • can_end_effector_reach_to — 返回末端执行器是否可以达到指定的方向。

  • can_end_effector_reach_inc — 返回末端执行器是否可以旋转指定的量。

  • get_timeout — 返回移动方法使用的当前超时值。

  • is_connected — 返回 6 轴机械臂是否连接到大脑。

回调函数——在发生起动事件时运行函数。

  • control_stopped — 注册一个在启用控制停止时要运行的函数。

构造函数——手动创建一个六轴机械臂对象。

  • Arm — 创建一个 6 轴机械臂对象。

本页面用于将六轴机械臂单独与 CTE Tile 配合使用。要将六轴机械臂与其他 CTE 工作单元组件(例如气动装置或传送带)配合使用,请将六轴机械臂连接到 EXP Brain,并使用相应的 EXP Arm 页面。

行动#

move_to#

move_to 将 6 轴机械臂移动到指定的 x、y 和 z 坐标。

x、y 和 z 坐标描述了末端执行器在三维空间中的位置。如果目标位置可能超出六轴机械臂的可达工作空间,请在此方法之前使用 can_arm_reach_to。

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

范围

描述

x

目标位置的 x 坐标(单位:毫米)。

y

目标位置的y坐标(单位:毫米)。

z

目标位置的z坐标(单位:毫米)。

wait

可选 wait=True (默认值)使项目等待移动完成后再继续。2 wait=False 开始移动并立即继续执行下一行代码。

# Move the 6-Axis Arm to (40, 140, 210)
arm.move_to(40, 140, 210)

# Start moving, then print the y-position while the arm moves
arm.move_to(-100, 200, 100, wait=False)

while not arm.is_done():
    brain.print(arm.get_y())
    brain.new_line()
    wait(0.25, SECONDS)

move_inc#

move_inc 将 6 轴机械臂沿 x、y 和 z 轴从其当前位置移动指定的距离。

使用此方法相对于末端执行器当前位置进行移动。如果移动可能将六轴机械臂置于其可达工作空间之外,请在此方法之前使用 can_arm_reach_inc。

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

范围

描述

x

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

y

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

z

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

wait

可选 wait=True (默认值)使项目等待移动完成后再继续。2 wait=False 开始移动并立即继续执行下一行代码。

# Move the 6-Axis Arm 100 millimeters along the y-axis
arm.move_inc(0, 100, 0)

move_end_effector_to#

move_end_effector_to 将 6 轴机械臂的末端执行器旋转到指定的偏航角、横滚角和俯仰角。

Orientation describes how the end effector is rotated. yaw rotates around the z-axis, roll rotates around the x-axis, and pitch rotates around the y-axis.

Usage:
arm.move_end_effector_to(yaw, roll, pitch, wait)

范围

描述

yaw

目标偏航角,单位为度。

roll

目标滚动角,单位为度。

pitch

目标俯仰角,单位为度。

wait

可选 wait=True (默认值)使项目等待移动完成后再继续。2 wait=False 开始移动并立即继续执行下一行代码。

# Rotate the end effector to 90 degrees of roll
arm.move_end_effector_to(0, 90, 0)

move_end_effector_inc#

move_end_effector_inc 将 6 轴机械臂的末端执行器从其当前方向旋转指定的偏航角、横滚角和俯仰角。

使用此方法可相对于末端执行器的当前偏航角、横滚角或俯仰角进行旋转。

Usage:
arm.move_end_effector_inc(yaw, roll, pitch, wait)

范围

描述

yaw

偏航角的变化量,以度为单位。

roll

滚动角度的变化量,以度为单位。

pitch

音调的变化,以度为单位。

wait

可选 wait=True (默认值)使项目等待移动完成后再继续。2 wait=False 开始移动并立即继续执行下一行代码。

# Rotate the end effector -50 degrees in pitch
arm.move_end_effector_inc(0, 0, -50)

变异体#

set_speed#

set_speed 设置 6 轴机械臂在运动方式中使用的运动速度。

项目开始时,6轴机械臂的速度设置为50%。

Usage:
arm.set_speed(speed)

范围

描述

speed

6轴机械臂的运动速度,从 1 到 100%。

# Set the 6-Axis Arm speed to 30%
arm.set_speed(30)

set_end_effector_type#

set_end_effector_type 设置连接到 6 轴机械臂的末端执行器的类型。

当末端执行器类型更改时,六轴机械臂会自动调整其 Z 轴偏移量以匹配所选工具。项目开始时,末端执行器类型设置为 Arm.MAGNET。

Usage:
arm.set_end_effector_type(type)

范围

描述

type

安装在 6 轴机械臂上的工具: Arm.MAGNET (磁性拾取工具)或 Arm.PEN (笔架工具)。

# Set the end effector type to the Pen Holder Tool
arm.set_end_effector_type(Arm.PEN)

set_end_effector_magnet#

set_end_effector_magnet 接合或释放磁性拾取工具。

The magnet state stays active until another set_end_effector_magnet method changes it. The magnet state is reset to False at the start of a project.

Usage:
arm.set_end_effector_magnet(state)

范围

描述

state

磁性拾取工具状态: True 表示拾取并保持物体,或 False 表示丢弃任何已拾取的物体并停止拾取新物体。

# Pick up objects and then drop them
arm.set_end_effector_type(Arm.MAGNET)
arm.set_end_effector_magnet(True)
wait(2, SECONDS)
arm.set_end_effector_magnet(False)

set_pen_offset#

set_pen_offset 设置当笔架工具连接到 6 轴臂时使用的 z 轴偏移量。

使用此方法前,请将末端执行器类型设置为 Arm.PEN 如果未选择笔架工具,则此方法无效。

笔偏移量是指从笔架工具顶部到白板笔笔尖的距离。在项目开始时,笔偏移量设置为 0笔偏移量为 0 时,机械臂的 Z 轴原点位于笔架工具与六轴机械臂连接点处。

Usage:
arm.set_pen_offset(zOffset)

范围

描述

zOffset

笔偏移值,单位为毫米。

# Set the end effector type to the Pen Holder Tool and set the pen offset
arm.set_end_effector_type(Arm.PEN)
arm.set_pen_offset(25)

set_control_stop#

set_control_stop 启用 6 轴机械臂的控制停止功能。

启用控制停止后,6 轴机械臂将立即停止所有运动,并且在项目重新启动之前不会运行任何进一步的机械臂运动方法。

Usage:
arm.set_control_stop(state)

范围

描述

state

可选。0 为真 True (默认值)启用控制停止。2 False 不启用控制停止。

# Stop the 6-Axis Arm and prevent further movement
arm.set_control_stop()

set_timeout#

set_timeout 设置移动 6 轴机械臂时使用的超时值。

如果在超时之前某个动作没有完成,项目将继续执行下一行代码。

Usage:
arm.set_timeout(timeout, units)

范围

描述

timeout

新的超时值。

units

可选。时间单位: MSEC (毫秒,默认值), SECONDS,或 SEC。

# Set the 6-Axis Arm timeout to 2 seconds
arm.set_timeout(2, SECONDS)

获取器#

is_done#

is_done 返回 6 轴机械臂是否已完成移动。

在调用移动方法时, wait=False ,则此方法非常有用。

  • True — 6轴机械臂已完成移动。

  • False ​​— 6轴机械臂仍在移动。

Usage:
arm.is_done()

参数

描述

此方法没有参数。

# Display the 6-Axis Arm's y-position while it moves
arm.move_to(-100, 200, 100, wait=False)

while not arm.is_done():
    brain.print(arm.get_y())
    brain.new_line()
    wait(0.25, SECONDS)

get_x#

get_x 返回末端执行器的当前 x 位置(以毫米为单位)。

使用此方法读取末端执行器当前沿 x 轴的位置。

Usage:
arm.get_x()

参数

描述

此方法没有参数。

# Print the current x position of the 6-Axis Arm
brain.print(arm.get_x())

get_y#

get_y 返回末端执行器的当前 y 位置(以毫米为单位)。

使用此方法读取末端执行器当前沿 y 轴的位置。

Usage:
arm.get_y()

参数

描述

此方法没有参数。

# Print the current y position of the 6-Axis Arm
brain.print(arm.get_y())

get_z#

get_z 返回末端执行器的当前 z 位置(以毫米为单位)。

使用此方法读取末端执行器当前沿 z 轴的位置。

Usage:
arm.get_z()

参数

描述

此方法没有参数。

# Print the current z position of the 6-Axis Arm
brain.print(arm.get_z())

get_pitch#

get_pitch 返回末端执行器的当前俯仰角(以度为单位)。

Usage:
arm.get_pitch()

参数

描述

此方法没有参数。

# Print the current pitch of the end effector
brain.print(arm.get_pitch())

get_roll#

get_roll 返回末端执行器的当前滚动角度(以度为单位)。

Usage:
arm.get_roll()

参数

描述

此方法没有参数。

# Print the current roll of the end effector
brain.print(arm.get_roll())

get_yaw#

get_yaw 返回末端执行器的当前偏航角(以度为单位)。

Usage:
arm.get_yaw()

参数

描述

此方法没有参数。

# Print the current yaw of the end effector
brain.print(arm.get_yaw())

can_arm_reach_to#

can_arm_reach_to 返回 6 轴机械臂是否可以将末端执行器移动到指定的 x、y 和 z 坐标。

使用此方法在执行 move_to 之前检查目标位置。

  • True — 6轴机械臂可以到达所请求的位置。

  • False ​​— 6轴机械臂无法到达请求的位置。

Usage:
arm.can_arm_reach_to(x, y, z)

范围

描述

x

目标位置的 x 坐标(单位:毫米)。

y

目标位置的y坐标(单位:毫米)。

z

目标位置的z坐标(单位:毫米)。

# Move the 6-Axis Arm to (100, -20, 50) if it can reach
if arm.can_arm_reach_to(100, -20, 50):
    arm.move_to(100, -20, 50)

can_arm_reach_inc#

can_arm_reach_inc 返回 6 轴机械臂是否可以将末端执行器从其当前位置移动指定的 x、y 和 z 距离。

使用此方法检查相对移动,然后再使用 move_inc。

  • True — 6 轴机械臂可以做出所请求的运动。

  • False ​​— 6 轴机械臂无法进行所请求的运动。

Usage:
arm.can_arm_reach_inc(x, y, z)

范围

描述

x

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

y

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

z

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

# Increment the 6-Axis Arm 100 mm along the x-axis if possible
if arm.can_arm_reach_inc(100, 0, 0):
    arm.move_inc(100, 0, 0)

can_end_effector_reach_to#

can_end_effector_reach_to 返回末端执行器是否可以旋转到指定的偏航角、横滚角和俯仰角。

使用此方法检查目标方向,然后再使用 move_end_effector_to。

  • True — 末端执行器可以达到所要求的方向。

  • False ​​— 末端执行器无法达到所请求的方向。

Usage:
arm.can_end_effector_reach_to(yaw, roll, pitch)

范围

描述

yaw

目标偏航角,单位为度。

roll

目标滚动角,单位为度。

pitch

目标俯仰角,单位为度。

# Rotate the end effector to 90 degrees of roll if possible
if arm.can_end_effector_reach_to(0, 90, 0):
    arm.move_end_effector_to(0, 90, 0)

can_end_effector_reach_inc#

can_end_effector_reach_inc 返回末端执行器是否可以从其当前方向旋转指定的偏航角、横滚角和俯仰角。

使用此方法检查相对方向运动,然后再使用 move_end_effector_inc。

  • True — 末端执行器可以进行所请求的旋转。

  • False ​​— 末端执行器无法进行所请求的旋转。

Usage:
arm.can_end_effector_reach_inc(yaw, roll, pitch)

范围

描述

yaw

偏航角的变化量,以度为单位。

roll

滚动角度的变化量,以度为单位。

pitch

音调的变化,以度为单位。

# Increment the end effector by 10 degrees of pitch if possible
if arm.can_end_effector_reach_inc(0, 0, 10):
    arm.move_end_effector_inc(0, 0, 10)

get_timeout#

get_timeout 返回 6 轴机械臂运动方法使用的超时值(以毫秒为单位)。

Usage:
arm.get_timeout()

参数

描述

此方法没有参数。

# Print the current movement timeout in milliseconds
brain.print(arm.get_timeout())

is_connected#

is_connected 返回 6 轴机械臂是否连接到大脑。

  • True — 6轴机械臂与大脑相连。

  • False ​​— 6轴机械臂未与大脑连接。

Usage:
arm.is_connected()

参数

描述

此方法没有参数。

# Print whether the 6-Axis Arm is connected
brain.print(arm.is_connected())

回调函数#

control_stopped#

control_stopped 注册一个在启用控制停止时运行的函数。

此方法返回 Event 类的一个实例。

Usage:
arm.control_stopped(callback, arg)

范围

描述

callback

先前定义的 函数,当控制停止功能启用时运行。

arg

可选。包含要传递给回调函数的参数的元组。有关更多信息,请参阅使用带参数的函数。

# Define a function to run when control stop is enabled
def when_control_stopped():
    brain.print("The arm has been control stopped")

# Run when_control_stopped when the 6-Axis Arm is control stopped
arm.control_stopped(when_control_stopped)

构造函数#

Arm#

Arm 创建一个 6 轴机械臂对象。

Usage:
Arm()

参数

描述

此构造函数没有参数。

# Construct a 6-Axis Arm named arm with the Arm class
arm = Arm()