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× 1Drives straight
30× 1.33× 0.67Gentle arc to the right
45× 1.5× 0.5Sharp arc to the right
90× 20Pivots around the right wheel
-30× 0.67× 1.33Gentle arc to the left

By geometry. moveArcRadius() takes the arc radius at the robot's centre and the angle of the sector.

angleRcentre of turnstartfinish
moveArcRadius(50, R, 90): the robot's centre follows an arc of radius R, the wheels follow the inner and outer tracks. A positive angle is an arc to the right.

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

  1. 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
    }
    R 100250 mmstart
    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.

  2. 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
    }
    R ≈ 160 mmrightleft≈ 95 cm≈ 95 cmstartfinish
    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 = 30 a 250 mm arc is roughly a quarter circle.

  3. 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 until stop() is called. SOFT stops without locking the wheels, HARD brakes.

Finished sketches: File › Examples › UNI › Arcs and ManualControl. 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() an angle above 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 use rotate().
  • The arc has the wrong curvature. Curvature depends on the track: check that the wheels do not slip — see the FAQ.