Tank Drive - Joystick Control

From FRC11 - Mentor Wiki
Revision as of 14:31, 27 January 2019 by Dsteinmark (talk | contribs)
Jump to navigation Jump to search

In tank drive, one or two joysticks can be used, but typically two joysticks are used - one joystick is use to control the left half of the drivetrain, and the other joystick is used to control the other half. Only forward and backwards motions of the joystick are used for affecting the drivetrain.

There are a few different control mappings to affect how a certain amount of joystick movement is needed to change the requested speed of the drivetrain:

  • Linear The simplest and most straightforward of the control mappings.
  • Quadratic Designed to give much finer control over slow movements.
  • Linear/Quadratic Average An averaging of linear and quadratic.
  • S-Curve Finer control than linear in first half of travel, faster control than linear in second half.

The equations given are of the form y = f(x), where x is the joystick position, and y is the output value. As most of these equations are not symmetric through the Origin, the expected input is from 0 to 1 (inclusive), and will not work directly for negative (reversing) input.

In order to accomodate negative values, absolute values will need to be used in most cases (except linear). These functions should take the following form.

if (x < 0)
   x1 = abs(x);
   y1 = f(x1);
   y = -1 * x1
end if;

or condensed to

if (x < 0)
   y = -1 * f(abs(x));
end if;


Linear

The simplest and most straightforward of the control mappings.

y = x
  • Advantages: Simple, linear response, easy to program, easy to drive
  • Disadvantages: Does not give fine control for slow movements

Quadratic

Designed to give much finer control over slow movements.

y = x2
  • Advantages: Gives very fine control over slow movements
  • Disadvantages: Drivers have complained that it feels too dead and sluggish when getting started.

Image: Comparison of Linear, Quadratic, and Linear Quadratic Average

Linear/Quadratic Average

An averaging of linear and quadratic.

y = (x2 + x) / 2
  • Advantages: Gives finer control over slow movements than linear, without feeling dead like quadratic. (At least in theory.)
  • Disadvantages: Overall slower feeling compared to linear

S-Curve

Finer control than linear in first half of travel, faster control than linear in second half.

For x <= 0.5
y = ((2x2) + x) / 2
For x > 0.5
y = 1 - ((2(x-1.5)2) + (x-1.5)) / 2
  • Advantages: Gives finer control for slow movements, without feeling dead like quadratic. Gives faster control than linear in second half. Feels zippy when past about 1/3 or 1/2 travel.
  • Disadvantages: Does not feel linear. Could be an issue in feel for driver. They may love it. They may hate it.

Image: S-Curve Mapping