Brazo de 6 ejes#

Introducción#

El brazo robótico de 6 ejes VEX permite a los programas mover un efector final en el espacio tridimensional y controlar su orientación mediante rotaciones de guiñada, balanceo y cabeceo. El brazo de 6 ejes también se puede configurar con diferentes efectores finales, como la herramienta de recogida magnética o el soporte para bolígrafos.

For the examples below, the configured 6-Axis Arm will be named arm1 and will be used in all subsequent examples throughout this API documentation when referring to Arm class methods.

A continuación se muestra una lista de todos los métodos disponibles:

Acciones: Mueva el brazo de 6 ejes a posiciones u orientaciones en el espacio 3D.

  • move_to – Moves the end effector to an absolute X, Y, Z position.

  • move_inc – Moves the end effector by a relative X, Y, Z distance.

  • move_end_effector_to – Rotates the end effector to an absolute yaw, roll, and pitch orientation.

  • move_end_effector_inc – Rotates the end effector by a relative yaw, roll, and pitch amount.

Motadores: configura el comportamiento, las herramientas y los ajustes de movimiento del brazo de 6 ejes.

Funciones de obtención: devuelven el estado de movimiento, la posición, la orientación y los valores de configuración del brazo de 6 ejes.

  • is_done – Returns whether the 6-Axis Arm has completed its movement.

  • is_crashed – Returns whether the 6-Axis Robotic Arm has crashed while moving.

  • get_x – Returns the current X position of the end effector.

  • get_y – Returns the current Y position of the end effector.

  • get_z – Returns the current Z position of the end effector.

  • get_pitch – Returns the current pitch orientation of the end effector.

  • get_roll – Returns the current roll orientation of the end effector.

  • get_yaw – Returns the current yaw orientation of the end effector.

  • can_arm_reach_to – Returns whether the 6-Axis Arm can reach an absolute position.

  • can_arm_reach_inc – Returns whether the 6-Axis Arm can reach a relative position.

  • can_end_effector_reach_to – Returns whether the 6-Axis Arm can reach an absolute orientation.

  • can_end_effector_reach_inc – Returns whether the 6-Axis Arm can reach a relative orientation.

  • control_stopped – Registers a function to run when the 6-Axis Arm enters control stop.

  • crashed – Registers a function to run when the 6-Axis Arm has crashed while moving.

  • get_timeout – Returns the current timeout value used by 6-Axis Arm movement methods.

  • is_connected – Returns whether the 6-Axis Arm is connected to the Brain.

Constructores: Inicialicen y configuren manualmente el brazo de 6 ejes.

  • Arm – Create a 6-Axis Arm.

Comportamiento#

move_to#

move_to moves the 6-Axis Arm to a specified x, y, and z coordinate.

Este método devuelve un valor booleano que indica si el brazo de 6 ejes ha alcanzado la posición solicitada:

  • True — The 6-Axis Arm has reached the requested position.

  • False — The 6-Axis Arm cannot reach the requested position.

Usage:
arm1.move_to(x, y, z, wait)

Parámetro

Descripción

incógnita

La coordenada x de la posición objetivo en milímetros.

y

La coordenada y de la posición objetivo en milímetros.

z

La coordenada z de la posición objetivo en milímetros.

wait

Optional.

  • wait=True (default) – The project waits until move_to is complete before executing the next line of code.
  • wait=False – The project starts the action and moves on to the next line of code immediately without waiting for move_to to finish.

# Move the Arm to (40, 140, 210)
arm1.move_to(40, 140, 210)

move_inc#

move_inc moves the 6-Axis Arm by a specified distance along the x, y, and z axes.

Este método devolverá un valor booleano que indicará si el brazo de 6 ejes ha alcanzado la posición solicitada:

  • True — The 6-Axis Arm has reached the requested position.

  • False — The 6-Axis Arm cannot reach the requested position.

Usage:
arm1.move_inc(x, y, z, wait)

Parámetro

Descripción

incógnita

La distancia a recorrer a lo largo del eje x en milímetros.

y

