手臂#
初始化arm类#
使用以下构造函数创建 6 轴臂:
arm
构造函数在指定端口创建一个 6 轴 CTE 臂。
范围 |
描述 |
---|---|
|
6 轴臂连接到的有效 智能端口。 |
// Construct a 6-Axis arm "Arm" with the
// arm class.
arm Arm = arm(PORT1);
当引用 arm 类方法时,此 Arm
对象将在整个 API 文档的所有后续示例中使用。
类方法#
移动到()#
moveTo(x, y, z, waitForCompletion)
方法将末端执行器移动到请求的 X、Y 和 Z 绝对位置。
这可以是等待或非等待方法,取决于是否使用了waitForCompletion
参数。
参数 |
描述 |
---|---|
x |
要移动到的 X 坐标(以毫米为单位)。 |
y |
要移动到的 Y 坐标(以毫米为单位)。 |
z |
要移动到的 Z 坐标(以毫米为单位)。 |
等待完成 |
确定命令是否阻止后续命令( |
**返回:**如果手臂已移动到请求的位置,则返回 true
。如果没有,则返回 false
。
// Move the arm to the (200, 0, 100).
Arm.moveTo(200, 0, 100);
moveInc()#
moveInc(x, y, z, waitForCompletion)
方法将末端执行器移动所请求的 X、Y 和 Z 距离。
这可以是等待或非等待方法,取决于是否使用了waitForCompletion
参数。
参数 |
描述 |
---|---|
x |
X 轴上移动的距离(以毫米为单位)。 |
y |
Y 轴上移动的距离(以毫米为单位)。 |
z |
Z 轴移动的距离(以毫米为单位)。 |
等待完成 |
确定命令是否阻止后续命令( |
**返回:**如果手臂已移动到请求的位置,则返回 true
。如果没有,则返回 false
。
// Move the Arm +100 millimeters on the Y axis.
Arm.moveInc(0, 100, 0);
移动末端效应器至()#
moveEndEffectorTo(yaw, roll, pitch, waitForCompletion)
方法将末端执行器移动到请求的绝对偏航、滚转和俯仰方向。
这可以是等待或非等待方法,取决于是否使用了waitForCompletion
参数。
参数 |
描述 |
---|---|
偏航 |
末端执行器应指向的围绕 Z 轴的角度(以度为单位)。 |
卷 |
末端执行器应指向的围绕 X 轴的角度(以度为单位)。 |
沥青 |
末端执行器应指向的围绕 Y 轴的角度(以度为单位)。 |
等待完成 |
确定命令是否阻止后续命令( |
**返回:**如果末端执行器已移动到请求的方向,则返回“true”。如果没有,则返回“false”。
// Orient the end effector to point towards
// 90 degrees around the X axis.
Arm.moveEndEffectorTo(0, 90, 0);
移动末端效应器公司()#
moveEndEffectorInc(yaw, roll, pitch, waitForCompletion)
方法将末端执行器移动到请求的相对偏航、滚转和俯仰方向。
这可以是等待或非等待方法,取决于是否使用了waitForCompletion
参数。
参数 |
描述 |
---|---|
偏航 |
末端执行器围绕 Z 轴应改变的角度(以度为单位)。 |
卷 |
末端执行器围绕 X 轴应改变的角度(以度为单位)。 |
沥青 |
末端执行器围绕 Y 轴应改变的角度(以度为单位)。 |
等待完成 |
确定命令是否阻止后续命令( |
**返回:**如果末端执行器已移动到请求的方向,则返回“true”。如果没有,则返回“false”。
// Orient the end effector -50 degrees on the Y axis.
Arm.moveEndEffectorInc(0, 0, -50);
设置速度()#
setSpeed(speed)
方法设置移动的速度。
参数 |
描述 |
---|---|
速度 |
手臂移动的速度。 |
**返回:**无。
设置终端效应器类型()#
setEndEffectorType(type)
方法将末端执行器类型设置为磁铁或笔。
参数 |
描述 |
---|---|
类型 |
有效的 endEffectorType。 |
**返回:**如果设置了请求的类型,则返回 true
。如果未设置,则返回 false
。
// Set the end effector to the Magnet Pickup Tool.
Arm.setEndEffectorType(magnet);
设置末端效应器磁铁()#
setEndEffectorMagnet(state)
方法将末端执行器磁铁设置为启用或禁用。
参数 |
描述 |
---|---|
状态 |
|
**返回:**无。
// Enable the Magnet Pickup Tool.
Arm.setEndEffectorMagnet(true);
设置笔偏移量()#
setPenOffset(zOffset)
方法设置笔端执行器 Z 轴偏移。
参数 |
描述 |
---|---|
z偏移 |
新的偏移量(以毫米为单位)。正 z 值表示向上。 |
**返回:**无。
设置控制停止()#
setControlStop(state)
方法禁用手臂并将关节马达置于制动模式。
参数 |
描述 |
---|---|
状态 |
“true”表示禁用进一步的线性或关节移动,或“false”表示禁用进一步的线性或关节移动。 |
**返回:**无。
控制停止()#
controlStopped(callback)
方法注册一个函数,当启用手臂控制停止时调用。
参数 |
描述 |
---|---|
打回来 |
当手臂控制停止时调用的函数 |
**返回:**无。
// Define the whenControlStopped function with a void
// return type, showing it doesn't return a value.
void whenControlStopped() {
// The brain will print that the arm has been control stopped
// on the Brain's screen.
Brain.Screen.print("The arm has been control stopped");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run whenControlStopped when the the arm is control stopped.
Arm.controlStopped(whenControlStopped);
}
canArmReachTo()#
canArmReachTo(x, y, z)
方法检查末端执行器是否可以移动到请求的 X、Y 和 Z 绝对位置。
参数 |
描述 |
---|---|
x |
要移动到的 X 坐标(以毫米为单位)。 |
y |
要移动到的 Y 坐标(以毫米为单位)。 |
z |
要移动到的 Z 坐标(以毫米为单位)。 |
**返回:**如果手臂可以移动到请求的位置,则返回 true
。如果不能,则返回 false
。
// Check if the arm can move to the (100, -20, 50).
if (Arm.canArmReachTo(100, -20, 50)){
// Move the arm to (100, -20, 50).
Arm.moveTo(100, -20, 50);
}
canArmReachInc()#
Arm.canArmReachInc(x, y, z)
方法检查末端执行器是否可以移动到请求的 X、Y 和 Z 相对位置。
参数 |
描述 |
---|---|
x |
X 轴上移动的距离(以毫米为单位)。 |
y |
Y 轴上移动的距离(以毫米为单位)。 |
z |
Z 轴移动的距离(以毫米为单位)。 |
**返回:**如果手臂可以移动到请求的位置,则返回 true
。如果不能,则返回 false
。
// Check if the arm can increment by 100 mm along the x-axis.
if (Arm.canArmReachInc(100, 0, 0)){
// Increment the arm by 100 mm along the X axis.
Arm.moveInc(100, 0, 0);
}
canEndEffectorReachTo()#
canEndEffectorReachTo(yaw, roll, pitch)
方法检查末端执行器是否可以移动到请求的绝对偏航、滚转和俯仰方向。
参数 |
描述 |
---|---|
偏航 |
末端执行器应指向的围绕 Z 轴的角度(以度为单位)。 |
卷 |
末端执行器应指向的围绕 X 轴的角度(以度为单位)。 |
沥青 |
末端执行器应指向的围绕 Y 轴的角度(以度为单位)。 |
**返回:**如果末端执行器可以移动到请求的方向,则返回“true”。如果不能,则返回“false”。
// Check if the arm can orient 25 degrees around the Z axis.
if (Arm.canEndEffectorReachTo(25, 0, 0)){
// Orient to 25 degrees around the Z axis.
Arm.moveEndEffectorTo(25, 0, 0);
}
canEndEffectorReachInc()#
canEndEffectorReachInc(yaw, roll, pitch)
方法检查末端执行器是否可以移动到请求的相对偏航、滚转和俯仰方向。
参数 |
描述 |
---|---|
偏航 |
末端执行器围绕 Z 轴移动的角度(以度为单位)。 |
卷 |
这是一个可选参数。末端执行器绕 X 轴移动的角度(以度为单位)。 |
沥青 |
这是一个可选参数。末端执行器绕 Y 轴移动的角度(以度为单位)。 |
**返回:**如果末端执行器可以移动到请求的方向,则返回“true”。如果不能,则返回“false”。
// Check If the arm can increment its orientation
// by 10 degrees on the X axis.
if (Arm.canEndEffectorReachInc(0, 10, 0)){
// Move +10 degrees around the X axis.
Arm.moveEndEffectorInc(0, 10, 0);
}
完成()#
isDone()
方法返回手臂运动的状态。
**返回:**如果手臂当前正在进行运动,则返回“true”。如果不是,则返回“false”。
// Move Arm to (-100, 200, 100) and let subsequent methods execute.
Arm.moveTo(-100, 200, 100, false);
// Keep repeating the methods until the Arm is done moving.
while (!Arm.isDone()) {
// Print the Arm's current Y coordinate on the Brain every .25 seconds.
Brain.Screen.print(Arm.getY());
Brain.Screen.newLine();
wait(0.25, seconds);
}
获取X()#
getX()
方法返回末端执行器的 X 位置。
**返回:**一个浮点数,以“mm”为单位表示末端执行器的 X 位置。
// Print the current X position of the Arm in degrees.
Brain.Screen.print(Arm.getX());
获取Y()#
getY()
方法返回末端执行器的 Y 位置。
**返回:**一个浮点数,以“mm”为单位表示末端执行器的 Y 位置。
// Print the current Y position of the Arm in degrees.
Brain.Screen.print(Arm.getY());
获取Z()#
getZ()
方法请求末端执行器的 Z 位置。
**返回:**一个浮点数,以“mm”为单位表示末端执行器的 Z 位置。
// Print the current Z position of the Arm in degrees.
Brain.Screen.print(Arm.getZ());
获取偏航角()#
getYaw()
方法请求末端执行器的当前偏航。
**返回:**一个浮点数,表示末端执行器当前偏航角度(以度为单位)。
// Print the current yaw of the Arm in degrees.
Brain.Screen.print(Arm.getYaw());
获取Roll()#
getRoll()
方法请求末端执行器的当前滚动。
**返回:**一个浮点数,表示末端执行器当前滚动的角度(以度为单位)。
// Print the current roll of the Arm in degrees.
Brain.Screen.print(Arm.getRoll());
获取音高()#
getPitch()
方法请求末端执行器的当前音高。
**返回:**一个浮点数,表示末端执行器当前倾斜度(以度为单位)。
// Print the current pitch of the Arm in degrees.
Brain.Screen.print(Arm.getPitch());
设置超时()#
setTimeout(timeout, units)
方法设置移动 Arm 时使用的超时值。
参数 |
描述 |
---|---|
暂停 |
新的超时值。 |
单位 |
有效的 timeUnit。 |
**返回:**无。
已连接()#
isConnected()
方法检查 CTE 臂是否已连接。这是一个兼容性函数,其返回值与 installed()
函数相同。
**返回:**如果手臂通过相关的智能端口连接到大脑,则返回“true”。如果不是,则返回“false”。
时间戳()#
timestamp()
方法从 Arm 请求最后接收到的状态包的时间戳。
**返回:**最后一个状态包的时间戳,以毫秒为单位的无符号 32 位整数。
安装()#
如果设备已连接,则 installed()
方法返回。
**返回:**如果设备已连接,则返回 true
。如果未连接,则返回 false
。