## Introduction: ☠WEEDINATOR☠ Part 4: Differential Steering Geometry Code

If you have the time to watch the above video, you'll notice that there are some strange noises caused by the motors on the steering stalling every now and again as the WEEDINATOR navigates a 3 point turn. The motors are essentially jamming against each other as the radius of turn is different on the inside to the outside and the distance the wheel travels is different per degree of turn.

The geometry of the turn can be worked out by sketching out 8 or so permutations of the turn, giving examples of turning at different angles on the inner wheel from 0 (no turn) to 90 (full lock) degrees. Sounds complicated?

Most small wheeled robots don't attempt to have any kind of sophisticated steering and rely, very effectively, on simply changing the relative speed of the motors on each side of the vehicle, which is pretty much the same as how a tracked digger or tank works. This is great if you're charging over a crater filled war zone shooting at everything that moves, but in a tranquil agricultural environment it's important to do as little damage to the soil and ground as possible so grinding wheels back and forwards against each other is not appropriate!

Most cars and tractors have a very useful gadget called a 'Differential', except the cars you see in old American movies where you can hear the tyres screeching like crazy every time they go round a corner. Do Americans still build cars like this? With the WEEDINATOR, we can program differential into the drive motors by working out the formula for the relative speeds and angles of the wheels at any particular angle of turn. Still sounds complicated?

Here's a quick example:

If the WEEDINATOR is navigating a turn and has it's inside wheel at 45 degrees, the outside wheel is NOT 45 degrees, it's more like 30 degrees. Also, the inside wheel may be turning at 1 km/hour, but the outside wheel will be significantly faster, more like 1.35 km/hour.

## Step 1: Geometry Setup

A few basic assumptions are made to begin with:

- The chassis will pivot about one of the back wheels as shown in the diagram above.
- The effective centre of the pivot circle will move along a line extended from the centres of the two back wheels, depending on the angle of turn.
- The geometry will take the form of a sine curve.

## Step 2: Scaled Drawings of Wheel Angles and Radii

A full scale drawing was made of the WEEDINATOR front wheels and chassis with 8 different permutations of inside wheel angle between 0 and 90 degrees and the respective turn centres were mapped out as shown in the drawings above.

The effective radii were measured from the drawing and plotted on a graph in Microsoft Excel.

Two graphs were produced, one of the ratio of the left and right front wheel axles and another for the ratio of the two radii for each particular turn angle.

I then 'fudged' up some formulae to mimic the empirical results based on a sine curve. One of the fudgings looks like this:

speedRatio= (sin(inner*1.65*pi/180)+2.7)/2.7; // inner is the inner turn angle.

The curves were fudged by changing the values shown in red in the excel file until the curves fitted together.

## Step 3: Coding the Formulae

Rather than trying to code the formulae in one line, they were broken down into 3 stages to allow the Arduino to process the math properly.

The results are shown in the serial port display and checked with the measured results on the scale drawing.

## Share

## Recommendations

We have a **be nice** policy.

Please be positive and constructive.

## 4 Comments

Yep, exactly how I would do it, but my coding would probably be a kludge. Lol it's not my strong point. I can build it, but never have been a great coder.

You can use my code!

Very impressive, nice documentation too... Now to implement in the robot a sense of self-awareness so that he knows where his wheels are and avoids driving over "important" plants

Thanks ! Just waiting for a motor upgrade to arrive tomorrow to test it all out in real life.