View Single Post
  #3   Spotlight this post!  
Unread 10-02-2016, 00:09
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,043
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Watchdog Function Not Functioning

Hey Will,

WPILib has the motor safety stuff built in and enabled for RobotDrive to make it harder for the robot to do something like go into an infinite loop and have all of the motors going at full blast.

Basically, if you don't tell the motors to do something within 100ms or so, then this error will occur. You can solve it by ensuring that you do something with robot drive each time teleopPeriodic is called.

You can run the following code in the simulator to demonstrate the problem and its solution:

Code:
import wpilib

class MyRobot(wpilib.IterativeRobot):

    def robotInit(self):
        self.joystick = wpilib.Joystick(0)
        self.robot_drive = wpilib.RobotDrive(1,2)

    def teleopPeriodic(self):
        if not self.joystick.getTrigger():
            self.robot_drive.arcadeDrive(self.joystick)

if __name__ == '__main__':
    wpilib.run(MyRobot)
If you run this code and stick it in teleop, then all is well, as robot drive is getting called on each loop. However, if you enable the trigger button on the first joystick, then the annoying robot safety output messages will start appearing -- because you're no longer calling robot drive.

Does that make sense?
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote