RobotPy Watchdog Not Fed


#1

I keep getting the error, “Watchdog not fed after 0.020000s” with this code.

    #!/usr/bin/env python3

    import wpilib
    from wpilib.drive import DifferentialDrive
    import ctre


    class MyRobot(wpilib.IterativeRobot):
        def robotInit(self):

            self.left = ctre.WPI_TalonSRX(0)
            self.right = ctre.WPI_TalonSRX(1)

            self.myRobot = DifferentialDrive(self.left, self.right)

            self.stick = wpilib.Joystick(0)

        def autonomousInit(self):
            pass

        def autonomousPeriodic(self):
            pass

        def teleopPeriodic(self):
            self.myRobot.setSafetyEnabled(False)
            self.myRobot.setExpiration(0.1)
            self.myRobot.arcadeDrive(self.stick, True)

        def testPeriodic(self):
            pass


    if __name__ == "__main__":
        wpilib.run(MyRobot)

#2

Does it stop if you use TimedRobot instead of IterativeRobot?


#3
self.myRobot.setSafetyEnabled(False) 
self.myRobot.setExpiration(0.1)

Why are you messing with MotorSafety at all?


#4

The Watchdog is enabled when the user’s functions start executing and disabled after they finish, so only user code is measured and network packet arrival jitter shouldn’t affect measurement (in other words, IterativeRobot and TimedRobot should behave the same). Try timing parts of the code yourself, or maybe just empty functions, to see where the slowdown is coming from.

Watchdog should have also printed a breakdown of the overrun per-function. What did it say, if anything?


#5

Note that even if you did want to mess with the watchdog settings (which is questionable), you should not be doing it in teleopPeriodic, it should be in a teleopInit function, or in robotInit.


#6

It also printed this
TypeError: ‘>’ not supported between instances of ‘Joystick’ and ‘float’

Locals at innermost frame:

{‘value’: <wpilib.joystick.Joystick object at 0x06940410>}


#7

Even without messing with the motor safety it still doesn’t work. The setSafetyEnabled(False) fixes the motors not being updated enough.


#8

That’s relevant! Missed that. You’re not using arcadeDrive correctly. It expects three arguments: forward/backward, turn, and whether to square the inputs or not. Use stick.getY and stick.getX to do that.

Honestly why do we even have setSafetyEnabled(False)… It is not a fix for broken code. I have never seen anyone use it for something that wasn’t band-aid.


#9

Team Update 14 announced a new RIO image to resolve this:

  • Control System:A requiredNIUpdate Suite (2019.2.0) with a new roboRIO image (FRC_roboRIO_2019_v14) has been released. This image fixes a bug where robots randomly enter the Watchdog Not Fed state (disabling outputs) for ~2.5s when they should be enabled. To use this image, C++\Java teams must have the previously released 2019.3.2 update installed.

#10

This is a different issue.