La distancia a recorrer a lo largo del eje y en milímetros.

z

La distancia a recorrer a lo largo del eje z en milímetros.

wait

Optional.

  • wait=True (default) – The project waits until move_inc is complete before executing the next line of code.
  • wait=False – The project starts the action and moves on to the next line of code right away, without waiting for move_inc to finish.

# Move the Arm +100 millimeters on the y-axis
arm1.move_inc(0, 100, 0)

move_end_effector_to#

move_end_effector_to rotates the 6-Axis Arm’s end effector to a specified yaw, roll, and pitch orientation.

Este método devuelve un valor booleano que indica si el efector final ha alcanzado la orientación solicitada:

  • True — The end effector has reached the requested orientation.

  • False — The end effector cannot reach the requested orientation.

Usage:
arm1.move_end_effector_to(yaw, roll, pitch, wait)

Parámetro

Descripción

guiñada

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

rollo

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

paso

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

wait

Optional.

  • wait=True (default) – The project waits until move_end_effector_to is complete before executing the next line of code.
  • wait=False – The project starts the action and moves on to the next line of code right away, without waiting for move_end_effector_to to finish.

# Orient the end effector to point towards
# 90 degrees around the x-axis
arm1.move_end_effector_to(0, 90, 0)

move_end_effector_inc#

move_end_effector_inc rotates the 6-Axis Arm’s end effector by a specified relative yaw, roll, and pitch amount.

Este método devuelve un valor booleano que indica si el efector final ha alcanzado la orientación solicitada:

  • True — The end effector has reached the requested orientation.

  • False — The end effector cannot reach the requested orientation.

Usage:
arm1.move_end_effector_inc(yaw, roll, pitch, wait)

Parámetro

Descripción

guiñada

El cambio de ángulo alrededor del eje z, en grados.

rollo

El cambio de ángulo alrededor del eje x, en grados.

paso

El cambio de ángulo alrededor del eje y, en grados.

wait

Optional.

  • wait=True (default) – The project waits until move_end_effector_inc is complete before executing the next line of code.
  • wait=False – The project starts the action and moves on to the next line of code right away, without waiting for move_end_effector_inc to finish.

# Rotate the end effector -50 degrees around the y-axis
arm1.move_end_effector_inc(0, 0, -50)

Mutadores#

set_speed#

set_speed sets the movement speed used by the 6-Axis Arm for motion commands.

Usage:
arm1.set_speed(speed)

Parámetro

Descripción

velocidad

La velocidad a la que debe moverse el brazo de 6 ejes, expresada como un porcentaje del 1 al 100.

# Set the Arm speed to 30%
arm1.set_speed(30)

set_end_effector_type#

set_end_effector_type sets the type of end effector attached to the 6-Axis Arm.

Usage:
arm1.set_end_effector_type(type)

Parámetro

Descripción

tipo

A valid end effector type:

  • MAGNET — Magnet Pickup Tool
  • PEN — Pen Holder Tool

# Set the end effector type to the Magnet Pickup Tool
arm1.set_end_effector_type(MAGNET)

set_end_effector_magnet#

set_end_effector_magnet sets the state of the Magnet Pickup Tool on the 6-Axis Arm.

Usage:
arm1.set_end_effector_magnet(state)

Parámetro

Descripción

estado

The state of the Magnet Pickup Tool:

  • True — The magnet will pick up and hold objects.
  • False — The magnet will drop and no longer pick up objects.

# Pick up objects and then drop them
arm1.set_end_effector_type(MAGNET)
arm1.set_end_effector_magnet(True)
arm1.move_inc(0, 0, 100)
arm1.set_end_effector_magnet(False)

set_pen_offset#

set_pen_offset sets the z-axis offset used when the Pen Holder Tool is attached to the 6-Axis Arm.

Usage:
arm1.set_pen_offset(zOffset)

Parámetro

Descripción

Desplazamiento z

Valor de desplazamiento del lápiz en milímetros. Un valor positivo desplaza el punto de desplazamiento hacia arriba desde el punto de montaje de la herramienta.

set_control_stop#

set_control_stop enables the control stop for the 6-Axis Arm.

Usage:
arm1.set_control_stop(state)

Parámetro

Descripción

estado

Optional.

  • True (default) – Enables control stop and prevents further linear or joint movements.
  • False – Does not enable control stop.

set_timeout#

set_timeout sets the timeout value used when moving the 6-Axis Arm.

Usage:
arm1.set_timeout(timeout, units)

Parámetro

Descripción

se acabó el tiempo

El nuevo valor de tiempo de espera.

unidades

The unit to represent the time:

  • MSEC (default) — milliseconds
  • SECONDS / SEC — seconds

Getters#

is_done#

is_done returns a Boolean indicating whether the 6-Axis Arm is currently moving.

  • True — The 6-Axis Arm is not moving.

  • False — The 6-Axis Arm is still moving.

Usage:
arm1.is_done()

# Display the arm's position while it moves
arm1.move_to(-100, 200, 100, False)
while not arm1.is_done():
    brain.print(arm1.get_y())
    brain.next_row()
    wait(0.25, SECONDS)

is_crashed#

is_crashed returns a Boolean indicating whether the 6-Axis Robotic Arm has crashed while moving.

  • True — The 6-Axis Arm has crashed.

  • False — The 6-Axis Arm has not crashed.

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.

Usage:
arm1.is_crashed()

# Quickly move to a new location
arm1.set_speed(100)
arm1.move_to(-30, 240, 40, False)
# While moving, check for a crash
while True:
    if arm1.is_crashed():
        # Indicate a crash with the Signal Tower and Brain screen
        brain.screen.print("Crash Detected")
        signal_tower_2.set_color(SignalTower.GREEN, SignalTower.OFF)
        signal_tower_2.set_color(SignalTower.RED, SignalTower.ON)
        break
    wait(5, MSEC)

get_x#

get_x returns the x position of the end effector in millimeters.

Usage:
arm1.get_x()

def main():
    # Print the current x position of the Arm in millimeters
    brain.print(arm1.get_x())

get_y#

get_y returns the y position of the end effector in millimeters.

Usage:
arm1.get_y()

def main():
    # Print the current y position of the Arm in millimeters
    brain.print(arm1.get_y())

get_z#

get_z returns the z position of the end effector in in millimeters.

Usage:
arm1.get_z()

def main():
    # Print the current z position of the Arm in millimeters
    brain.print(arm1.get_z())

get_pitch#

get_pitch returns the current pitch of the end effector in degrees.

Usage:
arm1.get_pitch()

def main():
    # Print the current pitch of the Arm in degrees.
    brain.print(arm1.get_pitch())

get_roll#

get_roll returns the current roll of the end effector in degrees.

Usage:
arm1.get_roll()

def main():
    # Print the current roll of the Arm in degrees.
    brain.print(arm1.get_roll())

get_yaw#

get_yaw returns the current yaw of the end effector in degrees.

Usage:
arm1.get_yaw()

def main():
    # Print the current yaw of the Arm in degrees.
    brain.print(arm1.get_yaw())

can_arm_reach_to#

can_arm_reach_to returns a Boolean indicating whether the 6-Axis Arm can move the end effector to a specified x, y, and z coordinate.

  • True — The 6-Axis Arm can reach the requested position.

  • False — The 6-Axis Arm cannot reach the requested position.

Usage:
arm1.can_arm_reach_to(x, y, z)

Parámetro

Descripción

incógnita

La coordenada x de la posición objetivo en milímetros.

y

La coordenada y de la posición objetivo en milímetros.

z

La coordenada z de la posición objetivo en milímetros.

# Move the Arm to (100, -20, 50) if it can reach
if arm1.can_arm_reach_to(100, -20, 50):
    arm1.move_to(100, -20, 50)

can_arm_reach_inc#

can_arm_reach_inc returns a Boolean indicating whether the 6-Axis Arm can move the end effector by a specified relative x, y, and z distance.

  • True — The 6-Axis Arm can reach the requested position.

  • False — The 6-Axis Arm cannot reach the requested position.

