手臂#
初始化arm类#
使用以下构造函数创建 6 轴臂:
The arm
constructor creates a 6-Axis CTE Arm in the specified Port.
范围 |
描述 |
---|---|
|
6 轴臂连接到的有效 智能端口。 |
// Construct a 6-Axis arm "Arm" with the
// arm class.
arm Arm = arm(PORT1);
This Arm
object will be used in all subsequent examples throughout this API documentation when referring to arm class methods.
类方法#
moveTo()#
The moveTo(x, y, z, waitForCompletion)
method moves the end effector to the requested X, Y, and Z absolute position.
This can be a waiting or non-waiting method depending on if the waitForCompletion
parameter is used.
参数 |
描述 |
---|---|
x |
要移动到的 X 坐标(以毫米为单位)。 |
y |
要移动到的 Y 坐标(以毫米为单位)。 |
z |
要移动到的 Z 坐标(以毫米为单位)。 |
等待完成 |
Determines whether the command will block subsequent commands ( |
Returns: true
if the arm has moved to the requested position. false
if it did not.
// Move the arm to the (200, 0, 100).
Arm.moveTo(200, 0, 100);
moveInc()#
The moveInc(x, y, z, waitForCompletion)
method moves the end effector by the requested X, Y, and Z distances.
This can be a waiting or non-waiting method depending on if the waitForCompletion
parameter is used.
参数 |
描述 |
---|---|
x |
X 轴上移动的距离(以毫米为单位)。 |
y |
Y 轴上移动的距离(以毫米为单位)。 |
z |
Z 轴移动的距离(以毫米为单位)。 |
等待完成 |
Determines whether the command will block subsequent commands ( |
Returns: true
if the arm has moved to the requested position. false
if it did not.
// Move the Arm +100 millimeters on the Y axis.
Arm.moveInc(0, 100, 0);
moveEndEffectorTo()#
The moveEndEffectorTo(yaw, roll, pitch, waitForCompletion)
method moves the end effector to the requested absolute yaw, roll, and pitch orientation.
This can be a waiting or non-waiting method depending on if the waitForCompletion
parameter is used.
参数 |
描述 |
---|---|
偏航 |
末端执行器应指向的围绕 Z 轴的角度(以度为单位)。 |
卷 |
末端执行器应指向的围绕 X 轴的角度(以度为单位)。 |
沥青 |
末端执行器应指向的围绕 Y 轴的角度(以度为单位)。 |
等待完成 |
Determines whether the command will block subsequent commands ( |
Returns: true
if the end effector has moved to the requested orientation. false
if it has not.
// Orient the end effector to point towards
// 90 degrees around the X axis.
Arm.moveEndEffectorTo(0, 90, 0);
moveEndEffectorInc()#
The moveEndEffectorInc(yaw, roll, pitch, waitForCompletion)
method moves the end effector to the requested relative yaw, roll, and pitch orientation.
This can be a waiting or non-waiting method depending on if the waitForCompletion
parameter is used.
参数 |
描述 |
---|---|
偏航 |
末端执行器围绕 Z 轴应改变的角度(以度为单位)。 |
卷 |
末端执行器围绕 X 轴应改变的角度(以度为单位)。 |
沥青 |
末端执行器围绕 Y 轴应改变的角度(以度为单位)。 |
等待完成 |
Determines whether the command will block subsequent commands ( |
Returns: true
if the end effector has moved to the requested orientation. false
if it has not.
// Orient the end effector -50 degrees on the Y axis.
Arm.moveEndEffectorInc(0, 0, -50);
setSpeed()#
The setSpeed(speed)
method sets the speed for moves.
参数 |
描述 |
---|---|
速度 |
手臂移动的速度。 |
**返回:**无。
setEndEffectorType()#
The setEndEffectorType(type)
method sets the end effector type to magnet or pen.
参数 |
描述 |
---|---|
类型 |
有效的 endEffectorType。 |
Returns: true
if the requested type was set. false
if it was not.
// Set the end effector to the Magnet Pickup Tool.
Arm.setEndEffectorType(magnet);
setEndEffectorMagnet()#
The setEndEffectorMagnet(state)
method sets the end effector magnet to enabled or disabled.
参数 |
描述 |
---|---|
状态 |
|
**返回:**无。
// Enable the Magnet Pickup Tool.
Arm.setEndEffectorMagnet(true);
setPenOffset()#
The setPenOffset(zOffset)
method sets the pen end effector Z axis offset.
参数 |
描述 |
---|---|
z偏移 |
The new offset in |
**返回:**无。
setControlStop()#
The setControlStop(state)
method disables the arm and places joint motors in brake mode.
参数 |
描述 |
---|---|
状态 |
|
**返回:**无。
controlStopped()#
The controlStopped(callback)
method registers a function to be called when the arm control stop is enabled.
参数 |
描述 |
---|---|
打回来 |
当手臂控制停止时调用的函数 |
**返回:**无。
// 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()#
The canArmReachTo(x, y, z)
method checks if the end effector can move to the requested X, Y, and Z absolute position.
参数 |
描述 |
---|---|
x |
要移动到的 X 坐标(以毫米为单位)。 |
y |
要移动到的 Y 坐标(以毫米为单位)。 |
z |
要移动到的 Z 坐标(以毫米为单位)。 |
Returns: true
if the arm can move to the requested position. false
if it cannot.
// 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()#
The Arm.canArmReachInc(x, y, z)
method checks if the end effector can move to the requested X, Y, and Z relative position.
参数 |
描述 |
---|---|
x |
X 轴上移动的距离(以毫米为单位)。 |
y |
Y 轴上移动的距离(以毫米为单位)。 |
z |
Z 轴移动的距离(以毫米为单位)。 |
Returns: true
if the arm can move to the requested position. false
if it cannot.
// 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()#
The canEndEffectorReachTo(yaw, roll, pitch)
method checks if the end effector can move to the requested absolute yaw, roll, and pitch orientation.
参数 |
描述 |
---|---|
偏航 |
末端执行器应指向的围绕 Z 轴的角度(以度为单位)。 |
卷 |
末端执行器应指向的围绕 X 轴的角度(以度为单位)。 |
沥青 |
末端执行器应指向的围绕 Y 轴的角度(以度为单位)。 |
Returns: true
if the end effector can move to the requested orientation. false
if it cannot.
// 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()#
The canEndEffectorReachInc(yaw, roll, pitch)
method checks if the end effector can move to the requested relative yaw, roll, and pitch orientation.
参数 |
描述 |
---|---|
偏航 |
末端执行器围绕 Z 轴移动的角度(以度为单位)。 |
卷 |
这是一个可选参数。末端执行器绕 X 轴移动的角度(以度为单位)。 |
沥青 |
这是一个可选参数。末端执行器绕 Y 轴移动的角度(以度为单位)。 |
Returns: true
if the end effector can move to the requested orientation. false
if it cannot.
// 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()#
The isDone()
method returns the status of arm movement.
Returns: true
if the arm is currently performing a movement. false
if it is not.
// 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);
}
getX()#
The getX()
method returns the X position of the end effector.
Returns: A float representing the X position of the end effector in mm
.
// Print the current X position of the Arm in degrees.
Brain.Screen.print(Arm.getX());
getY()#
The getY()
method returns the Y position of the end effector.
Returns: A float representing the Y position of the end effector in mm
.
// Print the current Y position of the Arm in degrees.
Brain.Screen.print(Arm.getY());
getZ()#
The getZ()
method requests the Z position of the end effector.
Returns: A float representing the Z position of the end effector in mm
.
// Print the current Z position of the Arm in degrees.
Brain.Screen.print(Arm.getZ());
getYaw()#
The getYaw()
method requests the current yaw of the end effector.
**返回:**一个浮点数,表示末端执行器当前偏航角度(以度为单位)。
// Print the current yaw of the Arm in degrees.
Brain.Screen.print(Arm.getYaw());
getRoll()#
The getRoll()
method requests the current roll of the end effector.
**返回:**一个浮点数,表示末端执行器当前滚动的角度(以度为单位)。
// Print the current roll of the Arm in degrees.
Brain.Screen.print(Arm.getRoll());
getPitch()#
The getPitch()
method requests the current pitch of the end effector.
**返回:**一个浮点数,表示末端执行器当前倾斜度(以度为单位)。
// Print the current pitch of the Arm in degrees.
Brain.Screen.print(Arm.getPitch());
setTimeout()#
The setTimeout(timeout, units)
method sets the timeout value used when moving the Arm.
参数 |
描述 |
---|---|
暂停 |
新的超时值。 |
单位 |
有效的 timeUnit。 |
**返回:**无。
isConnected()#
The isConnected()
method checks if the CTE arm is connected. This is a compatibility function that returns the same as the installed()
function.
Returns: true
if the arm is connected to the brain on the associated smartport. false
if it is not.
timestamp()#
The timestamp()
method requests the timestamp of the last received status packet from the Arm.
**返回:**最后一个状态包的时间戳,以毫秒为单位的无符号 32 位整数。
installed()#
The installed()
method returns if the device is connected.
Returns: true
if the device is connected. false
if it is not.