Robot Moving for no Reasons

When we are driving our robots, everything works well. However, sometimes the robot would slowly rock itself forward even when we are not touching the joystick. What is the problem?

This is a problem with most joysticks. Since the joystick is not always at 0 (somtimes it at 1 or 5 or maybe even 10), the motors will be given a little bit of power.
To fix this what you do is create a deadzone.
Assuming you are using VexCode this is what it would look like.

int x = Controller1.Axis2.position(percent);
if(fabs(x)<10){
  x=0;
}
FrontMotor.spin(forward, x, percent);

This code will get the value from the controller, and if it is between -10 and 10, it becomes equal to 0.

For example, if the joystick is at -7 the motors will be set to 0.

2 Likes

Would this also work?

if(abs(Controller1.Axis3.value())>15){}

You’ll also want to calibrate the joysticks in the joystick menu.

2 Likes

Yes, but needs an else that sets motors to stop.

if (outside deadzone){ listen to joysticks } else{ stop motors }

4 Likes