CTE手臂#
介绍#
The arm class provides control for the 6-Axis CTE Arm, allowing precise positioning and movement of the 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 classes includes the following member functions:
moveTo - 将末端执行器移动到请求的 x、y 和 z 坐标。
moveInc - 将末端执行器相对于其当前位置移动请求的 x、y 和 z 距离。
moveEndEffectorTo - 将末端执行器移动到请求的绝对偏航角、横滚角和俯仰角。
moveEndEffectorInc - 将末端执行器移动到请求的相对偏航角、横滚角和俯仰角方向。
setEndEffectorType - 设置连接到机械臂的末端执行器的类型。
setEndEffectorMagnet - 设置末端执行器磁铁是否启用或禁用。
setPenOffset - 设置笔末端执行器的 z 轴偏移量。
setControlStop - 禁用机械臂并将关节电机置于制动模式。
controlStopped - 注册一个在启用臂控制停止时要调用的函数。
canArmReachTo - 返回末端执行器是否可以移动到请求的 x、y 和 z 坐标。
canArmReachInc - 返回末端执行器是否可以沿 x、y 和 z 轴移动一定距离。
canEndEffectorReachTo - 返回末端执行器是否可以移动到请求的绝对偏航角、横滚角和俯仰角方向。
canEndEffectorReachInc - 返回末端执行器是否可以沿偏航、俯仰或横滚方向移动一定距离。
isDone – 返回手臂运动的状态。
getX – 返回末端执行器的 X 坐标。
getY – 返回末端执行器的 y 坐标。
getZ – 返回末端执行器的 z 坐标。
getYaw – 返回末端执行器的当前偏航角。
getRoll – 返回末端执行器的当前滚动角度。
getPitch – 返回末端执行器的当前俯仰角。
setTimeout – 设置移动机械臂时使用的超时值。
isConnected – 返回 CTE 臂是否已连接。
timestamp – 返回从 Arm 接收到的最后一个状态数据包的时间戳。
installed – 返回设备是否已连接。
moveTo#
将末端执行器移动到指定的 x、y 和 z 坐标。
Available Functionsbool moveTo(
double x,
double y,
double z,
bool waitForCompletion = true );
范围 |
类型 |
描述 |
|---|---|---|
|
|
要移动到的 X 坐标,单位为毫米。 |
|
|
要移动到的 Y 坐标,单位为毫米。 |
|
|
要移动到的 Z 坐标,单位为毫米。 |
|
|
|
返回一个布尔值,指示机械臂是否到达目标位置。
trueif the arm reached the target position.falseif the 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 轴方向的移动距离,以毫米为单位。 |
|
|
|
返回一个布尔值,指示机械臂是否到达目标位置。
trueif the arm reached the target position.falseif the 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 );
范围 |
类型 |
描述 |
|---|---|---|
|
|
机械臂应移动的速度,单位为毫米/秒。 |
此函数不返回值。
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#
禁用机械臂并将关节电机置于制动模式。
Available Functionsvoid setControlStop(
bool state = true);
范围 |
类型 |
描述 |
|---|---|---|
|
|
|
此函数不返回值。
controlStopped#
注册一个在启用机械臂控制停止功能时要调用的函数。
Available Functionsvoid controlStopped(
void (* callback)(void) );
范围 |
类型 |
描述 |
|---|---|---|
|
|
当机械臂停止控制时将调用的函数。 |
此函数不返回值。
Examples// 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");
}
// Run whenControlStopped when the the arm is control stopped.
Arm.controlStopped(whenControlStopped);
canArmReachTo#
返回末端执行器是否可以移动到请求的 x、y 和 z 坐标。
Available Functionsbool canArmReachTo( double x, double y, double z );
范围 |
类型 |
描述 |
|---|---|---|
|
|
要移动到的 X 坐标,单位为毫米。 |
|
|
要移动到的 Y 坐标,单位为毫米。 |
|
|
要移动到的 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#
返回末端执行器能否沿 x、y 和 z 轴移动一定距离。
Available Functionsbool canArmReachInc(
double x,
double y,
double z );
范围 |
类型 |
描述 |
|---|---|---|
|
|
X 轴方向的移动距离,以毫米为单位。 |
|
|
Y轴方向需要移动的距离,以毫米为单位。 |
|
|
Z 轴方向的移动距离,以毫米为单位。 |
返回一个布尔值,指示机械臂是否可以移动到请求的位置。
trueif the arm can move to the requested position.falseif the 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#
返回手臂运动状态。
Available Functionsbool isDone();
此函数没有参数。
Return Values返回一个布尔值,指示机械臂是否已完成其运动。
trueif the arm has completed its movement.falseif the 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#
返回 CTE 臂是否已连接。这是一个兼容性函数,其返回值与 installed() 函数相同。
Available Functionsbool isConnected();
此函数没有参数。
Return Values返回一个布尔值,指示机械臂是否通过关联的智能端口连接到大脑。
trueif the arm is connected to the brain on the associated smartport.falseif the 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.