Movimiento#
Introducción#
Motors control how parts of a robot move. Motors can be used to raise an arm, turn a claw, spin a wheel, or move another part of a build. Two motors can work together as a drivetrain to move and turn the whole robot.
Each motor is configured in the Devices window. Depending on the build, the names of the motors and directions can change. For example, the Competition Advanced 2.0 build has a motor named ArmMotor, with directions up and down. A custom robot may use different motor names or directions.
By default, forward spins a motor counterclockwise, and reverse spins a motor clockwise. If a motor is set to reverse in the Devices window, those directions will be switched.
There are many ways to code motors. Below is a list of all Motion blocks:
Acciones: Detener y hacer girar los motores.
spin motor — Spins a motor forward or reverse forever.
girar motor durante — Hace girar un motor durante una distancia específica.
spin motor to position — Spins a motor to a specific position.
stop motor — Stops a motor from spinning.
Ajustes: Ajuste la configuración del motor.
set motor position — Changes the motor’s current position to a new value.
set motor velocity — Tells a motor how fast to spin.
set motor stopping — Sets how a motor will stop moving: by braking, coasting, or holding.
set motor max torque — Sets how hard a motor is allowed to push while spinning.
set motor timeout — Sets how many seconds a motor will try to finish a movement.
Values — Check motor status.
motor is done — Reports whether the motor is finished moving.
motor is spinning? — Reports whether the motor is spinning.
motor position — Reports the motor’s current position.
motor velocity — Reports how fast the motor is spinning, as a percentage from -100% to 100%.
motor current — Reports how much power the motor is using from the battery, as a percentage from 0% to 100%.
Comportamiento#
motor de giro#
The spin motor stack block spins a motor forward or reverse forever. The motor will continue to spin until it is given another action, like spinning in a different direction or stopping.
girar [ArmMotor v] [arriba v]
Parámetros |
Descripción |
|---|---|
motor |
The motor to spin. Choose from the motors configured in the Devices window. |
dirección |
The direction the motor spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Raise the ArmMotor, then stop.]
girar [ArmMotor v] [arriba v]
esperar [1] segundos
parada [ArmMotor v]
motor de giro para#
The spin motor for stack block spins a motor for a specific distance. The spin is relative to the current position of the motor. The project will wait until the motor is done spinning before the next block in the stack runs.
girar [ArmMotor v] [arriba v] por [90] [grados v] ▶
Parámetros |
Descripción |
|---|---|
motor |
The motor to spin. Choose from the motors configured in the Devices window. |
dirección |
The direction the motor spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration. |
distancia |
The distance the motor spins. Degrees use integers. Turns can use integers or decimals. |
unidad |
The distance unit: degrees or turns. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Raise and lower the ArmMotor.]
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
esperar [1] segundos
girar [ArmMotor v] [abajo v] por [180] [grados v] ▶
motor de giro para posicionar#
The spin motor to position stack block spins a motor to a specific position.
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the motor position is set to 0 degrees. The motor position can also be set using the set motor position block.
Position values are absolute. This means the direction of the spin depends on the motor’s current position.
girar [ArmMotor v] a la posición (90) [grados v] ▶
Parámetros |
Descripción |
|---|---|
motor |
The motor to spin. Choose from the motors configured in the Devices window. |
posición |
The position value the motor will spin to. Degrees use integers. Turns can use integers or decimals. |
unidad |
The position unit: degrees or turns. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Return ArmMotor to 0 degrees after raising.]
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
esperar [1] segundos
girar [ArmMotor v] a la posición [0] [grados v] ▶
detener el motor#
The stop motor stack block stops a motor from spinning.
parada [ArmMotor v]
Parámetros |
Descripción |
|---|---|
motor |
The motor to stop. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Raise the ArmMotor.]
girar [ArmMotor v] [arriba v]
esperar [1] segundos
parada [ArmMotor v]
Ajustes#
establecer la posición del motor#
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The set motor position stack block changes the motor’s current position to a new value.
For example, if a motor has spun to 180 degrees, setting the position to 0 degrees will reset that position from 180 to 0 degrees. Then the motor can spin to positions based on that new value.
Establezca la posición [ArmMotor v] en (0) [grados v]
Parámetros |
Descripción |
|---|---|
motor |
The motor to set the position for. Choose from the motors configured in the Devices window. |
posición |
The position value to set for the motor. Degrees use integers. Turns can use integers or decimals. |
unidad |
The position unit: degrees or turns. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Return ArmMotor to 0 degrees after raising.]
Establezca la posición [ArmMotor v] en [0] [grados v]
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
esperar [1] segundos
girar [ArmMotor v] a la posición [0] [grados v] ▶
establecer la velocidad del motor#
The set motor velocity stack block tells a motor how fast to spin. A higher percentage makes the motor spin faster and a lower percentage makes the motor spin slower.
Every project begins with each motor spinning at 50% velocity by default.
Note: A higher velocity makes the motor spin faster, but it may be less precise. A lower velocity makes the motor spin slower, but it can be more precise.
set [ArmMotor v] velocity to [50] %
Parámetros |
Descripción |
|---|---|
motor |
The motor to set the velocity for. Choose from the motors configured in the Devices window. |
velocidad |
The velocity to spin with from 0% to 100%. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Move the ArmMotor at different velocities.]
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
esperar [1] segundos
[Move slow.]
set [ArmMotor v] velocity to [20] %
girar [ArmMotor v] [abajo v] por [180] [grados v] ▶
esperar [1] segundos
[Move fast.]
set [ArmMotor v] velocity to [100] %
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
configurar la parada del motor#
The set motor stopping stack block sets how a motor will stop moving: by braking, coasting, or holding.
establecer [ArmMotor v] deteniéndose en [freno v]
Parámetros |
Descripción |
|---|---|
motor |
The motor to set the stopping behavior for. Choose from the motors configured in the Devices window. |
comportamiento de detención |
How the motor will stop:
|
For example, if a Competition Advanced 2.0 build is used and ArmMotor is set to hold, the motor will hold the arm at its current position until another arm movement happens. This means the motor will work against gravity to keep the arm in the air if the motor was stopped with the arm raised.
If this block is not used, the motor will use brake when stopping.
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Move the ArmMotor, then coast to a stop.]
set [ArmMotor v] velocity to [20] %
establecer [ArmMotor v] deteniéndose en [libre v]
girar [ArmMotor v] [arriba v]
esperar [1] segundos
parada [ArmMotor v]
establecer el par máximo del motor#
Torque is a turning force. It shows how hard a motor can push or pull when it spins.
The set motor max torque stack block sets the most torque a motor is allowed to use.
A higher percentage lets the motor push harder, like when lifting a heavy object. A lower percentage limits how hard the motor can push. This can help protect the robot if the motor gets stuck or reaches the end of how far it can move.
Every project begins with each motor’s torque at 50% by default.
set [ArmMotor v] max torque to (50)%
Parámetros |
Descripción |
|---|---|
motor |
The motor to set the max torque for. Choose from the motors configured in the Devices window. |
esfuerzo de torsión |
The max torque the motor can use from 0% to 100%. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Move the ArmMotor at different torques.]
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
esperar [1] segundos
[Move with less torque.]
Establezca el par [ArmMotor v] en [20]%
girar [ArmMotor v] [abajo v] por [180] [grados v] ▶
esperar [1] segundos
[Move with maximum torque.]
Establezca el par [ArmMotor v] en [100]%
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
establecer el tiempo de espera del motor#
The set motor timeout stack block sets how many seconds a motor will try to finish a movement. If the motor cannot finish in that time, it will stop trying and move on to the next block in the stack. This keeps the motor from getting stuck on a movement.
Establezca el tiempo de espera [ArmMotor v] en (1) segundo
Parámetros |
Descripción |
|---|---|
motor |
The motor to set the timeout for. Choose from the motors configured in the Devices window. |
tiempo |
The number of seconds the motor can try to finish a movement. This can be a whole number or a decimal. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Move ArmMotor as far as possible for 1 second before resetting.]
Establezca la posición [ArmMotor v] en [0] [grados v]
Establezca el tiempo de espera [ArmMotor v] en [1] segundo
girar [ArmMotor v] [arriba v] por [180] [grados v] ▶
girar [ArmMotor v] a la posición [0] [grados v] ▶
Valores#
¿El motor está listo?#
The motor is done Boolean block reports whether the motor is finished moving. This can be used to control the timing of other behaviors based on the motor’s movement.
True — The motor is finished moving.
False — The motor is still moving.
This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[ArmMotor v] ¿está hecho?>
Parámetros |
Descripción |
|---|---|
motor |
The motor to report whether it is finished moving. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Turn the Eye Sensor's light on while ArmMotor is moving.]
girar [ArmMotor v] [arriba v] por [180] [grados v] ◀ y no esperes
esperar [0.1] segundos
para siempre
si <[ArmMotor v] ¿está hecho?> entonces
establecer luz de ojo [apagado v]
demás
establecer luz de ojo [encendido v]
¿El motor está girando?#
The motor is spinning? Boolean block reports whether the motor is spinning. This can be used to control the timing of other behaviors based on the motor’s movement.
True — The motor is spinning.
False — The motor is not spinning.
This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[ArmMotor v] esta girando?>
Parámetros |
Descripción |
|---|---|
motor |
The motor to report whether it is spinning. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Turn the Eye Sensor's light on while ArmMotor is moving.]
girar [ArmMotor v] [arriba v] por [180] [grados v] ◀ y no esperes
esperar [0.1] segundos
para siempre
si <[ArmMotor v] esta girando?> entonces
establecer luz de ojo [encendido v]
demás
establecer luz de ojo [apagado v]
posición del motor#
A motor’s position is how far it has spun, measured in degrees or turns. The motor position reporter block reports the motor’s current position.
At the beginning of a project, the motor position is set to 0 degrees. If the motor spins one full turn forward, the position will be 360 degrees or 1 turn. If the motor spins the other direction, the position will be negative.
([ArmMotor v] posición en [grados v] :: custom-motion)
Parámetros |
Descripción |
|---|---|
motor |
The motor to report the position of. Choose from the motors configured in the Devices window. |
unidad |
The unit to report the motor position in: degrees or turns. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Display how far the ArmMotor moves after one second.]
Establezca la posición [ArmMotor v] en [0] [grados v]
imprimir [Start: ] ▶
imprimir ([ArmMotor v] posición en [grados v] :: custom-motion) ▶
colocar el cursor en la siguiente fila
girar [ArmMotor v] [arriba v]
esperar [1] segundos
parada [ArmMotor v]
imprimir [After: ] ▶
imprimir ([ArmMotor v] posición en [grados v] :: custom-motion) ▶
velocidad del motor#
The motor velocity reporter block reports how fast the motor is spinning, as a percentage from -100% to 100%.
A positive value means the motor is spinning forward. A negative value means the motor is spinning in reverse.
([ArmMotor v] velocidad en %)
Parámetros |
Descripción |
|---|---|
motor |
The motor to report the velocity of. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Display the ArmMotor's velocity when it moves.]
imprimir [Resting: ] ▶
imprimir ([ArmMotor v] velocidad en %) ▶
colocar el cursor en la siguiente fila
girar [ArmMotor v] [arriba v]
esperar [1] segundos
imprimir [Moving: ] ▶
imprimir ([ArmMotor v] velocidad en %) ▶
parada [ArmMotor v]
corriente del motor#
The motor current reporter block reports how much power the motor is using from the battery, as a percentage from 0% to 100%.
A higher current value means the motor is using more power. This can happen when the motor is lifting something heavy, pushing against an object, or trying to move when it is stuck.
([ArmMotor v] corriente en %)
Parámetros |
Descripción |
|---|---|
motor |
The motor to report the current of. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó :: hat events
[Build Used: Competition Advanced 2.0]
[Display the motor's current when it moves.]
imprimir [Resting: ] ▶
imprimir ([ArmMotor v] corriente en %) ▶
colocar el cursor en la siguiente fila
girar [ArmMotor v] [arriba v]
esperar [1] segundos
imprimir [Moving: ] ▶
imprimir ([ArmMotor v] corriente en %) ▶
parada [ArmMotor v]