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);
}