DifferentialDrive trouble

So this weekend we had our first competition and to say it went bad would be an understatement. Mechanically the robot works very well, but the code that we had was not working. We use differential drive for our drivetrain and we were having an issue where after we shoot the drive train would only accept input from one joystick at a time, making it impossible to go forward. The code that we used was also written the morning of competition because we had too much trouble with our main code. I’m hoping for any information/help because I can’t find any.

Without showing your code, (preferably to a service like Github), you won’t be able to get a lot of help.

2 Likes

^^ seconding @maccopacco.
How did you determine that it was the joystick that wasn’t being accepted, vs the motor not being driven?

There isn’t any information shared that would allow us to help you. We need code. It could be that a command isn’t getting canceled, it could be that a while loop is not exiting. If you share your code, we will be happy to help you.

Did you ask for help from the CSA at your event?

Yes, they didn’t really help much.

I can post the code later, I don’t have It on github because it’s literally just garbage code that I wrote in 30 minutes with a bunch of if else statements.

We can help you with your original code if you like.

Here’s a link to a mostly recent version github.com/Gh0strab/FRC7621-2020
We changed a bunch of stuff but if anything stands out please let me know. We fixed the OI and we are no longer doing paths in autonomous due to time constraints

Some quick things I see missing:

  1. DriveTrain.java doesn’t set a default command. You at least want to have your robot driving with the joysticks as the default command for the drivetrain. Not sure whether it was supposed to be drive, or DriveTank, but one should be the default.

  2. Your command that you should have as your default command doesn’t ever actually drive the robot in it’s execute() method. So, from whichever the default command is to get driving you need to call Robot.m_drivetrain.drive() in the scheduler loop.

  3. You lost your scheduler instance running the scheduler. So you should add the following to your robot.java:

@Override
public void robotPeriodic(){
    Scheduler.getInstance().run();
} 

Getting to that point should at least have you being able to teleop drive your robot with the controller.

A secondary point for you is that given your joystick control is using the Left Y axis and the right X axis, I would recommend just using the arcadeDrive() method from your differential drive. So your arcadeDrive() would be a pass through to the differential drive method, OR just change your drive method to m_drivetrain.arcadeDrive(left, right);

1 Like

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