Jerky wheels with DifferentialDrive in autonomous

I recently got involved with mentoring a team. We recently ran into an issue programming our autonomous that I’d like to get some direction on. I haven’t been able to find much about this online and I’m still new to programming robots so I’d like to expand my own knowledge as well.

We were creating a new DifferentialDrive object and using it’s convenience .arcadeDrive() method for driving during teleop, which has been working great. The past few days we’ve been working on our autonomous, but haven’t been able to get the wheels to move smoothly in autonomous. They would jerk and almost oscillate back in forth when running the simplest of commands in autonomous. However switching to teleop, they would move smoothly and as expected.

We tried calling DifferentialDrive.arcadeDrive() with small values and got this error. We tried calling .set() on the individual WPI_TalonFX motors but would still see jerky wheels. We eventually found that our issue was creating a new DifferentialDrive object via drive = new DifferentialDrive(leftMotorControlGroup, rightMotorControlGroup). Commenting out this code and changing how we did arcade drive fixed this issue for us.

We’re able to make progress now, but I’d like to try to understand the why this was happening. We were also seeing this issue: ERROR  1  DifferentialDrive... Output not updated often enough. We weren’t sure if this was related/if we should set motor safety to false to resolve this.

Any information/leads would be greatly appreciated!

If you create a DifferentialDrive, it wants to be in control of the motors. It wants you to call for example arcadeDrive. If you instead directly call the ‘set’ method of the motor, the DifferentialDrive panics because it wasn’t called and stops the motors, issuing the “Output not updated” error.
You need to call the DifferentialDrive feed() method when you directly set the motors to tell the diff drive that everything is fine.

1 Like

Alternatively, you could disable the motor safety setting of the diff drive, but it’s there for a reason, so better play along and tell the diff drive via feed() that all is fine, you just happen to run the motors by circumventing the diff drive in autonomous.

When does this print?

This was super informative, thank you so much. Is there a part of the docs that I may have missed that talks more about this? I wasn’t able to find anything in the javadocs or wpilib docs, though I may have missed it.

This was printing in the driver station console when we’d enable in autonomous

Man I thought you built a wheel out of jerky.

…I think I need to leave the shop and find dinner.

Also, make sure you only have a single DiffDrive object - you can create it once and use the same instance for any mode - auto or teleop.

Not sure if the need to either call one of the xxxdrive() methods or feed() is specifically documented, but the issue is mentioned several times on this forum. Even one of the trajectory examples had this problem,
Bug or misunderstanding in Trajectory tutorial and Ramsete example? - #11 by ksquare and it was then fixed by calling feed(), https://github.com/wpilibsuite/allwpilib/pull/2298

Hmmm, I would expect the documentation to have something about any of this. Not needing to search through forums to find out more about what the code is doing.

Thanks for the links, looks like I managed to look at all the wrong posts when I first searched for this issue on here.

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