Watchdog Not Fed

Ok, so we’re basically recoding our bot from last year
For some reason, our watchdog is not being fed
Here is the java code:

package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.camera.*;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.PWM;
public class robot10 extends IterativeRobot {
    Joystick joystick=new Joystick(1);
    DriverStation driverstation=DriverStation.getInstance();
    AxisCamera camera;
    RobotDrive mecanumWheels= new RobotDrive(1,2,3,4);
    Solenoid extend1=new Solenoid(1);
    Solenoid retract1=new Solenoid(2);
    Solenoid extend2=new Solenoid(3);
    Solenoid retract2=new Solenoid(4);
    int b=0;
    Relay compressor=new Relay(4,1);
    PWM vacuum=new PWM(5);
    PWM camServo=new PWM(6);
    Watchdog watchdog=Watchdog.getInstance();

    public void robotInit() {
        compressor.set(Relay.Value.kOn);
        camera=AxisCamera.getInstance();
        watchdog.setEnabled(true);
        watchdog.feed();
    }

    public void autonomousPeriodic() {
        watchdog.setEnabled(true);
        if(b==0){
            watchdog.setEnabled(false);
            watchdog.kill();
            autoBot();
            b++;
        }
        watchdog.feed();
    }

    public void teleopPeriodic() {
        mecanumWheels.holonomicDrive(joystick.getMagnitude(), joystick.getDirectionDegrees(), joystick.getTwist());
        if(joystick.getRawButton(1))
        {
            retract1.set(false);
            retract2.set(false);
            extend1.set(true);
            extend2.set(true);
        }else{
            extend1.set(false);
            extend2.set(false);
            retract1.set(true);
            retract2.set(true);
        }
        camServo.setPosition(joystick.getThrottle());
        if(joystick.getRawButton(2))
            vacuum.setRaw(255);
        else
            vacuum.setRaw(0);
        watchdog.feed();
    }

    public void autoBot(){
        Timer.delay(5);
        mecanumWheels.arcadeDrive(255, 0);
        Timer.delay(2);
        extend1.set(true);
        extend2.set(true);
        Timer.delay(1);
        extend1.set(false);
        extend2.set(false);
        retract1.set(true);
        retract2.set(true);
        Timer.delay(2);
        retract1.set(false);
        retract2.set(false);
        extend1.set(true);
        extend2.set(true);
        Timer.delay(1);
        extend1.set(false);
        extend2.set(false);
        retract1.set(true);
        retract2.set(true);
        Timer.delay(2);
        retract1.set(false);
        retract2.set(false);
        extend1.set(true);
        extend2.set(true);
        Timer.delay(1);
        extend1.set(false);
        extend2.set(false);
        retract1.set(true);
        retract2.set(true);
        Timer.delay(1);
        retract1.set(false);
        retract2.set(false);
        watchdog.feed();
    }

    public void disabledInt(){
        compressor.set(Relay.Value.kOff);
    }

    public void disabledPeriodic(){
        watchdog.feed();
    }
}

Our labview code (which works fine) is in the attachment

Team 224 Code 0.zip (1.99 MB)


Team 224 Code 0.zip (1.99 MB)

Disable your watchdog. Don’t use it. Don’t implement it. The watchdog is not the way you should keep your robot safe.

Burn watchdog. It has been the bane of my starting year as a programmer. In more cases than not, it has caused more issues than it protected us from. at times, it has somehow made the robot go full speed one direction, before disabling itself while sitting on the opposite alliance’s goal.

if you are dead set on using watch dog, however, you need to feed it every so often. If you have any internal loops inside teleop periodic, (which is a bad idea to begin with) you should include a feed in them.

additionally, if you have any delay, you need to disable watchdog prior to it. Delay basically stops the system from proceeding, and thus the watchdog thread is not fed for what it interpret as an inordinate amount of time. EDIT: which it does appear you are doing.

speaking right out of my hat, java may find it problematic that you’re trying to feed a dead, disabled watchdog, since it tries to feed it after killing it in auto-periodic.

When exactly does the watchdog complain?

This thread is from 2010. The WPILib is completely different now.

Thats rather funny. I didn’t even notice the date :stuck_out_tongue: