brazo#
Inicializando la clase arm#
Un brazo de 6 ejes se crea utilizando el siguiente constructor:
The arm constructor creates a 6-Axis CTE Arm in the specified Port.
Parámetro |
Descripción |
|---|---|
|
A valid |
// Construct a 6-Axis arm "Arm" with the
// arm class.
arm Arm = arm(PORT1);
This Arm object will be used in all subsequent examples throughout this API documentation when referring to arm class methods.
Métodos de clase#
moveTo()#
The moveTo(x, y, z, waitForCompletion) method moves the end effector to the requested X, Y, and Z absolute position.
This can be a waiting or non-waiting method depending on if the waitForCompletion parameter is used.
Parámetros |
Descripción |
|---|---|
|
La coordenada X a la que moverse, en milímetros. |
|
La coordenada Y a la que moverse, en milímetros. |
|
La coordenada Z a la que moverse, en milímetros. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Returns: true if the arm has moved to the requested position. false if it did not.
// Move the arm to the (200, 0, 100).
Arm.moveTo(200, 0, 100);
moveInc()#
The moveInc(x, y, z, waitForCompletion) method moves the end effector by the requested X, Y, and Z distances.
This can be a waiting or non-waiting method depending on if the waitForCompletion parameter is used.
Parámetros |
Descripción |
|---|---|
|
La distancia en el eje X a recorrer, en milímetros. |
|
La distancia a recorrer en el eje Y, en milímetros. |
|
La distancia en el eje Z a mover, en milímetros. |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Returns: true if the arm has moved to the requested position. false if it did not.
// Move the Arm +100 millimeters on the Y axis.
Arm.moveInc(0, 100, 0);
moveEndEffectorTo()#
The moveEndEffectorTo(yaw, roll, pitch, waitForCompletion) method moves the end effector to the requested absolute yaw, roll, and pitch orientation.
This can be a waiting or non-waiting method depending on if the waitForCompletion parameter is used.
Parámetros |
Descripción |
|---|---|
|
El ángulo alrededor del eje Z al que debe apuntar el efector final, en grados. |
|
El ángulo alrededor del eje X al que debe apuntar el efector final, en grados. |
|
El ángulo alrededor del eje Y al que debe apuntar el efector final, en grados. |
|
Determines whether the command will block subsequent commands ( |
Returns: true if the end effector has moved to the requested orientation. false if it has not.
// Orient the end effector to point towards
// 90 degrees around the X axis.
Arm.moveEndEffectorTo(0, 90, 0);
moveEndEffectorInc()#
The moveEndEffectorInc(yaw, roll, pitch, waitForCompletion) method moves the end effector to the requested relative yaw, roll, and pitch orientation.
This can be a waiting or non-waiting method depending on if the waitForCompletion parameter is used.
Parámetros |
Descripción |
|---|---|
|
El ángulo alrededor del eje Z en el que debe cambiar el efector final, en grados. |
|
El ángulo alrededor del eje X en el que debe cambiar el efector final, en grados. |
|
El ángulo alrededor del eje Y en el que debe cambiar el efector final, en grados. |
|
Determines whether the command will block subsequent commands ( |
Returns: true if the end effector has moved to the requested orientation. false if it has not.
// Orient the end effector -50 degrees on the Y axis.
Arm.moveEndEffectorInc(0, 0, -50);
setSpeed()#
The setSpeed(speed) method sets the speed for moves.
Parámetros |
Descripción |
|---|---|
|
La velocidad a la que debe moverse el brazo. |
Devoluciones: Ninguna.
setEndEffectorType()#
The setEndEffectorType(type) method sets the end effector type to magnet or pen.
Parámetros |
Descripción |
|---|---|
|
A valid |
Returns: true if the requested type was set. false if it was not.
// Set the end effector to the Magnet Pickup Tool.
Arm.setEndEffectorType(magnet);
setEndEffectorMagnet()#
The setEndEffectorMagnet(state) method sets the end effector magnet to enabled or disabled.
Parámetros |
Descripción |
|---|---|
|
|
Devoluciones: Ninguna.
// Enable the Magnet Pickup Tool.
Arm.setEndEffectorMagnet(true);
setPenOffset()#
The setPenOffset(zOffset) method sets the pen end effector Z axis offset.
Parámetros |
Descripción |
|---|---|
|
The new offset in |
Devoluciones: Ninguna.
setControlStop()#
The setControlStop(state) method disables the arm and places joint motors in brake mode.
Parámetros |
Descripción |
|---|---|
|
|
Devoluciones: Ninguna.
controlStopped()#
The controlStopped(callback) method registers a function to be called when the arm control stop is enabled.
Parámetros |
Descripción |
|---|---|
|
Una función que se llamará cuando se detenga el control del brazo. |
Devoluciones: Ninguna.
// 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");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run whenControlStopped when the the arm is control stopped.
Arm.controlStopped(whenControlStopped);
}
canArmReachTo()#
The canArmReachTo(x, y, z) method checks if the end effector can move to the requested X, Y, and Z absolute position.
Parámetros |
Descripción |
|---|---|
|
La coordenada X a la que moverse, en milímetros. |
|
La coordenada Y a la que moverse, en milímetros. |
|
La coordenada Z a la que moverse, en milímetros. |
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()#
The Arm.canArmReachInc(x, y, z) method checks if the end effector can move to the requested X, Y, and Z relative position.
Parámetros |
Descripción |
|---|---|
|
La distancia en el eje X a recorrer, en milímetros. |
|
La distancia a recorrer en el eje Y, en milímetros. |
|
La distancia en el eje Z a mover, en milímetros. |
Returns: true if the arm can move to the requested position. false if it cannot.
// 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()#
The canEndEffectorReachTo(yaw, roll, pitch) method checks if the end effector can move to the requested absolute yaw, roll, and pitch orientation.
Parámetros |
Descripción |
|---|---|
|
El ángulo alrededor del eje Z al que debe apuntar el efector final, en grados. |
|
El ángulo alrededor del eje X al que debe apuntar el efector final, en grados. |
|
El ángulo alrededor del eje Y al que debe apuntar el efector final, en grados. |
Returns: true if the end effector can move to the requested orientation. false if it cannot.
// 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()#
The canEndEffectorReachInc(yaw, roll, pitch) method checks if the end effector can move to the requested relative yaw, roll, and pitch orientation.
Parámetros |
Descripción |
|---|---|
|
El ángulo alrededor del eje Z en el que se moverá el efector final, en grados. |
|
Este parámetro es opcional. Indica el ángulo en grados que se moverá el efector final alrededor del eje X. |
|
Este es un parámetro opcional. El ángulo alrededor del eje Y que el efector final alcanzará, en grados. |
Returns: true if the end effector can move to the requested orientation. false if it cannot.
// 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()#
The isDone() method returns the status of arm movement.
Returns: true if the arm is currently performing a movement. false if it is not.
// 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()#
The getX() method returns the X position of the end effector.
Returns: A float representing the X position of the end effector in mm.
// Print the current X position of the Arm in degrees.
Brain.Screen.print(Arm.getX());
getY()#
The getY() method returns the Y position of the end effector.
Returns: A float representing the Y position of the end effector in mm.
// Print the current Y position of the Arm in degrees.
Brain.Screen.print(Arm.getY());
getZ()#
The getZ() method requests the Z position of the end effector.
Returns: A float representing the Z position of the end effector in mm.
// Print the current Z position of the Arm in degrees.
Brain.Screen.print(Arm.getZ());
getYaw()#
The getYaw() method requests the current yaw of the end effector.
Devuelve: Un flotante que representa la guiñada actual del efector final en grados.
// Print the current yaw of the Arm in degrees.
Brain.Screen.print(Arm.getYaw());
getRoll()#
The getRoll() method requests the current roll of the end effector.
Devuelve: Un flotante que representa el balanceo actual del efector final en grados.
// Print the current roll of the Arm in degrees.
Brain.Screen.print(Arm.getRoll());
getPitch()#
The getPitch() method requests the current pitch of the end effector.
Devuelve: Un flotante que representa el tono actual del efector final en grados.
// Print the current pitch of the Arm in degrees.
Brain.Screen.print(Arm.getPitch());
setTimeout()#
The setTimeout(timeout, units) method sets the timeout value used when moving the Arm.
Parámetros |
Descripción |
|---|---|
|
El nuevo valor de tiempo de espera. |
|
A valid |
Devoluciones: Ninguna.
isConnected()#
The isConnected() method checks if the CTE arm is connected. This is a compatibility function that returns the same as the installed() function.
Returns: true if the arm is connected to the brain on the associated smartport. false if it is not.
timestamp()#
The timestamp() method requests the timestamp of the last received status packet from the Arm.
Devuelve: Marca de tiempo del último paquete de estado como un entero de 32 bits sin signo en milisegundos.
installed()#
The installed() method returns if the device is connected.
Returns: true if the device is connected. false if it is not.