Go to Post Do not worry about the VEX camp versus FIRST camp issues. It is a huge marketplace. It is only about 4% penetrated. There is room for everyone. And competition is good for the consumer. - ebarker [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 3 votes, 3.67 average. Display Modes
  #1   Spotlight this post!  
Unread 12-15-2010, 04:11 PM
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
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:
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
Attached Files
File Type: zip Team 224 Code 0.zip (1.99 MB, 65 views)
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 01-22-2016, 11:33 PM
Cobra Commander's Avatar
Cobra Commander Cobra Commander is offline
Registered User
FRC #0498 (Cobra Commanders)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2001
Location: Glendale, AZ
Posts: 30
Cobra Commander is on a distinguished road
Re: Watchdog Not Fed

Disable your watchdog. Don't use it. Don't implement it. The watchdog is not the way you should keep your robot safe.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-25-2016, 01:09 PM
techkid86's Avatar
techkid86 techkid86 is offline
Magic Programer
FRC #3044 (0xBE4)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: ballston spa
Posts: 58
techkid86 is an unknown quantity at this point
Re: Watchdog Not Fed

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?
__________________
"you can build a perfect machine out of imperfect parts" -Urza

Last edited by techkid86 : 01-25-2016 at 01:15 PM.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-25-2016, 01:12 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,697
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Watchdog Not Fed

This thread is from 2010. The WPILib is completely different now.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #5   Spotlight this post!  
Unread 01-25-2016, 01:26 PM
techkid86's Avatar
techkid86 techkid86 is offline
Magic Programer
FRC #3044 (0xBE4)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: ballston spa
Posts: 58
techkid86 is an unknown quantity at this point
Re: Watchdog Not Fed

Thats rather funny. I didn't even notice the date
__________________
"you can build a perfect machine out of imperfect parts" -Urza
Reply With Quote
  #6   Spotlight this post!  
Unread 01-25-2016, 01:27 PM
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,712
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Watchdog Not Fed

Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Watchdog not fed brianelite C/C++ 12 03-14-2010 02:43 PM
Watchdog Not Fed! masoug C/C++ 5 02-24-2010 07:59 PM
Autonomous Independent Code Issue Watchdog not fed pilum40 FRC Control System 0 02-11-2010 12:00 PM
Watchdog Not Fed but, All Systems Are Go. DHSrobotics Java 4 01-24-2010 10:01 PM
Watchdog not fed ahudson Programming 1 01-22-2010 11:26 AM


All times are GMT -5. The time now is 07:56 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi