ARC Turn

ARC turn is used when you want the robot to make a smooth turn following a circular path. The circular path may be quicker than following a path with square corners or a polygon path made of straight lines and angles. if not quicker it at least looks cooler.

In order to make this turn we tell the robot the radius of the circle rd and the fraction of the arc we want to turn which we will quantify by degrees 0 to 360 for a right turn and 0 to -360 for a left turn.

The code also needs to know the characteristics of the robot. The wheel Diameter D, the gear ratio between the motor and the wheel. G, and the width of the drivebase W. Since we are using encoders within the motor we also need to be sure to set the internal gear ratio of the motors Red 1:36, Green 1:18 or Blue 1:6

To make an arc turn we calculate the distance of the outside wheel path and the ratio of speed between the two sides of the drive. for a circle radius of rd the distance of the arc turn is 2pird*angle/360

$$ targetArcLength=rd2pi*angle/360 $$

We make this the distance the outside the outside of the robot will turn and use our standard inchDrive function to implement it.

To make the robot turn the inside wheels must roll slower than the outside wheels the ratio of the speed is based on the width of the drive base. For a right turn:

$$ rspeed=lspeed*(rd-W)/rd $$

The length that the robot has travelled is calculated from the encoder measurements. At the starte we reset the encoder position to zero. Read the position of the encoder in revolutions =rev

$$ length=revGpi*D $$

InchDrive Process

We develop this first by making a right turn:

Call the arcTurn function with rd and angle. Calculate targetArcLength using equation 1.

  1. Calculate or set lspeed (for simplicity we can start with lspeed as a constant, later we will add PID)
  2. Calculate rspeed using equation 2
  3. Move the robot a little using our standard drive function
  4. read encoder on left drive motor and calculate length traveled and compare to targetArcLength
  5. if not at targetArcLength then repeat from step 1.