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();

参数#

范围

类型

描述

index

int32_t

A valid Smart Port that the 6-Axis Arm is connected to, written as PORTx, where x is the port number (for example, PORT1).

例子#

// 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 Functions
bool moveTo( 
  double x, 
  double y, 
  double z, 
  bool   waitForCompletion = true );

Parameters

范围

类型

描述

x

double

要移动到的 X 坐标,单位为毫米。

y

double

要移动到的 Y 坐标,单位为毫米。

z

double

要移动到的 Z 坐标,单位为毫米。

waitForCompletion

bool

  • true (default) — The project waits until the function finishes before executing the next line of code.
  • false — The project starts the action and moves on to the next line of code right away, without waiting for the function to finish.

Return Values

返回一个布尔值,指示机械臂是否到达目标位置。

  • true if the arm reached the target position.

  • false if the arm did not reach the target position or if waitForCompletion parameter is set to false.

Examples
// Move the arm to the (200, 0, 100)
Arm.moveTo(200, 0, 100);

moveInc#

使末端执行器相对于其当前位置移动所请求的 x、y 和 z 距离。

Available Functions
bool moveInc( 
  double x, 
  double y, 
  double z, 
  bool   waitForCompletion = true );

Parameters

范围

类型

描述

x

double

X 轴方向的移动距离,以毫米为单位。

y

double

Y轴方向需要移动的距离,以毫米为单位。

z

double

Z 轴方向的移动距离,以毫米为单位。

waitForCompletion

bool

  • true (default) — The project waits until the function finishes before executing the next line of code.
  • false — The project starts the action and moves on to the next line of code right away, without waiting for the function to finish.

Return Values

返回一个布尔值,指示机械臂是否到达目标位置。

  • true if the arm reached the target position.

  • false if the arm did not reach the target position or if waitForCompletion parameter is set to false.

Examples
// Move the Arm +100 millimeters on the Y axis
Arm.moveInc(0, 100, 0);

moveEndEffectorTo#

将末端执行器移动到所要求的绝对偏航角、横滚角和俯仰角。

Available Functions
bool moveEndEffectorTo( 
  double yaw, 
  double roll = 0, 
  double pitch = 0, 
  bool   waitForCompletion = true);

Parameters

范围

类型

描述

yaw

double

末端执行器应指向的绕 Z 轴的角度,以度为单位。

roll

double

末端执行器绕 X 轴的指向角度,以度为单位。默认值为 0。

pitch

double

末端执行器绕 Y 轴的指向角度,单位为度。默认值为 0。

waitForCompletion

bool

  • true (default) — The project waits until the function finishes before executing the next line of code.
  • false — The project starts the action and moves on to the next line of code right away, without waiting for the function to finish.

Return Values

返回一个布尔值,指示末端执行器是否达到目标方向。

  • true if the end effector reached the target orientation.

  • false if the end effector did not reach the target orientation or if waitForCompletion parameter is set to false.

Examples
// Orient the end effector to point towards 
// 90 degrees around the X axis
Arm.moveEndEffectorTo(0, 90, 0);

moveEndEffectorInc#

将末端执行器移动到所要求的相对偏航角、横滚角和俯仰角。

Available Functions
bool moveEndEffectorInc( 
  double yaw, 
  double roll = 0, 
  double pitch = 0, 
  bool   waitForCompletion = true );

Parameters

范围

类型

描述

yaw

double

末端执行器绕 Z 轴改变的角度,以度为单位。

roll

double

末端执行器绕 X 轴改变的角度,以度为单位。默认值为 0。

pitch

double

末端执行器绕 Y 轴旋转的角度,以度为单位。默认值为 0。

waitForCompletion

bool

  • true (default) — The project waits until the function finishes before executing the next line of code.
  • false — The project starts the action and moves on to the next line of code right away, without waiting for the function to finish.

Return Values

