六轴机械臂#
介绍#
VEX 六轴机械臂允许程序在三维空间中移动末端执行器,并通过偏航、横滚和俯仰旋转来控制其姿态。该六轴机械臂还可以配置不同的末端执行器,例如磁性拾取工具或笔夹工具。
以下是所有可用方法的列表:
动作 – 将六轴机械臂移动到三维空间中的指定位置或方向。
move_to– Moves the end effector to an absolute X, Y, Z position.move_inc– Moves the end effector by a relative X, Y, Z distance.move_end_effector_to– Rotates the end effector to an absolute yaw, roll, and pitch orientation.move_end_effector_inc– Rotates the end effector by a relative yaw, roll, and pitch amount.
修改器 – 配置六轴机械臂的行为、工具和运动设置。
set_speed– Sets the movement speed used for arm motion.set_end_effector_type– Sets the type of end effector attached to the arm.set_end_effector_magnet– Enables or disables the Magnet Pickup Tool.set_pen_offset– Sets the Z-axis offset used when the Pen Holder Tool is attached.set_control_stop– Enables the arm’s control stop to halt movement.set_timeout– Sets the timeout used for arm movement methods.
获取器 – 返回六轴机械臂的运动状态、位置、方向和配置值。
is_done– Returns whether the arm has completed its movement.get_x– Returns the current X position of the end effector.get_y– Returns the current Y position of the end effector.get_z– Returns the current Z position of the end effector.get_pitch– Returns the current pitch orientation of the end effector.get_roll– Returns the current roll orientation of the end effector.get_yaw– Returns the current yaw orientation of the end effector.can_arm_reach_to– Returns whether the arm can reach an absolute position.can_arm_reach_inc– Returns whether the arm can reach a relative position.can_end_effector_reach_to– Returns whether the arm can reach an absolute orientation.can_end_effector_reach_inc– Returns whether the arm can reach a relative orientation.control_stopped– Registers a function to run when the arm enters control stop.get_timeout– Returns the current timeout value used by arm movement methods.is_connected– Returns whether the arm is connected to the Brain.
构造函数 – 手动初始化和配置六轴机械臂。
Arm– Create a 6-Axis Arm.
行动#
move_to#
move_to moves the 6-Axis Arm to a specified x, y, and z coordinate.
该方法返回一个布尔值,指示六轴机械臂是否已到达请求的位置:
True— The 6-Axis Arm has reached the requested position.False— The 6-Axis Arm cannot reach the requested position.
Usage:
arm.move_to(x, y, z, wait)
范围 |
描述 |
|---|---|
x |
目标位置的 x 坐标(单位:毫米)。 |
是 |
目标位置的y坐标(单位:毫米)。 |
z |
目标位置的z坐标(单位:毫米)。 |
|
Optional.
|
# Move the Arm to (40, 140, 210)
arm.move_to(40, 140, 210)
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 轴移动的距离,单位为毫米。 |
|
Optional.
|
# Move the Arm +100 millimeters on the y-axis
arm.move_inc(0, 100, 0)
move_end_effector_to#
move_end_effector_to rotates the 6-Axis Arm’s end effector to a specified yaw, roll, and pitch orientation.
此方法返回一个布尔值,指示末端执行器是否已达到所请求的方向:
True— The end effector has reached the requested orientation.False— The end effector cannot reach the requested orientation.
Usage:
arm.move_end_effector_to(yaw, roll, pitch, wait)
范围 |
描述 |
|---|---|
偏航 |
末端执行器应指向的绕 z 轴的角度,以度为单位。 |
卷 |
末端执行器应指向的绕 x 轴的角度,以度为单位。 |
沥青 |
末端执行器绕 y 轴的指向角度(以度为单位)。 |
|
Optional.
|
# Orient the end effector to point towards
# 90 degrees around the x-axis
arm.move_end_effector_to(0, 90, 0)
move_end_effector_inc#
move_end_effector_inc rotates the 6-Axis Arm’s end effector by a specified relative yaw, roll, and pitch amount.
此方法返回一个布尔值,指示末端执行器是否已达到所请求的方向:
True— The end effector has reached the requested orientation.False— The end effector cannot reach the requested orientation.
Usage:
arm.move_end_effector_inc(yaw, roll, pitch, wait)
范围 |
描述 |
|---|---|
偏航 |
绕 z 轴的角度变化,以度为单位。 |
卷 |
绕 x 轴的角度变化,以度为单位。 |
沥青 |
绕 y 轴的角度变化,以度为单位。 |
|
Optional.
|
# Rotate the end effector -50 degrees around the y-axis
arm.move_end_effector_inc(0, 0, -50)
变异体#
set_speed#
set_speed sets the movement speed used by the 6-Axis Arm for motion commands.
Usage:
arm.set_speed(speed)
范围 |
描述 |
|---|---|
速度 |
6轴机械臂的移动速度,以1到100的百分比表示。 |
# Set the Arm speed to 30%
arm.set_speed(30)
set_end_effector_type#
set_end_effector_type sets the type of end effector attached to the 6-Axis Arm.
Usage:
arm.set_end_effector_type(type)
范围 |
描述 |
|---|---|
类型 |
A valid end effector type:
|
# Set the end effector type to the Magnet Pickup Tool
arm.set_end_effector_type(MAGNET)
set_end_effector_magnet#
set_end_effector_magnet sets the state of the Magnet Pickup Tool on the 6-Axis Arm.
Usage:
arm.set_end_effector_magnet(state)
范围 |
描述 |
|---|---|
状态 |
The state of the Magnet Pickup Tool:
|
# Pick up objects and then drop them
arm.set_end_effector_type(MAGNET)
arm.set_end_effector_magnet(True)
arm.move_inc(0, 0, 100)
arm.set_end_effector_magnet(False)
set_pen_offset#
set_pen_offset sets the z-axis offset used when the Pen Holder Tool is attached to the 6-Axis Arm.
Usage:
arm.set_pen_offset(zOffset)
范围 |
描述 |
|---|---|
z偏移 |
笔偏移量,单位为毫米。正值表示笔的偏移量从工具安装点向上移动。 |
set_control_stop#
set_control_stop enables the control stop for the 6-Axis Arm.
Usage:
arm.set_control_stop(state)
范围 |
描述 |
|---|---|
状态 |
Optional.
|
set_timeout#
set_timeout sets the timeout value used when moving the 6-Axis Arm.
Usage:
arm.set_timeout(timeout, units)
范围 |
描述 |
|---|---|
暂停 |
新的超时值。 |
单位 |
The unit to represent the time:
|
获取器#
is_done#
is_done returns a Boolean indicating whether the 6-Axis Arm is currently moving.
True— The 6-Axis Arm is not moving.False— The 6-Axis Arm is still moving.
Usage:
arm.is_done()
def main():
# Display the arm's position while it moves
arm.move_to(-100, 200, 100, False)
while not arm.is_done():
brain.print(arm.get_y())
brain.next_line()
wait(0.25, SECONDS)
get_x#
get_x returns the x position of the end effector in millimeters.
Usage:
arm.get_x()
def main():
# Print the current x position of the Arm in millimeters
brain.print(arm.get_x())
get_y#
get_y returns the y position of the end effector in millimeters.
Usage:
arm.get_y()
def main():
# Print the current y position of the Arm in millimeters
brain.print(arm.get_y())
get_z#
get_z returns the z position of the end effector in in millimeters.
Usage:
arm.get_z()
def main():
# Print the current z position of the Arm in millimeters
brain.print(arm.get_z())
get_pitch#
get_pitch returns the current pitch of the end effector in degrees.
Usage:
arm.get_pitch()
def main():
# Print the current pitch of the Arm in degrees.
brain.print(arm.get_pitch())
get_roll#
get_roll returns the current roll of the end effector in degrees.
Usage:
arm.get_roll()
def main():
# Print the current roll of the Arm in degrees.
brain.print(arm.get_roll())
get_yaw#
get_yaw returns the current yaw of the end effector in degrees.
Usage:
arm.get_yaw()
def main():
# Print the current yaw of the Arm in degrees.
brain.print(arm.get_yaw())
can_arm_reach_to#
can_arm_reach_to returns a Boolean indicating whether the 6-Axis Arm can move the end effector to a specified x, y, and z coordinate.
True— The 6-Axis Arm can reach the requested position.False— The 6-Axis Arm cannot reach the requested position.
Usage:
arm.can_arm_reach_to(x, y, z)
范围 |
描述 |
|---|---|
x |
目标位置的 x 坐标(单位:毫米)。 |
是 |
目标位置的y坐标(单位:毫米)。 |
z |
目标位置的z坐标(单位:毫米)。 |
# Move the 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 returns a Boolean indicating whether the 6-Axis Arm can move the end effector by a specified relative x, y, and z distance.
True— The 6-Axis Arm can reach the requested position.False— The 6-Axis Arm cannot reach the requested position.
Usage:
arm.can_arm_reach_inc(x, y, z)
范围 |
描述 |
|---|---|
x |
沿 x 轴移动的距离(单位:毫米)。 |
是 |
沿 y 轴移动的距离(单位:毫米)。 |
z |
沿 z 轴移动的距离,单位为毫米。 |
# Increment the 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 returns a Boolean indicating whether the 6-Axis Arm can move the end effector to a specified yaw, roll, and pitch orientation.
True— The end effector can reach the requested orientation.False— The end effector cannot reach the requested orientation.
Usage:
arm.can_end_effector_reach_to(yaw, roll, pitch)
范围 |
描述 |
|---|---|
偏航 |
末端执行器应指向的绕 z 轴的角度,以度为单位。 |
卷 |
末端执行器应指向的绕 x 轴的角度,以度为单位。 |
沥青 |
末端执行器绕 y 轴的指向角度(以度为单位)。 |
# Orient towards 90 degrees on the x-axis 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 returns a Boolean indicating whether the 6-Axis Arm can move the end effector by a specified relative yaw, roll, and pitch amount.
True— The end effector can reach the requested orientation.False— The end effector cannot reach the requested orientation.
Usage:
arm.can_end_effector_reach_inc(yaw, roll, pitch)
范围 |
描述 |
|---|---|
偏航 |
绕 z 轴的角度变化,以度为单位。 |
卷 |
绕 x 轴的角度变化,以度为单位。 |
沥青 |
绕 y 轴的角度变化,以度为单位。 |
# Increment the end effector by
# +10 degrees on the y-axis if possible
if arm.can_end_effector_reach_inc(0, 0, 10):
arm.move_end_effector_inc(0, 0, 10)
control_stopped#
control_stopped registers a function that will be called when the control stop is enabled.
This method returns an instance of the Event class.
Usage:
arm.control_stopped(callback, arg)
参数 |
描述 |
|---|---|
|
先前定义的 函数,当控制停止功能启用时执行。 |
|
可选。包含要传递给回调函数的参数的元组。有关更多信息,请参阅使用带参数的函数。 |
# Define a function when_control_stopped
def when_control_stopped():
# Print to the Brain's screen that the Arm has been
# control stopped.
brain.print("The arm has been control stopped")
# Run when_control_stopped when the Arm is control stopped.
arm.control_stopped(when_control_stopped)
get_timeout#
get_timeout returns the timeout value used by the 6-Axis Arm move methods in milliseconds.
Usage:
arm.get_timeout()
is_connected#
is_connected returns a Boolean indicating whether the 6-Axis Arm is connected to the Brain.
True— The Arm is connected to the Brain.False— The Arm is not connected to the Brain.
Usage:
arm.is_connected()
构造函数#
Arm#
Arm create a 6-Axis Arm.
Arm()
范围 |
描述 |
|---|---|
此构造函数没有参数。 |
# Construct a 6-Axis Arm "arm" with the
# Arm class
arm = Arm()