FRC Differential Drive Not Updating - Motor Safety

We are having issues with out drive train not working. We get the error “DifferentialDrive…Output no updated often enough.
Error at edu.wpi.first.wpilibj.MotorSafety.chec(MotorSafety.java:101)”

package frc.robot.subsystems.Drive;

import com.revrobotics.CANEncoder;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMax.IdleMode;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.wpilibj.SpeedControllerGroup;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
public class DriveSubsystem extends SubsystemBase {
/**

  • Creates a new DriveSubsystem.
    */
    public DriveSubsystem() {
    }
    public CANSparkMax frontLeft = new CANSparkMax(Constants.FRONT_LEFT_MOTOR_CAN, MotorType.kBrushless);
    public CANSparkMax frontRight = new CANSparkMax(Constants.FRONT_RIGHT_MOTOR_CAN, MotorType.kBrushless);
    public CANSparkMax backLeft = new CANSparkMax(Constants.BACK_LEFT_MOTOR_CAN, MotorType.kBrushless);
    public CANSparkMax backRight = new CANSparkMax(Constants.BACK_RIGHT_MOTOR_CAN, MotorType.kBrushless);
    // Declaring the motor groups
    public SpeedControllerGroup leftGroup = new SpeedControllerGroup(frontLeft, backLeft);
    public SpeedControllerGroup rightGroup = new SpeedControllerGroup(frontRight, backRight);
    public DifferentialDrive differentialRocketLeagueDrive = new DifferentialDrive(leftGroup, rightGroup);
    protected void init(){
    // Don’t use. Might break the code.
    }
    // negative speed = right forwards, left backwards
    public void setLeft(double speed){
    leftGroup.set(speed);
    }
    public void setRight(double speed){
    rightGroup.set(speed);
    }
    public void RocketLeagueDrive(double moving, double turning) {
    double turn = 0.0;
    double speed = 0.0;
    double driveSpeed = 0.80;
    double rotateSpeed = 0.60;
    double swivel = .80;
    if(moving != 0){
    speed = driveSpeed * moving;
    if(Math.abs(turning) > .10){
    turn = rotateSpeed * turning;
    }
    }else if(Math.abs(turning) > .10){
    turn = swivel * Math.pow(turning, 3);
    }
    differentialRocketLeagueDrive.arcadeDrive(speed, turn);
    System.out.println(“Turn” + turn);
    System.out.println("Speed = " + speed);
    }

We’d need to see more of your code. Please post a link to github or similar.

We had a very similar problem.

The wpi drivetrain parts of the code have a "safety where they check for joystick input every cycle, and if they don’t have it they turn off the motors.

For us it was that we were updating the smart driverstation too much which slowed down the joystick data.

We were advised to check through our code looking for anything that might slow down data transmission.

Hope this helps.

Edoga

So, the error message tells you exactly what the problem is. There is more than a 20ms period of time where you’re not explicitly telling your DifferentialDrive object what output to use. This is ALMOST always due to a misconfigured default command.

In short, this doesn’t do what you think it does: https://github.com/RedThunder7166/7166_2020_Code/blob/master/2020_Real_Code/src/main/java/frc/robot/subsystems/Drive/DriveSubsystem.java#L167

This is a change between the “old” and “new” command-based frameworks. Take a look through the docs: https://docs.wpilib.org/en/latest/docs/software/commandbased/subsystems.html#setting-default-commands

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