返回一个布尔值,指示末端执行器是否达到目标方向。

  • true if the end effector reached the target orientation.

  • false if the end effector did not reach the target orientation or if waitForCompletion parameter is set to false.

Examples
// Orient the end effector -50 degrees on the Y axis
Arm.moveEndEffectorInc(0, 0, -50);

setSpeed#

设置手臂运动速度。

Available Functions
void setSpeed( 
  uint32_t speed );

Parameters

范围

类型

描述

speed

uint32_t

机械臂应移动的速度,单位为毫米/秒。

Return Values

此函数不返回值。

setEndEffectorType#

设置末端执行器类型为磁铁或笔。

Available Functions
bool setEndEffectorType( 
  endEffectorType type, 
  bool            waitForCompletion = true));

Parameters

范围

类型

描述

type

endEffectorType

An end effector type:

  • magnet
  • pen

waitForCompletion

bool

  • true (default) — The project waits until the function finishes before executing the next line of code.
  • false — The project starts the action and moves on to the next line of code right away, without waiting for the function to finish.

Return Values

返回一个布尔值,指示是否已设置请求的类型。

  • true if the requested type was set.

  • false if the requested type was not set or if waitForCompletion parameter is set to false.

Examples
// Set the end effector to the Magnet Pickup Tool.
Arm.setEndEffectorType(magnet);

setEndEffectorMagnet#

设置末端执行器磁铁的启用或禁用状态。

Available Functions
void setEndEffectorMagnet( 
  bool enabled );

Parameters

范围

类型

描述

enabled

bool

  • true – enable the magnet
  • false – disable the magnet

Return Values

此函数不返回值。

Examples
// Enable the Magnet Pickup Tool
Arm.setEndEffectorMagnet(true);

setPenOffset#

设置笔端执行器 Z 轴偏移量。

Available Functions
void setPenOffset( 
  double zOffset );

Parameters

范围

类型

描述

zOffset

double

新的偏移量,单位为毫米。正的 z 值表示向上。

Return Values

此函数不返回值。

setControlStop#

禁用机械臂并将关节电机置于制动模式。

Available Functions
void setControlStop( 
  bool state = true);

Parameters

范围

类型

描述

state

bool

  • true (default) — Disable further linear or joint moves.
  • false — Enable further linear or joint moves.

Return Values

此函数不返回值。

controlStopped#

注册一个在启用机械臂控制停止功能时要调用的函数。

Available Functions
void controlStopped( 
  void (* callback)(void) );

Parameters

范围

类型

描述

callback

void (*)(void)

当机械臂停止控制时将调用的函数。

Return Values

此函数不返回值。

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 Functions
bool canArmReachTo( double x, double y, double z );

Parameters

范围

类型

描述

x

double

要移动到的 X 坐标,单位为毫米。

y

double

要移动到的 Y 坐标,单位为毫米。

z

double

要移动到的 Z 坐标,单位为毫米。

Return Values

Returns true if the arm can move to the requested position, false if it cannot.

Examples
// 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 Functions
bool canArmReachInc( 
  double x, 
  double y, 
  double z );

Parameters

范围

类型

描述

x

double

X 轴方向的移动距离,以毫米为单位。

y

double

Y轴方向需要移动的距离,以毫米为单位。

z

double

Z 轴方向的移动距离,以毫米为单位。

Return Values

返回一个布尔值,指示机械臂是否可以移动到请求的位置。

  • true if the arm can move to the requested position.

  • false if the arm cannot move to the requested position.

Examples
// 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 Functions
bool canEndEffectorReachTo( 
  double yaw, 
  double roll = 0, 
  double pitch = 0 );

Parameters

范围

类型

描述

yaw

double

末端执行器应指向的绕 Z 轴的角度,以度为单位。

roll

double

末端执行器绕 X 轴的指向角度,以度为单位。默认值为 0。

pitch

double

末端执行器绕 Y 轴的指向角度,单位为度。默认值为 0。

Return Values

