Jerk in motor every second or so

Hi,

We have done a very simple command base mecanum drive and it works except that the motors jerk once in every seconds or so. In the past, we used to put a thread.sleep for the iterative robot. Is that the same for a command base one?

Our code can be found here.

Thanks for any help

Team 7116

Nooo! Don’t ever use a Thread.sleep. It will block your program from running. Command based is built on the TimedRobot framework which automatically runs every 20ms.

1 Like

20ms; 50hz.

Whoops. Guess I was thinking of Minecraft.:slight_smile:

1 Like

Not sure if this is the source of your problem, but this bit from DrivingSubsystem.drive does not look quite right:

    if(Math.abs(yAxisLeft)<MIN_CONTROLLER_SPEED){
      xAxisLeft = 0;
    }

Also, I would recommend using the wpilib MecanumDrive class rather than trying to role your own (see https://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/drive/MecanumDrive.html).

Hope this helps,
Steve

This is a dead band for the joystick, but you might be right. I’ll give it a try tomorrow.

I’ll try the mecanum drive class also.

Thanks

I think what Waz was pointing out is that in the deadband test you check yAxisLeft but set xAxisLeft. That might be alright but it looks suspicious to someone not familiar in detail with your code.

Yes, that was it.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.