Brazo con CTE#

Introducción#

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.

Constructores de clases#

arm( 
  int32_t index );

Instructor de clase#

Destroys the arm object and releases associated resources.

~arm();

Parámetros#

Parámetro

Tipo

Descripción

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).

Ejemplo#

// Create the arm instance in Port 1
arm Arm = arm(PORT1);

Funciones de los miembros#

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#

Mueve el efector final a las coordenadas x, y, z solicitadas.

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

Parameters

Parámetro

Tipo

Descripción

x

double

La coordenada X a la que hay que moverse, en milímetros.

y

double

La coordenada Y a la que hay que moverse, en milímetros.

z

double

La coordenada Z a la que hay que desplazarse, en milímetros.

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

Devuelve un valor booleano que indica si el brazo de 6 ejes alcanzó la posición objetivo.

  • true if the 6-Axis Arm reached the target position.

  • false if the 6-Axis 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#

Mueve el efector final las distancias x, y, z solicitadas con respecto a su posición actual.

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

Parameters

Parámetro

Tipo

Descripción

x

double

La distancia que hay que recorrer en el eje X, en milímetros.

y

double

La distancia que hay que recorrer en el eje Y, en milímetros.

z

double

La distancia que hay que recorrer en el eje Z, en milímetros.

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

Devuelve un valor booleano que indica si el brazo de 6 ejes alcanzó la posición objetivo.

  • true if the 6-Axis Arm reached the target position.

  • false if the 6-Axis 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#

Mueve el efector final a la orientación absoluta de guiñada, balanceo y cabeceo solicitada.

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

Parameters

Parámetro

Tipo

Descripción

yaw

double

El ángulo alrededor del eje Z hacia el que debe apuntar el efector final, en grados.

roll

double

El ángulo alrededor del eje X hacia el que debe apuntar el efector final, en grados. El valor predeterminado es 0.

pitch

double

El ángulo alrededor del eje Y hacia el que debe apuntar el efector final, en grados. El valor predeterminado es 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

Devuelve un valor booleano que indica si el efector final alcanzó la orientación objetivo.

  • 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#

Mueve el efector final a la orientación relativa de guiñada, balanceo y cabeceo solicitada.

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

Parameters

Parámetro

Tipo

Descripción

yaw

double

El ángulo alrededor del eje Z que debe cambiar el efector final, en grados.

roll

double

El ángulo alrededor del eje X que debe cambiar el efector final, en grados. El valor predeterminado es 0.

pitch

double

El ángulo alrededor del eje Y que debe cambiar el efector final, en grados. El valor predeterminado es 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

Devuelve un valor booleano que indica si el efector final alcanzó la orientación objetivo.

  • 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#

Establece la velocidad para los movimientos del brazo de 6 ejes.

Available Functions
void setSpeed( 
  uint32_t speed );

Parameters

Parámetro

Tipo

Descripción

speed

uint32_t

La velocidad a la que debe moverse el brazo de 6 ejes en mm/s.

Return Values

Esta función no devuelve ningún valor.

setEndEffectorType#

Establece el tipo de efector final en imán o bolígrafo.

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

Parameters

Parámetro

Tipo

Descripción

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

Devuelve un valor booleano que indica si se ha establecido el tipo solicitado.

  • 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#

Configura el imán del efector final como habilitado o deshabilitado.

Available Functions
void setEndEffectorMagnet( 
  bool enabled );

Parameters

Parámetro

Tipo

Descripción

enabled

bool

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

Return Values

Esta función no devuelve ningún valor.

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

setPenOffset#

Establece el desplazamiento del eje Z del efector final del lápiz.

Available Functions
void setPenOffset( 
  double zOffset );

Parameters

Parámetro

Tipo

Descripción

zOffset

double

El nuevo desplazamiento en milímetros. Un valor z positivo indica hacia arriba.

Return Values

Esta función no devuelve ningún valor.

setControlStop#

Desactiva el brazo de 6 ejes y pone los motores de las articulaciones en modo de frenado.

Available Functions
void setControlStop( 
  bool state = true);

Parameters

Parámetro

Tipo

Descripción

state

bool

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

Return Values

Esta función no devuelve ningún valor.

controlStopped#

Registra una función que se llamará cuando se habilite la parada de control del brazo de 6 ejes.

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

Parameters

Parámetro

Tipo

Descripción

callback

void (*)(void)

Una función que se llamará cuando se detenga el control del brazo de 6 ejes.

Return Values

Esta función no devuelve ningún valor.

Examples Examples

Define 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#

Devuelve un valor si el brazo de 6 ejes se ha accidentado durante el movimiento.

Nota: Cuando se detecta una colisión, el brazo de 6 ejes detendrá todo movimiento de los motores y parecerá que se queda inmóvil. Esto sirve para reducir la tensión y proteger los motores de daños accidentales.

Available Functions
bool isCrashed();

Parameters

Esta función no requiere ningún parámetro.

Return Values

Returns true if the 6-Axis Arm has crashed while moving, false if it has not.

Examples
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#

Registra una función que se llamará cuando el brazo de 6 ejes falle durante el movimiento.

Nota: Cuando se detecta una colisión, el brazo de 6 ejes detendrá todo movimiento de los motores y parecerá que se queda inmóvil. Esto sirve para reducir la tensión y proteger los motores de daños accidentales.

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

Parameters

Parámetro

Tipo

