Autonomous Driving

We’ve been having problems with our autonomous. The robot drives just fine in teleop, but doesn’t when we run it in autonomous. It will give us the error ERROR  1  DifferentialDrive… Output not updated often enough. How can I fix this?

1 Like

Can you Give us some more information? can we see your code or at least the autonomous portion of it?

Try using differentialDrive.feed() during the auto driving. This tells the drive it is being updated.

4 Likes

For us, if we have an if statement that can return negative and not update the drivetrain, this can happen easily. Beyond that, a loop can do it too.

2-17-22.zip (93.2 MB)

Which auton command are you running when you get the error?

We are trying to run auto_Routine_2.

If all else fails, write a one-file simple program. Start with one motor, run it at a fixed speed like 0.1 in teleop, and -0.1 in autonomous. Run it in autonomous or as a practice match from the Drivers Station. Get it to work. Start adding drive code a little at a time ‘till it fails, and work on that.

I ran your code in the simulator and noticed that the drivetrain subsystem (that was put to SmartDashboard) was either running the TankDrive command or no command in autonomous, depending on whether I was in telop or disabled before starting autonomous. In order to investigate further, I put the scheduler to SmartDashboard so I could see all commands and saw that when teleop was run before auton, both TankDrive and auto_Routine_2 were running, which shouldn’t happen because both require the Drivetrain class. I then noticed you have two copies of the Drivetrain class one called m_drivetrain and one called driveTrain. m_drivetrain was the requirement for TankDrive command in teleop and driveTrain was the requirement for auto_Routine_2 in autonomous

  public static final Shoot_Motor shoot_Motor = new Shoot_Motor();
  private final DriveTrain m_drivetrain = new DriveTrain();
  private final Intake_Motor m_intake_motor = new Intake_Motor();
  private final Feeder_Motor m_feeder_motor = new Feeder_Motor();
  private final Pneumatics pneumatics = new Pneumatics();
  private final DriveTrain driveTrain = new DriveTrain();
  private final Adjust_Motor m_adjust_motor = new Adjust_Motor();

Since you had two copies of the DifferentialDrive, but were only calling one in auto, the other instance was stopping the drivetrain since it wasn’t being called. That is what was printing the error message. If you get rid of the duplicate Drivetrain instances and fix everything to use the one instance, I think your problem will go away.

Other things I noticed:

In the Drivetrain class, you’re creating two objects for each TalonFx, one that is the TalonFX class, and one that’s WPI_TalonFX (in the motor controller group). I’m not sure how CTRE’s library handles this, but it may cause some issues. It would be better to create WPITalonFX objects and then pass them to MotorControllerGoup.

Per team update 2, you need to use image 2022_v4.0 which will require that you upgrade to WPILib 2022.3.1 (you’re using 2022.2.1 currently)

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