transmisión#
Inicializando la clase de transmisión#
Se crea un sistema de transmisión utilizando el siguiente constructor:
The drivetrain
constructor creates a drivetrain object.
Parámetro |
Descripción |
---|---|
|
El nombre del Motor o Grupo Motor izquierdo. |
|
El nombre del Motor o Grupo Motor derecho. |
|
Circunferencia de las ruedas motrices. El valor predeterminado es 300 mm. |
|
Ancho de vía del tren motriz. El valor predeterminado es 320 mm. |
|
Distancia entre ejes del tren motriz. El valor predeterminado es 320 mm. |
|
A valid distanceUnit for the units that wheelTravel, trackWidth and wheelBase are specified in. The default is |
|
El gearSetting del motor se utiliza para compensar las distancias de conducción si se utilizan engranajes. |
Los Motores y/o los Grupos de motores deben crearse primero antes de poder usarse para crear un objeto con el constructor de la clase drivetrain.
// Create the Motors.
motor left_motor = motor(PORT1,false);
motor right_motor = motor(PORT2, true);
// Construct a 2-Motor drivetrain "Drivetrain" with the
// drivetrain class.
drivetrain Drivetrain = drivetrain(left_motor, right_motor, 259.34, 320, 40, mm, ratio18_1);
Si va a fabricar un sistema de transmisión con 4 motores, deberá crear los Motores por separado antes de agruparlos en un Grupo de motores.
// Create the left Motors and group them under the
// motor_group "leftMotors".
motor leftMotorA = motor(PORT1, false);
motor leftMotorB = motor(PORT2, false);
motor_group leftMotors = motor_group(leftMotorA, leftMotorB);
// Create the right Motors and group them under the
// MotorGroup "rightMotors".
motor rightMotorA = motor(PORT3, true);
motor rightMotorB = motor(PORT4, true);
motor_group rightMotors = motor_group(rightMotorA, rightMotorB);
// Construct a 4-Motor drivetrain "Drivetrain" with the
// drivetrain class.
drivetrain Drivetrain = drivetrain(leftMotors, rightMotors, 259.34, 320, 40, mm, ratio18_1);
This Drivetrain
object will be used in all subsequent examples throughout this API documentation when referring to drivetrain class methods.
Para incorporar un Sensor inercial o un Sensor giroscópico para una funcionalidad de giro mejorada en su transmisión, puede incluirlo al crear un objeto usando el constructor de clase smartdrive.
Métodos de clase#
drive()#
Este es un método sin espera y permite que el siguiente método se ejecute sin demora.
Este método se llama de las siguientes maneras:
The drive(dir)
method is used to drive the drivetrain in the specified direction forever at the default velocity as specified by the setDriveVelocity()
method, until another drivetrain movement method is used, or the project is stopped.
Parámetros |
Descripción |
---|---|
director |
Un DirectionType válido. |
Devoluciones: Ninguna.
// Drive the drivetrain forward.
Drivetrain.drive(forward);
The drive(dir, velocity, units)
method is used to drive the drivetrain in the specified direction forever at a specified velocity, until another drivetrain movement method is used, or the project is stopped.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
velocidad |
La velocidad a la que se moverá el tren motriz. |
unidades |
Una velocityUnit válida. |
Devoluciones: Ninguna.
// Drive the drivetrain forward at 100 rpm.
Drivetrain.drive(forward, 100, rpm);
driveFor()#
This can be a waiting or non-waiting method depending on if the waitForCompletion
parameter is used.
Este método se llama de las siguientes maneras:
The driveFor(distance, units, waitForCompletion)
method is used to drive the drivetrain for a specified distance at the default velocity.
Parámetros |
Descripción |
---|---|
distancia |
La distancia que debe recorrer el tren motriz. |
unidades |
A valid DistanceUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha alcanzado la distancia objetivo.
// Drive the drivetrain for 10 inches.
Drivetrain.driveFor(10, inches);
The driveFor(dir, distance, units, waitForCompletion)
method is used to drive the drivetrain in a specified direction for a specified distance at the default velocity.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
distancia |
La distancia que debe recorrer el tren motriz. |
unidades |
A valid distanceUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha alcanzado la distancia objetivo.
// Drive the drivetrain forward for 10 inches.
Drivetrain.driveFor(forward, 10, inches);
The driveFor(distance, units, velocity, units_v, waitForCompletion)
method is used to drive the drivetrain for a specified distance at the default velocity.
Parámetros |
Descripción |
---|---|
distancia |
La distancia que debe recorrer el tren motriz. |
unidades |
A valid distanceUnit. The default is |
velocidad |
The velocity the drivetrain will move with. The default velocity set by the |
unidades_v |
A valid velocityUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha alcanzado la distancia objetivo.
// Drive the drivetrain for 10 inches at 100 rpm.
Drivetrain.driveFor(10, inches, 100, rpm);
The driveFor(dir, distance, units, velocity, units_v, waitForCompletion)
method is used to drive the drivetrain for a specified distance at the default velocity.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
distancia |
La distancia que debe recorrer el tren motriz. |
unidades |
A valid distanceUnit. The default is |
velocidad |
The velocity the drivetrain will move with. The default velocity set by the |
unidades_v |
A valid velocityUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha alcanzado la distancia objetivo.
// Drive the drivetrain forward for 10 inches at 100 rpm.
Drivetrain.driveFor(forward, 10, inches, 100, rpm);
turn()#
Este es un método sin espera y permite que el siguiente método se ejecute sin demora.
Este método se llama de las siguientes maneras:
The turn(dir)
method is used to turn the robot in a specified direction at the default velocity as specified by the setTurnVelocity()
method, until another drivetrain movement method is used, or the project is stopped.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
Devoluciones: Ninguna.
// Turn the drivetrain right.
Drivetrain.turn(right);
The turn(dir, velocity, units)
method is used to turn the robot in a specified direction at a specified velocity, until another drivetrain movement method is used, or the project is stopped.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
velocidad |
The velocity at which the drivetrain will turn. The default velocity set by The |
unidades |
A valid velocityUnit. The default is |
Devoluciones: Ninguna.
// Turn the drivetrain right at 100 rpm.
Drivetrain.turn(right, 100, rpm);
turnFor()#
This can be a waiting or non-waiting method depending on if the waitForCompletion
parameter is used.
Este método se llama de las siguientes maneras:
The turnFor(angle, units, waitForCompletion)
turns the drivetrain for a specified angle or rotations at the default velocity as specified by the setTurnVelocity()
method.
Parámetros |
Descripción |
---|---|
ángulo |
El ángulo en el que debe girar la transmisión. |
unidades |
A valid rotationUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha girado al ángulo objetivo.
// Turn the drivetrain for 90 degrees.
Drivetrain.turnFor(90, degrees);
The turnFor(dir, angle, units, waitForCompletion)
turns the drivetrain left or right for a specified angle or rotations at the default velocity as specified by the setTurnVelocity()
method.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
ángulo |
El ángulo en el que debe girar la transmisión. |
unidades |
A valid rotationUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha girado al ángulo objetivo.
// Turn the drivetrain right for 90 degrees.
Drivetrain.turnFor(right, 90, degrees);
The turnFor(angle, units, velocity, units_v, waitForCompletion)
turns the drivetrain for a specified angle or rotations at a specified velocity.
Parámetros |
Descripción |
---|---|
ángulo |
El ángulo en el que debe girar la transmisión. |
unidades |
A valid rotationUnit. The default is |
velocidad |
The velocity at which the drivetrain will turn. The default velocity set by The |
unidades_v |
A valid velocityUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha girado al ángulo objetivo.
// Turn the drivetrain for 90 degrees at 100 rpm.
Drivetrain.turnFor(90, degrees, 100, rpm);
The turnFor(dir, angle, units, velocity, units_vwaitForCompletion)
turns the drivetrain left or right for a specified angle or rotations at a specified velocity.
Parámetros |
Descripción |
---|---|
director |
Un directionType válido. |
ángulo |
El ángulo en el que debe girar la transmisión. |
unidades |
A valid rotationUnit. The default is |
velocidad |
The velocity at which the drivetrain will turn. The default velocity set by The |
unidades_v |
A valid velocityUnit. The default is |
esperar a que se complete |
Determines whether the command will block subsequent commands ( |
Devuelve: Un valor booleano que representa si la transmisión ha girado al ángulo objetivo.
// Turn the drivetrain right for 90 degrees at 100 rpm.
Drivetrain.turnFor(right, 90, degrees, 100, rpm);
stop()#
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Este método se llama de las siguientes maneras:
The stop()
command is used to stop the drivetrain, setting the drivetrain to 0 velocity and configuring the current stopping mode. The default Brake Type is coast
, unless previously changed using the setStopping()
command.
Devoluciones: Ninguna.
// Spin Drivetrain for 2.5 seconds.
Drivetrain.spin(forward);
wait(2.5 seconds);
// Stop Drivetrain.
Drivetrain.stop();
The stop(mode)
command is used to stop the drivetrain using a specific Brake Type.
Parámetros |
Descripción |
---|---|
modo |
Un brakeType válido. |
Devoluciones: Ninguna.
// Spin Drivetrain for 2.5 seconds.
Drivetrain.spin(forward);
wait(2.5 seconds);
// Stop Drivetrain using the hold Brake Type.
Drivetrain.stop(hold);
isMoving()#
The isMoving()
command returns if any drivetrain motor is on and rotating to a specific target.
Returns: true
if any drivetrain motor is on and rotating to a target. false
if it they are done rotating to a target.
isDone()#
The isDone()
command returns if all drivetrain motors are done rotating to a specific target.
Returns: true
if the all drivetrain motors are done rotating to a target. false
if any drivetrain motor is on and rotating to a target.
setDriveVelocity()#
The setDriveVelocity(velocity, units)
method is used to set the default velocity for the Drivetrain. This velocity setting affects all subsequent drive method unless a specific velocity is provided in those method.
Parámetros |
Descripción |
---|---|
velocidad |
La nueva velocidad que se establecerá como predeterminada para el tren motriz. |
unidades |
A valid velocityUnit or |
Devoluciones: Ninguna.
// Set the drivetrain to drive at a velocity of 200 rpm.
Drivetrain.setDriveVelocity(200, rpm);
setTurnVelocity()#
The setTurnVelocity(velocity, units)
method is used to set the default velocity for turning maneuvers in the Drivetrain. This setting specifies the speed at which the drivetrain will execute turning method unless overridden by a specific velocity in those method.
Parámetros |
Descripción |
---|---|
velocidad |
La nueva velocidad que se establecerá como predeterminada para las maniobras de giro. |
unidades |
A valid velocityUnit or |
Devoluciones: Ninguna.
// Set the drivetrain to turn at a velocity of 200 RPM.
Drivetrain.setTurnVelocity(200, rpm);
setStopping()#
The setStopping(mode)
method is used to set the stopping mode for all motors on the Drivetrain. This setting determines the behavior of the motors when they receive a stop method or when the velocity is set to zero.
Parámetros |
Descripción |
---|---|
modo |
Un brakeType válido. |
Devoluciones: Ninguna.
// Set the stopping mode to BRAKE.
Drivetrain.setStopping(brake);
setGearRatio()#
The setGearRatio(mode)
method is used to set the gear ratio for all motors on the Drivetrain.
Parámetros |
Descripción |
---|---|
modo |
Un gearSetting válido. |
Devoluciones: Ninguna.
setTimeout()#
The Drivetrain.setTimeout(time, units)
method is used to set the timeout value for all motors on the Drivetrain. This setting determines how long the drivetrain will attempt to execute driveFor
or turnFor
method before timing out if the motors have not completed their movements.
Parámetros |
Descripción |
---|---|
se acabó el tiempo |
La duración del tiempo de espera que se establecerá como predeterminada para las operaciones del tren motriz. |
unidades |
A valid timeUnit type. The default is |
Devoluciones: Ninguna.
// Set the timeout for the drivetrain to 10 seconds.
Drivetrain.setTimeout(10, seconds);
velocity()#
The velocity(units)
method returns the average velocity of the drivetrain.
Parámetros |
Descripción |
---|---|
unidades |
A valid velocityUnit or |
Devuelve: Un doble que representa la velocidad del tren motriz en las unidades especificadas.
current()#
The current()
method returns the average current of the drivetrain.
Parámetros |
Descripción |
---|---|
unidades |
The only valid units for current are |
Devuelve: Un doble que representa la corriente del tren motriz en las unidades especificadas.
voltage()#
The voltage(units)
method returns the average velocity of the drivetrain.
Parámetros |
Descripción |
---|---|
unidades |
A valid voltageUnit. The default is |
Devuelve: Un doble que representa el voltaje del tren motriz en las unidades especificadas.
power()#
The power(units)
method returns the average power of the drivetrain .
Parámetros |
Descripción |
---|---|
unidades |
The only valid unit for power is |
Devuelve: Un doble que representa la potencia del tren motriz en las unidades especificadas.
torque()#
The torque(units)
method returns the average torque of the drivetrain.
Parámetros |
Descripción |
---|---|
unidades |
A valid torqueUnit. The default is |
Devuelve: Un doble que representa el torque del tren motriz en las unidades especificadas.
efficiency()#
The efficiency(units)
method returns the average efficiency of the drivetrain.
Parámetros |
Descripción |
---|---|
unidades |
The only valid unit for efficiency is |
Devuelve: Un doble que representa la eficiencia del tren motriz en las unidades proporcionadas.
temperature()#
The temperature(units)
method returns the average temperature of the drivetrain.
Parámetros |
Descripción |
---|---|
unidades |
The only valid unit for temperature is |
Devuelve: Un doble que representa la temperatura del tren motriz en las unidades proporcionadas.