First set of 'motors' topics (#305)
* Start of 'motors' topics * Draft the 'motor motion' side doc * Add / update more topics * Last blast of edits * Capture some more edits * Put in movement and steering details
This commit is contained in:
committed by
Peli de Halleux
parent
e2eb5f35af
commit
88c58b4e76
84
docs/reference/motors/synced/steer.md
Normal file
84
docs/reference/motors/synced/steer.md
Normal file
@ -0,0 +1,84 @@
|
||||
# steer
|
||||
|
||||
Steer the brick in one direction using a turn ratio between two motors.
|
||||
|
||||
```sig
|
||||
motors.largeAB.steer(0, 0)
|
||||
```
|
||||
|
||||
A brick driving with two motors can steer itself by changing the speed of one motor compared to the speed of the other. To make a slow turn to the left, you might make the right motor run slightly faster than the left one. To make a fast, or sharp, turn to the right, the left motor could run at least twice as fast as the right one.
|
||||
|
||||
The @boardname@ steers by using a percentage value of _follow_ for one of the motors. This means that the motor in the turn direction will rotate slower than the other. It is the _follower_ motor and the other motor is the _drive_ motor. The drive motor runs at a percentage of full speed set in **speed**. The follower motor runs at a percentage of speed of the drive motor. So, it runs at a percentage of a percentage of full speed.
|
||||
|
||||
To make the turn happen you give a _turn ratio_ which is a percentage value of steer to the left or right. If you want to steer to the left at 30% of the of the drive motor speed, use the value of `-30` for **turnRatio**. Left turns use negative values and right turns use positive values. A really sharp turn to the right might use a turn ratio value of `80`.
|
||||
|
||||
## Speed and distance
|
||||
|
||||
The speed setting is a pecentage of the motor's full speed. Full speed is the speed that the motors run when the brick supplies maximum output voltage to the port.
|
||||
|
||||
If you use just the **speed** number, the motors run continously and won't stop unless you tell them to. You can also give a value for a certain amount of distance you want the motors to rotate for. The **value** can be an amount of time, a turn angle in degrees, or a number of full rotations.
|
||||
|
||||
If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**. Also, if you use a number of milliseconds as movement units, then you don't need to include the unit type. The description in [set speed](/reference/motors/motor/set-speed) shows how to use different movement units.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **turnRatio**: a [number](/types/number) that is the percentage of speed of the drive motor. The follower motor runs at this speed. A negative number steers to the left and a positive number steers to the right. This is a number between `-100` and `100`.
|
||||
* **speed**: a [number](/types/number) that is the percentage of full speed. A negative value runs the motors in the reverse direction. This is the speed that the drive motor runs at.
|
||||
* **value**: the [number](/types/number) of movement units to rotate for. A value of `0` means run the motor continuously.
|
||||
* **unit**: the movement unit of rotation. This can be `milliseconds`, `seconds`, `degrees`, or `rotations`. If the number for **value** is `0`, this parameter isn't used.
|
||||
|
||||
## ~hint
|
||||
|
||||
** Reverse is negative speed**
|
||||
|
||||
Steering the brick backwards (in reverse) is simple. Reverse is just a negative speed setting. To steer the brick to the left in reverse at 75% speed:
|
||||
|
||||
```block
|
||||
motors.largeBC.steer(-15, -75)
|
||||
```
|
||||
|
||||
## ~
|
||||
|
||||
## Examples
|
||||
|
||||
### Make a slight right
|
||||
|
||||
Turn to the right with a turn ratio of 10%.
|
||||
|
||||
```block
|
||||
motors.largeBC.steer(10, 55)
|
||||
```
|
||||
|
||||
### Make a sharp left
|
||||
|
||||
Turn sharply to the left.
|
||||
|
||||
```block
|
||||
motors.largeBC.steer(-80, 40)
|
||||
```
|
||||
|
||||
### Steer straight
|
||||
|
||||
Use **steer** but go straight ahead.
|
||||
|
||||
```block
|
||||
motors.largeBC.steer(0, 100)
|
||||
```
|
||||
|
||||
### Sneaky snake
|
||||
|
||||
Steer the brick in a snake pattern for a short time.
|
||||
|
||||
```block
|
||||
for (let i = 0; i < 4; i++) {
|
||||
motors.largeBC.steer(30, 30)
|
||||
loops.pause(5000)
|
||||
motors.largeBC.steer(-30, 30)
|
||||
loops.pause(5000)
|
||||
}
|
||||
motors.stopAllMotors()
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[tank](/reference/motors/synced/tank), [set speed](/reference/motors/motor/set-speed)
|
81
docs/reference/motors/synced/tank.md
Normal file
81
docs/reference/motors/synced/tank.md
Normal file
@ -0,0 +1,81 @@
|
||||
# tank
|
||||
|
||||
Rotate two motors in synchronization.
|
||||
|
||||
```sig
|
||||
motors.largeAB.tank(50, 50)
|
||||
```
|
||||
|
||||
Tanking the brick will drive two motors in synchronization. This means that both motors will start at the same time. Also, each motor uses the same amount of rotation when running at the same speed. You can use different speed values for each motor to perform turns or spins.
|
||||
|
||||
## Speed and distance
|
||||
|
||||
The speed setting is a pecentage of the motor's full speed. Full speed is the speed that the motors run when the brick supplies maximum output voltage to the port.
|
||||
|
||||
If you use just the **speed** number, the motors run continously and won't stop unless you tell them to. You can also give a value for a certain amount of distance you want the motors to rotate for. The **value** can be an amount of time, a turn angle in degrees, or a number of full rotations.
|
||||
|
||||
If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**. Also, if you use a number of milliseconds as movement units, then you don't need to include the unit type. The description in [set speed](/reference/motors/motor/set-speed) shows how to use different movement units.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **speedLeft**: a [number](/types/number) that is the percentage of full speed for the motor attached to the left of the brick. A negative value runs the motor in the reverse direction.
|
||||
* **speedRight**: a [number](/types/number) that is the percentage of full speed for the motor attached to the right of the brick. A negative value runs the motor in the reverse direction.
|
||||
* **value**: the [number](/types/number) of movement units to rotate for. A value of `0` means run the motor continuously.
|
||||
* **unit**: the movement unit of rotation. This can be `milliseconds`, `seconds`, `degrees`, or `rotations`. If the number for **value** is `0`, this parameter isn't used.
|
||||
|
||||
## ~hint
|
||||
|
||||
** Reverse is negative speed**
|
||||
|
||||
Tankng the brick in the opposite direction (reverse) is simple. Reverse is just a negative speed setting. To drive the motors in reverse at 75% speed:
|
||||
|
||||
```block
|
||||
motors.largeBC.tank(-75, -75)
|
||||
```
|
||||
|
||||
## ~
|
||||
|
||||
## Examples
|
||||
|
||||
### Tank forward and backward
|
||||
|
||||
Move the brick straight ahead and then go backward.
|
||||
|
||||
```blocks
|
||||
motors.largeAB.tank(75, 75)
|
||||
loops.pause(10000)
|
||||
motors.largeAB.tank(-55, -55)
|
||||
loops.pause(10000)
|
||||
motors.stopAllMotors()
|
||||
```
|
||||
|
||||
### Slip steer
|
||||
|
||||
Run the right motor at 50% and let the left motor spin freely.
|
||||
|
||||
```blocks
|
||||
motors.largeAB.tank(0, 50)
|
||||
```
|
||||
|
||||
### Skid steer
|
||||
|
||||
Set the brake on the right motor. Run the left motor at 60% and let the right motor skid.
|
||||
|
||||
```blocks
|
||||
motors.largeB.setBrake(true)
|
||||
motors.largeAB.tank(60, 0)
|
||||
```
|
||||
|
||||
### Spin around
|
||||
|
||||
Run both motors in opposite directions to spin the brick around to the left.
|
||||
|
||||
```blocks
|
||||
motors.largeAB.tank(-30, 30)
|
||||
loops.pause(5000)
|
||||
motors.stopAllMotors()
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[steer](/reference/motors/synced/steer), [set speed](/reference/motors/motor/set-speed)
|
Reference in New Issue
Block a user