Descripción

callback

void (*)(void)

Una función que se llamará cuando el brazo de 6 ejes falle durante el movimiento.

Return Values

Esta función no devuelve ningún valor.

Examples Examples

Define 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#

Devuelve un valor booleano si el efector final puede moverse a las coordenadas x, y, z solicitadas.

Available Functions
bool canArmReachTo( double x, double y, double z );

Parameters

Parámetro

Tipo

Descripción

x

double

La coordenada X a la que hay que moverse, en milímetros.

y

double

La coordenada Y a la que hay que moverse, en milímetros.

z

double

La coordenada Z a la que hay que desplazarse, en milímetros.

Return Values

Returns true if the 6-Axis 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#

Devuelve verdadero si el efector final puede moverse una distancia a lo largo de los ejes x, y y z.

Available Functions
bool canArmReachInc( 
  double x, 
  double y, 
  double z );

Parameters

Parámetro

Tipo

Descripción

x

double

La distancia que hay que recorrer en el eje X, en milímetros.

y

double

La distancia que hay que recorrer en el eje Y, en milímetros.

z

double

La distancia que hay que recorrer en el eje Z, en milímetros.

Return Values

Devuelve un valor booleano que indica si el brazo de 6 ejes puede moverse a la posición solicitada.

  • true if the 6-Axis Arm can move to the requested position.

  • false if the 6-Axis 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#

Devuelve verdadero si el efector final puede moverse a la orientación absoluta de guiñada, balanceo y cabeceo solicitada.

Available Functions
bool canEndEffectorReachTo( 
  double yaw, 
  double roll = 0, 
  double pitch = 0 );

Parameters

Parámetro

Tipo

Descripción

yaw

double

El ángulo alrededor del eje Z hacia el que debe apuntar el efector final, en grados.

roll

double

El ángulo alrededor del eje X hacia el que debe apuntar el efector final, en grados. El valor predeterminado es 0.

pitch

double

El ángulo alrededor del eje Y hacia el que debe apuntar el efector final, en grados. El valor predeterminado es 0.

Return Values

Devuelve un valor booleano que indica si el efector final puede moverse a la orientación solicitada.

  • 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#

Devuelve verdadero si el efector final puede moverse una distancia en las direcciones de guiñada, cabeceo o balanceo.

Available Functions
bool canEndEffectorReachInc( 
  double yaw, 
  double roll = 0, 
  double pitch = 0 );

Parameters

Parámetro

Tipo

Descripción

yaw

double

El ángulo alrededor del eje z que abarca el movimiento del efector final, expresado en grados.

roll

double

El ángulo alrededor del eje x que abarca el movimiento del efector final, expresado en grados. El valor predeterminado es 0.

pitch

double

El ángulo alrededor del eje Y que el efector final recorrerá, expresado en grados. El valor predeterminado es 0.

Return Values

Devuelve un valor booleano que indica si el efector final puede moverse a la orientación solicitada.

  • 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#

Devuelve el estado del movimiento del brazo de 6 ejes.

Available Functions
bool isDone();

Parameters

Esta función no tiene parámetros.

Return Values

Devuelve un valor booleano que indica si el brazo de 6 ejes ha completado su movimiento.

  • true if the 6-Axis Arm has completed its movement.

  • false if the 6-Axis 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#

Devuelve la posición X del efector final.

Available Functions
float getX();

Parameters

Esta función no tiene parámetros.

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#

Devuelve la posición Y del efector final.

Available Functions
float getY();

Parameters

Esta función no tiene parámetros.

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#

Devuelve la posición z del efector final.

Available Functions
float getZ();

Parameters

Esta función no tiene parámetros.

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#

Devuelve el ángulo de guiñada actual del efector final.

Available Functions
float getYaw();

Parameters

Esta función no tiene parámetros.

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#

Devuelve el valor actual del efector final.

Available Functions
float getRoll();

Parameters

Esta función no tiene parámetros.

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#

Devuelve el tono actual del efector final.

Available Functions
float getPitch();

Parameters

Esta función no tiene parámetros.

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#

Establece el valor de tiempo de espera que se utiliza al mover el brazo.

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

Parameters

Parámetro

Tipo

Descripción

timeout

int32_t

El nuevo valor de tiempo de espera.

units

timeUnits

The unit that represents the time:

  • sec – seconds
  • msec – milliseconds

Return Values

Esta función no devuelve ningún valor.

isConnected#

Devuelve true si el brazo de 6 ejes está conectado. Esta es una función de compatibilidad que devuelve el mismo valor que la función installed().

Available Functions
bool isConnected();

Parameters

Esta función no tiene parámetros.

Return Values

Devuelve un valor booleano que indica si el brazo de 6 ejes está conectado al cerebro a través del puerto inteligente asociado.

  • true if the 6-Axis Arm is connected to the brain on the associated smartport.

  • false if the 6-Axis Arm is not connected to the brain on the associated smartport.

timestamp#

Devuelve la marca de tiempo del último paquete de estado recibido del Arm.

Available Functions
uint32_t timestamp();

Parameters

Esta función no tiene parámetros.

Return Values

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

installed#

Devuelve un valor si el dispositivo está conectado.

Available Functions
bool installed();

Parameters

Esta función no tiene parámetros.

Return Values

Devuelve un valor booleano que indica si el dispositivo está conectado.

  • true if the device is connected.

  • false if the device is not connected.