手臂#
初始化 Arm 类#
使用以下构造函数创建 6 轴臂:
臂(端口)
此构造函数使用一个参数:
范围 |
描述 |
---|---|
|
6 轴臂连接到的有效 智能端口。 |
# Construct a 6-Axis Arm "arm" with the
# Arm class.
arm = Arm(Ports.PORT1)
当引用 Arm 类方法时,此“arm”对象将在整个 API 文档的所有后续示例中使用。
类方法#
move_to()#
move_to(x, y, z, wait)
方法将末端执行器移动到请求的 X、Y 和 Z 绝对位置。
根据是否使用 wait
参数,这可以是 等待 或 非等待 方法。
参数 |
描述 |
---|---|
x |
要移动到的 x 坐标(以毫米为单位)。 |
y |
要移动到的 y 坐标(以毫米为单位)。 |
z |
要移动到的 z 坐标(以毫米为单位)。 |
等待 |
可选。 wait 参数决定该方法是否阻止后续方法( |
**返回:**当 wait 为 True
时,如果 6 轴臂已移动到请求的位置,则返回 True
。如果没有,则返回 False
。
# Move the Arm to (40, 140, 210).
arm.move_to(40, 140, 210)
move_inc()#
move_inc(x, y, z, wait)
方法将末端执行器移动所请求的 X、Y 和 Z 距离。
根据是否使用 wait
参数,这可以是 等待 或 非等待 方法。
参数 |
描述 |
---|---|
x |
x 轴上移动的距离(以毫米为单位)。 |
y |
沿 y 轴移动的距离(以毫米为单位)。 |
z |
z 轴上移动的距离(以毫米为单位)。 |
等待 |
可选。 wait 参数决定该方法是否阻止后续方法( |
**返回:**当 wait 为 True
时,如果 6 轴臂已移动到请求的位置,则返回 True
。如果没有,则返回 False
。
# Move the Arm +100 millimeters on the y-axis.
arm.move_inc(0, 100, 0)
move_end_effector_to()#
move_end_effector_to(yaw, roll, pitch, wait)
方法将末端效应器移动到请求的绝对偏航、滚转和俯仰方向。
根据是否使用 wait
参数,这可以是 等待 或 非等待 方法。
参数 |
描述 |
---|---|
偏航 |
末端执行器应指向的围绕 z 轴的角度(以度为单位)。 |
卷 |
末端执行器应指向的围绕 x 轴的角度(以度为单位)。 |
沥青 |
末端执行器应指向的 y 轴周围的角度(以度为单位)。 |
等待 |
可选。 wait 参数决定该方法是否阻止后续方法( |
返回: 如果在 wait 为 True
时末端执行器已移动到请求的方向,则返回 True
。如果没有,则返回 False
。
# 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(yaw, roll, pitch, wait)
方法将末端效应器移动到请求的相对偏航、滚转和俯仰方向。
根据是否使用 wait
参数,这可以是 等待 或 非等待 方法。
参数 |
描述 |
---|---|
偏航 |
末端执行器围绕 z 轴应改变的角度(以度为单位)。 |
卷 |
末端执行器围绕 x 轴应改变的角度(以度为单位)。 |
沥青 |
末端执行器围绕 y 轴应改变的角度(以度为单位)。 |
等待 |
可选。 wait 参数决定该方法是否阻止后续方法( |
返回: 如果在 wait 为 True
时末端执行器已移动到请求的方向,则返回 True
。如果没有,则返回 False
。
# Orient the End Effector -50 degrees on the y-axis.
arm.move_end_effector_inc(0, 0, -50)
set_speed()#
set_speed(speed)
方法设置移动的速度。
参数 |
描述 |
---|---|
速度 |
6 轴臂移动的速度。 |
**返回:**无。
set_end_effector_type()#
set_end_effector_type(type)
方法将末端效应器类型设置为 magnet
或 pen
。
参数 |
描述 |
---|---|
类型 |
有效的 EndEffectorType。 |
返回: 如果设置了请求的类型,则返回 True
。如果未设置,则返回 False
。
# Set the End Effector type to the Magnet Pickup Tool.
arm.set_end_effector_type(MAGNET)
set_end_effector_magnet()#
set_end_effector_magnet(state)
方法将末端效应器的磁铁拾取工具设置为启用或禁用。
参数 |
描述 |
---|---|
状态 |
设置为“True”则启用磁铁拾取工具,设置为“False”则禁用。 |
**返回:**无。
# Enable the Magnet Pickup Tool.
arm.set_end_effector_magnet(True)
set_pen_offset()#
set_pen_offset(zOffset)
方法设置笔末端效应器 z 轴偏移。
参数 |
描述 |
---|---|
z偏移 |
新的偏移量(以“MM”为单位)。正的 z 值表示向上。 |
**返回:**无。
set_control_stop()#
set_control_stop(state)
方法禁用 Arm 并将关节电机置于制动模式。
如果启用了控制停止,则除非重新启动整个项目,否则将无法禁用它。
参数 |
描述 |
---|---|
状态 |
“True”表示禁用进一步的线性或关节移动。 |
**返回:**无。
control_stopped()#
control_stopped(callback, arg)
方法注册一个函数,当 6 轴臂控制停止启用时调用该函数。
参数 |
描述 |
---|---|
打回来 |
当 6 轴臂控制停止时调用的函数 |
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.screen.print("The arm has been control stopped")
# Run when_control_stopped when the Arm is control stopped.
arm.control_stopped(when_control_stopped)
can_arm_reach_to()#
can_arm_reach_to(x, y, z)
方法检查末端执行器是否可以移动到请求的 X、Y 和 Z 绝对位置。
参数 |
描述 |
---|---|
x |
要移动到的 x 坐标(以毫米为单位)。 |
y |
要移动到的 y 坐标(以毫米为单位)。 |
z |
要移动到的 z 坐标(以毫米为单位)。 |
返回: 如果 Arm 可以移动到请求的位置,则返回 True
。如果不能,则返回 False
。
# Check if the Arm can move to the (100, -20, 50).
if arm.can_arm_reach_to(100, -20, 50):
# Move the Arm to (100, -20, 50).
arm.move_to(100, -20, 50)
can_arm_reach_inc()#
can_arm_reach_inc(x, y, z)
方法检查末端执行器是否可以移动到请求的 X、Y 和 Z 相对位置。
参数 |
描述 |
---|---|
x |
x 轴上移动的距离(以毫米为单位)。 |
y |
沿 y 轴移动的距离(以毫米为单位)。 |
z |
z 轴上移动的距离(以毫米为单位)。 |
返回: 如果 Arm 可以移动到请求的位置,则返回 True
。如果不能,则返回 False
。
# Check if the Arm can increment its position
# +100 mm along the x-axis.
if arm.can_arm_reach_inc(100, 0, 0):
# Increment the Arm +100 mm along the x-axis.
arm.move_inc(100, 0, 0)
can_end_effector_reach_to()#
can_end_effector_reach_to(yaw, roll, pitch)
方法检查末端执行器是否可以移动到请求的绝对偏航、滚转和俯仰方向。
参数 |
描述 |
---|---|
偏航 |
末端执行器应指向的围绕 z 轴的角度(以度为单位)。 |
卷 |
末端执行器应指向的围绕 x 轴的角度(以度为单位)。 |
沥青 |
末端执行器应指向的 y 轴周围的角度(以度为单位)。 |
**返回:**如果末端执行器可以移动到请求的方向,则返回 True
。如果不能,则返回 False
。
# Check If the arm can orient to 90 degrees on the x-axis.
if arm.can_end_effector_reach_to(0, 90, 0):
# Orient towards 90 degrees on the x-axis.
arm.move_end_effector_to(0, 90, 0)
can_end_effector_reach_inc()#
can_end_effector_reach_inc(yaw, roll, pitch)
方法检查末端执行器是否可以移动到请求的相对偏航、滚转和俯仰方向。
参数 |
描述 |
---|---|
偏航 |
末端执行器围绕 z 轴应改变的角度(以度为单位)。 |
卷 |
末端执行器围绕 x 轴应改变的角度(以度为单位)。 |
沥青 |
末端执行器围绕 y 轴应改变的角度(以度为单位)。 |
**返回:**如果末端执行器可以移动到请求的方向,则返回 True
。如果不能,则返回 False
。
# Check if the End Effector can increment its orientation
# +10 degrees on the y-axis.
if arm.can_end_effector_reach_inc(0, 0, 10):
# Increment the End Effector by +10 degrees on the y-axis.
arm.move_end_effector_inc(0, 0, 10)
is_done()#
is_done()
方法用于检查 6 轴臂当前是否正在移动。
返回: 如果 6 轴臂当前正在执行运动,则返回 True
。如果不是,则返回 False
。
def main():
# Move the Arm to (-100, 200, 100) and let subsequent
# methods execute.
arm.move_to(-100, 200, 100, False)
# Repeat the methods until the Arm is done moving.
while not arm.is_done():
# Print the Arm's current y position to the Brain's
# screen every .25 seconds.
brain.print(arm.get_y())
brain.next_row()
wait(0.25, SECONDS)
get_x()#
get_x()
方法返回末端执行器的 x 位置。
**返回:**末端执行器在“MM”中的 x 位置。
def main():
# Print the current x position of the Arm in millimeters.
brain.print(arm.get_x())
get_y()#
get_y()
方法返回末端执行器的 y 位置。
**返回:**末端执行器在“MM”中的 y 位置。
def main():
# Print the current y position of the Arm in millimeters.
brain.print(arm.get_y())
get_z()#
get_z()
方法请求末端执行器的 z 位置。
**返回:**末端执行器在“MM”中的 z 位置。
def main():
# Print the current z position of the Arm in millimeters.
brain.print(arm.get_z())
get_pitch()#
get_pitch()
方法请求末端执行器的当前音高。
**返回:**末端执行器的当前倾斜度(以度为单位)。
def main():
# Print the current pitch of the Arm in degrees.
brain.print(arm.get_pitch())
get_roll()#
get_roll()
方法请求末端执行器的当前滚动。
**返回:**末端执行器当前的滚动角度(以度为单位)。
def main():
# Print the current roll of the Arm in degrees.
brain.print(arm.get_roll())
get_yaw()#
get_yaw()
方法请求末端执行器的当前偏航。
**返回:**末端执行器当前的偏航角(以度为单位)。
def main():
# Print the current yaw of the Arm in degrees.
brain.print(arm.get_yaw())
set_timeout()#
set_timeout(timeout, units)
方法设置移动 6 轴臂时使用的超时值。
参数 |
描述 |
---|---|
暂停 |
新的超时值。 |
单位 |
有效的 TimeUnits 类型。默认单位为“MSEC”。 |
**返回:**无。
get_timeout()#
get_timeout()
方法获取 6 轴臂移动方法使用的当前超时值。
**返回:**以毫秒为单位的超时值。
# Get the current timeout value of the 6-Axis Arm.
value = arm.get_timeout()
is_connected()#
is_connected()
方法检查 CTE Arm 是否已连接。这是一个兼容性函数,其返回值与 installed()
函数相同。
这是一种非等待方法,允许下一个方法无延迟运行。
返回: 如果 Arm 通过相关智能端口连接到大脑,则返回 True
。否则,返回 False
。
installed()#
installed()
方法检查设备连接。
这是一种非等待方法,允许下一个方法无延迟运行。
返回: 如果设备已连接,则返回 True
。如果未连接,则返回 False
。
timestamp()#
timestamp()
方法返回从 Arm 接收到的最后一个状态包的时间戳。
这是一种非等待方法,允许下一个方法无延迟运行。
**返回:**从 Arm 接收的最后一个状态包的时间戳(以毫秒为单位)。