pxt-ev3/docs/reference/motors/synced/steer.md
Galen Nickel 88c58b4e76 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
2018-02-06 19:43:50 -08:00

3.6 KiB

steer

Steer the brick in one direction using a turn ratio between two motors.

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 shows how to use different movement units.

Parameters

  • turnRatio: a 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 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 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:

motors.largeBC.steer(-15, -75)

~

Examples

Make a slight right

Turn to the right with a turn ratio of 10%.

motors.largeBC.steer(10, 55)

Make a sharp left

Turn sharply to the left.

motors.largeBC.steer(-80, 40)

Steer straight

Use steer but go straight ahead.

motors.largeBC.steer(0, 100)

Sneaky snake

Steer the brick in a snake pattern for a short time.

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, set speed