Drive Train not updating

Hi everyone, new programmer from 7193 here. My robot seems to have a stuttering issue when driving. The Rio log says that the Differential Drive is not being updated fast enough and I am having trouble finding the source of the issue.

The GitHub link for my team’s practice robot is https://github.com/mariotumasionis/PracticeBot-2019

PS: Any tips or tricks for GitHub would be amazing as I’m very new to the platform.

1 Like

Does it always happen? 857 had that issue show up sporadically but we were never able to pin down the issue.

Had the same issue last year, I see that you’re using the WPI_TalonSRX and WPI_VictorSPX, they’re a wrapper around the base TalonSRX and VictorSPX with the added motor safety functionality. This means that there’s something in your code that’s taking too long to update and is running longer than the cycle rate and the motor safety kicks in and disables the motors until you set the power to it again which causes jittery driving. This can also be because wife network issues. One way to solve this is to disable motor safety which is kind of frowned upon but it will fix it, at least it helped me solve the problem.

Inside your Drivtrain constructor you can just put:

drive.setSafetyEnabled(false);

And same for the motors:

talon.setSafetyEnabled(false);

Could you post a screenshot of the log? Here’s some info about it:
https://wpilib.screenstepslive.com/s/currentCS/m/driver_station/l/144980-driver-station-log-file-viewer

This issue only surfaced when I added a toggle button into Robot.java to toggle a solenoid for the robot’s transmission

Are you using the latest RIO image? V14 fixed an issue like this.

1 Like

In your Robot.java file, you are polling your buttons in your teleopPeriodic() loop in order to control your pneumatics. I think this is causing your issues. Is there any reason why you don’t declare buttons and have them call commands in your OI.java?

2 Likes

Whoops! Sniped by @jdao.
Interesting. I noticed that you added a toggle with this block of code:


In command-based robot program architecture, people often use the button class. Take a look here for more information: https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599739-running-commands-on-joystick-input
I would write this button differently in your OI file:
private static Button aButton = new JoystickButton(oi.driver, 1);

aButton.whenPressed(new InstantCommand(() -> { belt = !belt; Robot.PneumaticSubsystem.transmission.set(Value.kForward); }));

Also, be careful with this part of your OI file because those joystick values are only updated when the OI is initialized. You could write this instead to have them update whenever they are called:
public DoubleSupplier leftX = () -> driver.getRawAxis(0);
public DoubleSupplier leftY = () -> driver.getRawAxis(1);
public DoubleSupplier rightX = () -> driver.getRawAxis(4);
public DoubleSupplier rightY = () -> driver.getRawAxis(5);
public DoubleSupplier leftTrigger = () -> driver.getRawAxis(2);
public DoubleSupplier rightTrigger = () -> driver.getRawAxis(3);

Also, for some basic GitHub reading, I would recommend this guide for an overview and GitHub Desktop as a git client. Here’s how to get started with it. It plays well with Visual Studio Code, too.

I didn’t assign any buttons to a Transmission command because I couldn’t figure out how to have the command toggle with the button. I know it has something to do with toggleWhenPressed method, however I have yet to figure out a way to implement it. With a week break, I’m ready to come back to this full force

The issue has been resolved by eliminating all unnecessary imports and variables that are constantly called in my periodic code. Don’t know how, but it’s now stutter free.

“It’s voodoo” - Tim Wheeler from Automation Direct

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