Usage:
arm1.can_arm_reach_inc(x, y, z)

Parámetro

Descripción

incógnita

La distancia a recorrer a lo largo del eje x en milímetros.

y

La distancia a recorrer a lo largo del eje y en milímetros.

z

La distancia a recorrer a lo largo del eje z en milímetros.

# Increment the Arm +100 mm along the x-axis if possible
if arm1.can_arm_reach_inc(100, 0, 0):
    arm1.move_inc(100, 0, 0)

can_end_effector_reach_to#

can_end_effector_reach_to returns a Boolean indicating whether the 6-Axis Arm can move the end effector to a specified yaw, roll, and pitch orientation.

  • True — The end effector can reach the requested orientation.

  • False — The end effector cannot reach the requested orientation.

Usage:
arm1.can_end_effector_reach_to(yaw, roll, pitch)

Parámetro

Descripción

guiñada

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

rollo

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

paso

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

# Orient towards 90 degrees on the x-axis if possible
if arm1.can_end_effector_reach_to(0, 90, 0):
    arm1.move_end_effector_to(0, 90, 0)

can_end_effector_reach_inc#

can_end_effector_reach_inc returns a Boolean indicating whether the 6-Axis Arm can move the end effector by a specified relative yaw, roll, and pitch amount.

  • True — The end effector can reach the requested orientation.

  • False — The end effector cannot reach the requested orientation.

Usage:
arm1.can_end_effector_reach_inc(yaw, roll, pitch)

Parámetro

Descripción

guiñada

El cambio de ángulo alrededor del eje z, en grados.

rollo

El cambio de ángulo alrededor del eje x, en grados.

paso

El cambio de ángulo alrededor del eje y, en grados.

# Increment the end effector by 
# +10 degrees on the y-axis if possible
if arm1.can_end_effector_reach_inc(0, 0, 10):
    arm1.move_end_effector_inc(0, 0, 10)

control_stopped#

control_stopped registers a function that will be called when the control stop is enabled.

This method returns an instance of the Event class.

Usage:
arm1.control_stopped(callback, arg)

Parámetros

Descripción

callback

Una función definida previamente que se ejecuta cuando se habilita la parada de control.

arg

Opcional. Una tupla que contiene los argumentos que se pasarán a la función de devolución de llamada. Consulte Uso de funciones con parámetros para obtener más información.

# Define a function when_control_stopped
def when_control_stopped():
    # Print to the Brain's screen that the Arm has been
    # control stopped.
    brain.screen.print("The arm has been control stopped")

# Run when_control_stopped when the Arm is control stopped.
arm.control_stopped(when_control_stopped)

crashed#

crashed registers a function to run when the 6-Axis Arm has crashed while moving.

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.

Usage:
arm1.crashed(callback)

Parámetros

Descripción

callback

Una función definida previamente que se ejecuta cuando se habilita la parada de control.

# Define what happens in the event of a crash
def arm_crash():
    # Indicate a crash with the Signal Tower and Brain screen
    brain.screen.print("Crash Detected")
    signal_tower_2.set_color(SignalTower.GREEN, SignalTower.OFF)
    signal_tower_2.set_color(SignalTower.RED, SignalTower.ON)

# Listen for a crash
arm1.crashed(arm_crash)

get_timeout#

get_timeout returns the timeout value used by the 6-Axis Arm move methods in milliseconds.

Usage:
arm1.get_timeout()

is_connected#

is_connected returns a Boolean indicating whether the 6-Axis Arm is connected to the Brain.

  • True — The Arm is connected to the Brain.

  • False — The Arm is not connected to the Brain.

Usage:
arm1.is_connected()

Constructores#

Arm#

Arm create a 6-Axis Arm.

Arm(smartport)

Parámetro

Descripción

smartport

The Smart Port that the 6-Axis Arm is connected to, written as Ports.PORTx where x is the number of the port.

# Construct a 6-Axis Arm "arm1" with the
# Arm class
arm1 = Arm(Ports.PORT1)