返回一个布尔值,指示末端执行器是否可以移动到请求的方向。

  • true if the end effector can move to the requested orientation.

  • false if the end effector cannot move to the requested orientation.

Examples
// 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 Functions
bool canEndEffectorReachInc( 
  double yaw, 
  double roll = 0, 
  double pitch = 0 );

Parameters

范围

类型

描述

yaw

double

末端执行器绕 z 轴移动的角度,以度为单位。

roll

double

末端执行器绕 x 轴移动的角度,以度为单位。默认值为 0。

pitch

double

末端执行器绕 y 轴旋转的角度,单位为度。默认值为 0。

Return Values

返回一个布尔值,指示末端执行器是否可以移动到请求的方向。

  • true if the end effector can move to the requested orientation.

  • false if the end effector cannot move to the requested orientation.

Examples
// 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 Functions
bool isDone();

Parameters

此函数没有参数。

Return Values

返回一个布尔值,指示机械臂是否已完成其运动。

  • true if the arm has completed its movement.

  • false if the arm is still moving.

Examples
// 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 Functions
float getX();

Parameters

此函数没有参数。

Return Values

Returns a float representing the X position of the end effector in millimeters.

Examples
// Print the current x-position of the arm in degrees
Brain.Screen.print(Arm.getX());

getY#

返回末端执行器的 y 坐标。

Available Functions
float getY();

Parameters

此函数没有参数。

Return Values

Returns a float representing the y-position of the end effector in millimeters.

Examples
// Print the current y-position of the Arm in degrees
Brain.Screen.print(Arm.getY());

getZ#

返回末端执行器的 z 轴位置。

Available Functions
float getZ();

Parameters

此函数没有参数。

Return Values

Returns a float representing the z-position of the end effector in millimeters.

Examples
// Print the current z-position of the Arm in degrees
Brain.Screen.print(Arm.getZ());

getYaw#

返回末端执行器的当前偏航角。

Available Functions
float getYaw();

Parameters

此函数没有参数。

Return Values

Returns a float representing the current yaw of the end effector in degrees.

Examples
// Print the current yaw of the Arm in degrees
Brain.Screen.print(Arm.getYaw());

getRoll#

返回末端执行器的当前滚动方向。

Available Functions
float getRoll();

Parameters

此函数没有参数。

Return Values

Returns a float representing the current roll of the end effector in degrees.

Examples
// Print the current roll of the Arm in degrees
Brain.Screen.print(Arm.getRoll());

getPitch#

返回末端执行器的当前俯仰角。

Available Functions
float getPitch();

Parameters

此函数没有参数。

Return Values

Returns a float representing the current pitch of the end effector in degrees.

Examples
// Print the current pitch of the Arm in degrees
Brain.Screen.print(Arm.getPitch());

setTimeout#

设置移动机械臂时使用的超时值。

Available Functions
void setTimeout( 
  int32_t   timeout, 
  timeUnits units );

Parameters

范围

类型

描述

timeout

int32_t

新的超时值。

units

timeUnits

The unit that represents the time:

  • sec
  • – seconds
  • msec
  • – milliseconds

Return Values

此函数不返回值。

isConnected#

返回 CTE 臂是否已连接。这是一个兼容性函数,其返回值与 installed() 函数相同。

Available Functions
bool isConnected();

Parameters

此函数没有参数。

Return Values

返回一个布尔值,指示机械臂是否通过关联的智能端口连接到大脑。

  • true if the arm is connected to the brain on the associated smartport.

  • false if the arm is not connected to the brain on the associated smartport.

timestamp#

返回从 Arm 接收到的最后一个状态数据包的时间戳。

Available Functions
uint32_t timestamp();

Parameters

此函数没有参数。

Return Values

Returns the timestamp of the last status packet as a uint32_t in milliseconds.

installed#

返回设备已连接的状态。

Available Functions
bool installed();

Parameters

此函数没有参数。

Return Values

返回一个布尔值,指示设备是否已连接。

  • true if the device is connected.

  • false if the device is not connected.