The analog sticks on the Logitech joysticks used in the FTC competition don’t always reset to a perfect zero when released.  There is a decent range in how far off from zero different joysticks may be due to tolerances in the manufacturing process, but most seen to be off by between 5 and 15.
This can be a challenge if you map the value of the analog stick position to a motor such as those on your drivetrain.  Few things are more embarrassing than your robot slowing spinning in a circle on the field when you’re not driving it.


The deadzone pattern solves this issue by checking the value from the analog stick against a predefined threshold and treating anything within the threshold to be zero.
A deadzone can be applied inline, when setting output, or as part of a scaling function.

Pattern Template

If absolute value of X is less than threshold T, then X => 0.


Example setting output:

const int DEADZONE = 15;
if(abs(joystick.joy1_y1) >= DEADZONE)
  motor[someDriveMotor] = joystick.joy1_y1;
  motor[someDriveMotor] = 0;

Example using a function:

int deadzoneFilter(int joystickValue)
  const int DEADZONE = 15;
  if(abs(joystickValue) < DEADZONE) 
    return 0;
  return joystickValue;
motor[someDriveMotor] = deadzoneFilter(joystick.joy1_y1);

*Note that the examples above are incomplete for use as a solid drivetrain control.  The deadzone pattern is typically combined with a scaling function to create a proper control system for the FTC motors.

Related Patterns


Submitted by:   Green Army Robotics

–>  Back to list of FTC Design Patterns

Print This Post Print This Post

Comments are closed.