Arcs
Turning on the spot means stopping. An arc changes direction on the move: it rounds corners and takes the robot along a smooth path.
Two ways to describe an arc
By the ratio of wheel speeds. This is how moveArcDist(),
moveArcTime() and motorsArc() work. The angle parameter, from −90 to
90, sets how sharp the arc is: the left wheel gets power × (1 + angle / 90), the right one
power × (1 − angle / 90).
| angle | Left wheel | Right wheel | What the robot does |
|---|---|---|---|
| 0 | × 1 | × 1 | Drives straight |
| 30 | × 1.33 | × 0.67 | Gentle arc to the right |
| 45 | × 1.5 | × 0.5 | Sharp arc to the right |
| 90 | × 2 | 0 | Pivots around the right wheel |
| -30 | × 0.67 | × 1.33 | Gentle arc to the left |
By geometry. moveArcRadius() takes the arc radius at the robot's centre and
the angle of the sector.
Both describe the same thing: angle = 90 × (track / 2) / radius. With the standard 107 mm track, angle = 30 corresponds to a radius of about 160 mm.
Steps
-
Round the corners of the square
for (int i = 0; i < 4; i++) { robot.moveDist(50, 250); robot.moveArcRadius(50, 100, 90); // a quarter circle of radius 100 mm }Four 250 mm straights and four arcs of 100 mm radius: the robot goes round a 45 × 45 cm square and comes back to the start. Instead of turning on the spot, the robot takes the corner along a quarter circle.
-
Drive a slalom
for (int i = 0; i < 3; i++) { robot.moveArcDist(50, 30, 250); // arc to the right robot.moveArcDist(50, -30, 250); // arc to the left }The snake drifts diagonally: three pairs of arcs take the robot about 95 cm forward and as far to the right, and it ends up facing the way it started. Clear about a metre by a metre of floor. The third number is the arc length at the robot's centre in millimetres. At
angle = 30a 250 mm arc is roughly a quarter circle. -
Steer an arc by hand
robot.motorsArc(40, 20); // follows the arc until it is stopped delay(2000); robot.stop(SOFT);motorsArc()has no target: the robot follows the arc untilstop()is called.SOFTstops without locking the wheels,HARDbrakes.
Finished sketches: and . The code is on the Examples page.
Try changing it
- Compare radii of 60, 150 and 300 mm in
moveArcRadius(). - Drive a full circle:
robot.moveArcRadius(50, 150, 360), then the same to the left with an angle of-360— that makes a figure of eight. - Give
moveArcDist()anangleabove 90 and watch what the inner wheel does.
If it does not work
moveArcRadius()does nothing. The radius must be at least half the track — 53 mm — and the angle must not be zero. To turn on the spot userotate().- The arc has the wrong curvature. Curvature depends on the track: check that the wheels do not slip — see the FAQ.