CTE手臂#
介绍#
The arm class provides control for the 6-Axis CTE Arm, allowing precise positioning and movement of the 6-Axis Robotic Arm in 3D space. This class supports both absolute and relative positioning, end effector control, and various sensor functions for monitoring arm status and capabilities.
类构造函数#
arm(
int32_t index );
类析构函数#
Destroys the arm object and releases associated resources.
~arm();
参数#
范围 |
类型 |
描述 |
|---|---|---|
|
|
A valid Smart Port that the 6-Axis Arm is connected to, written as |
例子#
// Create the arm instance in Port 1
arm Arm = arm(PORT1);
成员功能#
The arm class includes the following member functions:
moveTo— Moves the end effector to the requested x, y, and z coordinates.moveInc— Moves the end effector by the requested x, y, and z distances relative to its current position.moveEndEffectorTo— Moves the end effector to the requested absolute yaw, roll, and pitch orientation.moveEndEffectorInc— Moves the end effector to the requested relative yaw, roll, and pitch orientation.setEndEffectorType— Sets the type of end effector attached to the 6-Axis Arm.setEndEffectorMagnet— Sets the end effector magnet to enabled or disabled.setPenOffset— Sets the pen end effector z-axis offset.setControlStop— Disables the 6-Axis Arm and places joint motors in brake mode.controlStopped— Registers a function to be called when the 6-Axis Arm control stop is enabled.isCrashed— Returns if the 6-Axis Arm has crashed while moving.crashed— Registers a function to be called when the 6-Axis Arm has crashed while moving.canArmReachTo— Returns if the end effector can move to the requested x, y, and z coordinates.canArmReachInc— Returns if the end effector can move for a distance along the x, y, and z axes.canEndEffectorReachTo— Returns if the end effector can move to the requested absolute yaw, roll, and pitch orientation.canEndEffectorReachInc— Returns if the end effector can move for a distance along the yaw, pitch, or roll orientations.isDone– Returns the status of 6-Axis Arm movement.getX– Returns the X position of the end effector.getY– Returns the y-position of the end effector.getZ– Returns the z-position of the end effector.getYaw– Returns the current yaw of the end effector.getRoll– Returns the current roll of the end effector.getPitch– Returns the current pitch of the end effector.setTimeout– Sets the timeout value used when moving the Arm.isConnected– Returns if the 6-Axis Arm is connected.timestamp– Returns the timestamp of the last received status packet from the Arm.installed– Returns if the device is connected.
moveTo#
将末端执行器移动到指定的 x、y 和 z 坐标。
Available Functionsbool moveTo(
double x,
double y,
double z,
bool waitForCompletion = true );
范围 |
类型 |
描述 |
|---|---|---|
|
|
要移动到的 X 坐标,单位为毫米。 |
|
|
要移动到的 Y 坐标,单位为毫米。 |
|
|
要移动到的 Z 坐标,单位为毫米。 |
|
|
|
返回一个布尔值,指示 6 轴机械臂是否到达目标位置。
trueif the 6-Axis Arm reached the target position.falseif the 6-Axis Arm did not reach the target position or ifwaitForCompletionparameter is set tofalse.
// Move the arm to the (200, 0, 100)
Arm.moveTo(200, 0, 100);
moveInc#
使末端执行器相对于其当前位置移动所请求的 x、y 和 z 距离。
Available Functionsbool moveInc(
double x,
double y,
double z,
bool waitForCompletion = true );
范围 |
类型 |
描述 |
|---|---|---|
|
|
X 轴方向的移动距离,以毫米为单位。 |
|
|
Y轴方向需要移动的距离,以毫米为单位。 |
|
|
Z 轴方向的移动距离,以毫米为单位。 |
|
|
|
返回一个布尔值,指示 6 轴机械臂是否到达目标位置。
trueif the 6-Axis Arm reached the target position.falseif the 6-Axis Arm did not reach the target position or ifwaitForCompletionparameter is set tofalse.
// Move the Arm +100 millimeters on the Y axis
Arm.moveInc(0, 100, 0);
moveEndEffectorTo#
将末端执行器移动到所要求的绝对偏航角、横滚角和俯仰角。
Available Functionsbool moveEndEffectorTo(
double yaw,
double roll = 0,
double pitch = 0,
bool waitForCompletion = true);
范围 |
类型 |
描述 |
|---|---|---|
|
|
末端执行器应指向的绕 Z 轴的角度,以度为单位。 |
|
|
末端执行器绕 X 轴的指向角度,以度为单位。默认值为 0。 |
|
|
末端执行器绕 Y 轴的指向角度,单位为度。默认值为 0。 |
|
|
|
返回一个布尔值,指示末端执行器是否达到目标方向。
trueif the end effector reached the target orientation.falseif the end effector did not reach the target orientation or ifwaitForCompletionparameter is set tofalse.
// Orient the end effector to point towards
// 90 degrees around the X axis
Arm.moveEndEffectorTo(0, 90, 0);
moveEndEffectorInc#
将末端执行器移动到所要求的相对偏航角、横滚角和俯仰角。
Available Functionsbool moveEndEffectorInc(
double yaw,
double roll = 0,
double pitch = 0,
bool waitForCompletion = true );
范围 |
类型 |
描述 |
|---|---|---|
|
|
末端执行器绕 Z 轴改变的角度,以度为单位。 |
|
|
末端执行器绕 X 轴改变的角度,以度为单位。默认值为 0。 |
|
|
末端执行器绕 Y 轴旋转的角度,以度为单位。默认值为 0。 |
|
|
|
返回一个布尔值,指示末端执行器是否达到目标方向。
trueif the end effector reached the target orientation.falseif the end effector did not reach the target orientation or ifwaitForCompletionparameter is set tofalse.
// Orient the end effector -50 degrees on the Y axis
Arm.moveEndEffectorInc(0, 0, -50);
setSpeed#
设置六轴机械臂运动速度。
Available Functionsvoid setSpeed(
uint32_t speed );
范围 |
类型 |
描述 |
|---|---|---|
|
|
6轴机械臂的移动速度(单位:毫米/秒)。 |
此函数不返回值。
setEndEffectorType#
设置末端执行器类型为磁铁或笔。
Available Functionsbool setEndEffectorType(
endEffectorType type,
bool waitForCompletion = true);
范围 |
类型 |
描述 |
|---|---|---|
|
|
An end effector type:
|
|
|
|
返回一个布尔值,指示是否已设置请求的类型。
trueif the requested type was set.falseif the requested type was not set or ifwaitForCompletionparameter is set tofalse.
// Set the end effector to the Magnet Pickup Tool.
Arm.setEndEffectorType(magnet);
setEndEffectorMagnet#
设置末端执行器磁铁的启用或禁用状态。
Available Functionsvoid setEndEffectorMagnet(
bool enabled );
范围 |
类型 |
描述 |
|---|---|---|
|
|
|
此函数不返回值。
Examples// Enable the Magnet Pickup Tool
Arm.setEndEffectorMagnet(true);
setPenOffset#
设置笔端执行器 Z 轴偏移量。
Available Functionsvoid setPenOffset(
double zOffset );
范围 |
类型 |
描述 |
|---|---|---|
|
|
新的偏移量,单位为毫米。正的 z 值表示向上。 |
此函数不返回值。
setControlStop#
禁用 6 轴机械臂并将关节电机置于制动模式。
Available Functionsvoid setControlStop(
bool state = true);
范围 |
类型 |
描述 |
|---|---|---|
|
|
|
此函数不返回值。
controlStopped#
注册一个函数,当启用 6 轴机械臂控制停止功能时,该函数将被调用。
Available Functionsvoid controlStopped(
void (* callback)(void) );
范围 |
类型 |
描述 |
|---|---|---|
|
|
当 6 轴机械臂停止控制时将调用的函数。 |
此函数不返回值。
Examples ExamplesDefine the callback function (outside of
int main())// Called when the 6-Axis Arm is control stopped void onControlStopped() { Brain.Screen.print("Arm control stopped"); }Register the callback inside
int main()/* vexcodeInit() is only required when using VEXcode. Remove vexcodeInit() if compiling in VS Code. */ int main() { vexcodeInit(); Arm.controlStopped(onControlStopped); }
isCrashed#
返回 6 轴机械臂在移动过程中发生碰撞的情况。
**注意:**当检测到碰撞时,六轴机械臂的电机将停止所有运动,机械臂会暂时失去动力。这是为了减少电机负荷,保护电机免受意外损坏。
Available Functionsbool isCrashed();
此函数不接受任何参数。
Return ValuesReturns true if the 6-Axis Arm has crashed while moving, false if it has not.
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Quickly move to a new location
Arm10.setSpeed(100);
Arm10.moveTo(-40, 250, 40, false);
// While moving check for a crash
while (true) {
if (Arm10.isCrashed()) {
// Indicate a crash with the Signal Tower and Brain screen
Brain.Screen.print("Crash Detected");
SignalTower6.setColor(signaltower::green, signaltower::off);
SignalTower6.setColor(signaltower::red, signaltower::on);
break;
}
}
}
crashed#
注册一个函数,当 6 轴机械臂在移动过程中发生碰撞时,该函数将被调用。
**注意:**当检测到碰撞时,六轴机械臂的电机将停止所有运动,机械臂会暂时失去动力。这是为了减少电机负荷,保护电机免受意外损坏。
Available Functionsvoid crashed(
void (* callback)(void) );
范围 |
类型 |
描述 |
|---|---|---|
|
|
当 6 轴机械臂在移动过程中发生碰撞时,将调用此函数。 |
此函数不返回值。
Examples ExamplesDefine the callback function (outside of
int main())// Called when the 6-Axis Arm crashes while moving void onArmCrashed() { Brain.Screen.print("Crash detected"); SignalTower6.setColor(signaltower::green, signaltower::off); SignalTower6.setColor(signaltower::red, signaltower::on); }Register the callback inside
int main()/* vexcodeInit() is only required when using VEXcode. Remove vexcodeInit() if compiling in VS Code. */ int main() { vexcodeInit(); Arm.crashed(onArmCrashed); }
canArmReachTo#
返回末端执行器是否可以移动到请求的 x、y 和 z 坐标。
Available Functionsbool canArmReachTo( double x, double y, double z );
范围 |
类型 |
描述 |
|---|---|---|
|
|
要移动到的 X 坐标,单位为毫米。 |
|
|
要移动到的 Y 坐标,单位为毫米。 |
|
|
要移动到的 Z 坐标,单位为毫米。 |
Returns true if the 6-Axis 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#
返回末端执行器能否沿 x、y 和 z 轴移动一定距离。
Available Functionsbool canArmReachInc(
double x,
double y,
double z );
范围 |
类型 |
描述 |
|---|---|---|
|
|
X 轴方向的移动距离,以毫米为单位。 |
|
|
Y轴方向需要移动的距离,以毫米为单位。 |
|
|
Z 轴方向的移动距离,以毫米为单位。 |
返回一个布尔值,指示 6 轴机械臂是否可以移动到请求的位置。
trueif the 6-Axis Arm can move to the requested position.falseif the 6-Axis Arm cannot move to the requested position.
// 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#
返回末端执行器能否移动到所请求的绝对偏航角、横滚角和俯仰角。
Available Functionsbool canEndEffectorReachTo(
double yaw,
double roll = 0,
double pitch = 0 );
范围 |
类型 |
描述 |
|---|---|---|
|
|
末端执行器应指向的绕 Z 轴的角度,以度为单位。 |
|
|
末端执行器绕 X 轴的指向角度,以度为单位。默认值为 0。 |
|
|
末端执行器绕 Y 轴的指向角度,单位为度。默认值为 0。 |
返回一个布尔值,指示末端执行器是否可以移动到请求的方向。
trueif the end effector can move to the requested orientation.falseif the end effector cannot move to the requested orientation.
// 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#
返回末端执行器能否沿偏航、俯仰或横滚方向移动一段距离。
Available Functionsbool canEndEffectorReachInc(
double yaw,
double roll = 0,
double pitch = 0 );
范围 |
类型 |
描述 |
|---|---|---|
|
|
末端执行器绕 z 轴移动的角度,以度为单位。 |
|
|
末端执行器绕 x 轴移动的角度,以度为单位。默认值为 0。 |
|
|
末端执行器绕 y 轴旋转的角度,单位为度。默认值为 0。 |
返回一个布尔值,指示末端执行器是否可以移动到请求的方向。
trueif the end effector can move to the requested orientation.falseif the end effector cannot move to the requested orientation.
// 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#
返回 6 轴机械臂运动状态。
Available Functionsbool isDone();
此函数没有参数。
Return Values返回一个布尔值,指示 6 轴机械臂是否已完成其运动。
trueif the 6-Axis Arm has completed its movement.falseif the 6-Axis Arm is still moving.
// 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#
返回末端执行器的 X 坐标。
Available Functionsfloat getX();
此函数没有参数。
Return ValuesReturns a float representing the X position of the end effector in millimeters.
// Print the current x-position of the arm in degrees
Brain.Screen.print(Arm.getX());
getY#
返回末端执行器的 y 坐标。
Available Functionsfloat getY();
此函数没有参数。
Return ValuesReturns a float representing the y-position of the end effector in millimeters.
// Print the current y-position of the Arm in degrees
Brain.Screen.print(Arm.getY());
getZ#
返回末端执行器的 z 轴位置。
Available Functionsfloat getZ();
此函数没有参数。
Return ValuesReturns a float representing the z-position of the end effector in millimeters.
// Print the current z-position of the Arm in degrees
Brain.Screen.print(Arm.getZ());
getYaw#
返回末端执行器的当前偏航角。
Available Functionsfloat getYaw();
此函数没有参数。
Return ValuesReturns a float representing the current yaw of the end effector in degrees.
// Print the current yaw of the Arm in degrees
Brain.Screen.print(Arm.getYaw());
getRoll#
返回末端执行器的当前滚动方向。
Available Functionsfloat getRoll();
此函数没有参数。
Return ValuesReturns a float representing the current roll of the end effector in degrees.
// Print the current roll of the Arm in degrees
Brain.Screen.print(Arm.getRoll());
getPitch#
返回末端执行器的当前俯仰角。
Available Functionsfloat getPitch();
此函数没有参数。
Return ValuesReturns a float representing the current pitch of the end effector in degrees.
// Print the current pitch of the Arm in degrees
Brain.Screen.print(Arm.getPitch());
setTimeout#
设置移动机械臂时使用的超时值。
Available Functionsvoid setTimeout(
int32_t timeout,
timeUnits units );
范围 |
类型 |
描述 |
|---|---|---|
|
|
新的超时值。 |
|
|
The unit that represents the time:
|
此函数不返回值。
isConnected#
返回六轴机械臂是否已连接。这是一个兼容性函数,其返回值与 installed() 函数相同。
Available Functionsbool isConnected();
此函数没有参数。
Return Values返回一个布尔值,指示 6 轴机械臂是否通过关联的智能端口连接到大脑。
trueif the 6-Axis Arm is connected to the brain on the associated smartport.falseif the 6-Axis Arm is not connected to the brain on the associated smartport.
timestamp#
返回从 Arm 接收到的最后一个状态数据包的时间戳。
Available Functionsuint32_t timestamp();
此函数没有参数。
Return ValuesReturns the timestamp of the last status packet as a uint32_t in milliseconds.
installed#
返回设备已连接的状态。
Available Functionsbool installed();
此函数没有参数。
Return Values返回一个布尔值,指示设备是否已连接。
trueif the device is connected.falseif the device is not connected.