Go to Post I'm not certain that I agree with me on this reasoning, either. - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-02-2010, 22:05
Thxe Thxe is offline
Registered User
FRC #2535
 
Join Date: Jan 2009
Location: Tigears
Posts: 17
Thxe is an unknown quantity at this point
Problems with the watchdog (I think)

Hello, we are having some problems with getting our code to work. At first, whenever we put the robot into enabled mode, it would immediately say watchdog not fed. The thing is, we are feeding the watch dog. I commented out the camera related code, which helped a lot, but consistently, about 2 minutes after the robot is turned on, it dies to the watch dog. I have the watch dog set to 100ms time out, which seems like plenty of time, especially considering that we don't have much code yet. All we have is a bit of camera initialization (which I commented out anyway) and the code to control the mecanum wheels.

I have resolved the problem if I comment out all code except the feed statement, so I'm confident that that is working.

Anyways, does anyone have any idea what could because the watch dog to trigger? I also tried setting the time out up to 1000 which had no effect so I'm a little confused.
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2010, 22:07
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Problems with the watchdog (I think)

Could we please see your code? You might have returned the functions, caused an exception, overflow, endless loop, etc by accident that caused the cRio to break out of the function or keep cycling over the same code segment that does not include a feed function call.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2010, 22:29
Thxe Thxe is offline
Registered User
FRC #2535
 
Join Date: Jan 2009
Location: Tigears
Posts: 17
Thxe is an unknown quantity at this point
Re: Problems with the watchdog (I think)

Sure, I'm at home right now, but I can post the code after school tomorrow.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-02-2010, 23:25
davidalln's Avatar
davidalln davidalln is offline
World's Worst Coder
AKA: David Allen
FRC #2415 (The Westminster Wiredcats)
Team Role: Programmer
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Atlanta, GA
Posts: 108
davidalln is on a distinguished road
Send a message via AIM to davidalln
Re: Problems with the watchdog (I think)

Are you running any printf()s to send data back to the target console? We were scratching our heads over why we were having so much trouble with the watchdog until we tried commenting out all the print statements. They are expensive.
__________________
SANTOSH ANDREW DECKER RICK WYNNIE SEAN DEREK MATT
(alamo (semis), p'tree (CHAMPS!), nc (CHAMPS!), newton (quarters))


Best four years of my life. Thanks to everyone who made it happen.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-02-2010, 16:55
Thxe Thxe is offline
Registered User
FRC #2535
 
Join Date: Jan 2009
Location: Tigears
Posts: 17
Thxe is an unknown quantity at this point
Re: Problems with the watchdog (I think)

Thanks for the responses. Unfortunately, our mentor was not at school today, so no robotics, so I still do not have code to post.

As for the printfs, they are another issue I've been looking into. I have tried the code with and with our printfs and get the same result either way. I'm not sure whether this is relevant, but when I was using them, I was unable to get them to work. I have to do a little more investigation in to them though, so I think that is a separate issue.

Thxe
Reply With Quote
  #6   Spotlight this post!  
Unread 02-02-2010, 17:46
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Problems with the watchdog (I think)

Quote:
Originally Posted by davidalln View Post
Are you running any printf()s to send data back to the target console? We were scratching our heads over why we were having so much trouble with the watchdog until we tried commenting out all the print statements. They are expensive.
They are expensive if you are using the serial port on the cRIO for console output (because of the 9600 baud rate). If you are using NetConsole, they are much less expensive.

-Joe
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2010, 19:07
Thxe Thxe is offline
Registered User
FRC #2535
 
Join Date: Jan 2009
Location: Tigears
Posts: 17
Thxe is an unknown quantity at this point
Re: Problems with the watchdog (I think)

Ok, here is the code. Sorry this took so long. It is based off of the Defaut Robot. The watchdog says it is not fed about 1:45 to 2:00 minutes into teleop mode.

DefaultRobot.cpp
Code:
#include <iostream.h>
#include "math.h"

//#include "Vision/AxisCamera2010.h"
#include "WPILib.h"
#include "Mecanum.cpp"

/**
 * This is a demo program showing the use of the RobotBase class.
 * The SimpleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 */
class DefaultRobot : public SimpleRobot
{			// robot drive system
	Joystick *rightStick;			// joystick 1 (arcade stick or right tank stick)
	Joystick *leftStick;			// joystick 2 (tank left stick)
	DriverStation *ds; 				// driver station object
	Mecanum *mecanum;				// Mecanum drive system

                            

public:
	/**
	 * 
	 * 
	 * Constructor for this robot subclass.
	 * Create an instance of a RobotDrive with left and right motors plugged into PWM
	 * ports 1 and 2 on the first digital module.
	 */
	DefaultRobot(void)
	{
		ds = DriverStation::GetInstance();	// create robot drive base
		rightStick = new Joystick(1);			// create the joysticks
		leftStick = new Joystick(2);
		mecanum = new Mecanum(4, 1, 2, 3, 4);
		//Update the motors at least every 100ms.
		GetWatchdog().SetExpiration(100);
	}

	/**
	 * Drive left & right motors fo7r 2 seconds, enabled by a jumper (jumper
	 * must be in for autonomous to operate).
	 */
	void Autonomous(void)
	{
		GetWatchdog().Feed();
		GetWatchdog().SetEnabled(false);
		//Pull triger, fire rockets
		//{
		/*	myRobot->Drive(0.5, 0.0);			// drive forwards half speed
			Wait(2000);							//    for 2 seconds						//    for 2 seconds
			myRobot->Drive(-0.5, 0.0);			// reverse robot
			Wait(2000);
			myRobot->Drive(0.0, 0.0);			// stop robot
		//}*/
		GetWatchdog().SetEnabled(true);
	}

	/**
	 * Runs the motors under driver control with either tank or arcade steering selected
	 * by a jumper in DS Digin 0. Also an arm will operate based on a joystick Y-axis. 
	 */
	void OperatorControl(void)
	{
		GetWatchdog().Feed();
		while (true)
		{
			GetWatchdog().Feed();
			mecanum->SetSpeeds(rightStick->GetX(), rightStick->GetY(), leftStick->GetX());  //It works when I comment this out.
			GetWatchdog().Feed();
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
Mecanum.cpp
Code:
/*
 * Mecanum drive class
 * Team 2535
 * Theodore Dahlen
 * 2/1/2010
 */

class Mecanum
{
	
	Victor *MotorFrontLeft;
	Victor *MotorFrontRight;
	Victor *MotorBackLeft;
	Victor *MotorBackRight;
	
public:
	
	
	Mecanum(UINT32 slot,
			UINT32 FrontLeft,
			UINT32 FrontRight,
			UINT32 BackLeft,
			UINT32 BackRight)
	{
		MotorFrontLeft = new Victor(slot, FrontLeft);
		MotorFrontRight = new Victor(slot, FrontRight);
		MotorBackLeft = new Victor(slot, BackLeft);
		MotorBackRight = new Victor(slot, BackRight);
		
		
	}
	
	void SetSpeeds(float X, float Y, float Twist)
	{
		float *Wheels[4]; // 0 is FL, 1 is FR, 2 is BL, 3 is BR
		
		*Wheels[0] = Y + X + Twist;
		*Wheels[1] = Y - X - Twist;
		*Wheels[2] = Y - X + Twist;
		*Wheels[3] = Y + X - Twist;
		

		
		if(*Wheels[0] > 1 || *Wheels[0] < -1)
		{
			Divide(Wheels, 0);
		}
		else if(*Wheels[1] > 1 || *Wheels[1] < -1)
		{
			Divide(Wheels, 1);
		}
		else if(*Wheels[2] > 1 || *Wheels[2] < -1)
		{
			Divide(Wheels, 2);
		}
		else if(*Wheels[3] > 1 || *Wheels[3] < -1)
		{
			Divide(Wheels, 3);
		}
		else
		{
			//YOU MAY PROBLEMS! :D
		}
		
		Drive(Wheels);
	}
		
	
	void Divide(float *Wheels[4], int Divide)
	{
		float Divider = fabs(*Wheels[Divide]);
		
		*Wheels[0] = *Wheels[0] / Divider;
		*Wheels[1] = *Wheels[1] / Divider;
		*Wheels[2] = *Wheels[2] / Divider;
		*Wheels[3] = *Wheels[3] / Divider;
	}
	
	void Drive(float *Wheels[4])
	{
		MotorFrontLeft->Set(*Wheels[0]);
		MotorFrontRight->Set(*Wheels[1]);
		MotorBackLeft->Set(*Wheels[2]);
		MotorBackRight->Set(*Wheels[3]);
		
	}

};

Last edited by Thxe : 05-02-2010 at 22:23. Reason: I deleted a function that was not used after a simplification I made. It wasn't getting called anyway.
Reply With Quote
  #8   Spotlight this post!  
Unread 05-02-2010, 22:00
davidalln's Avatar
davidalln davidalln is offline
World's Worst Coder
AKA: David Allen
FRC #2415 (The Westminster Wiredcats)
Team Role: Programmer
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Atlanta, GA
Posts: 108
davidalln is on a distinguished road
Send a message via AIM to davidalln
Re: Problems with the watchdog (I think)

You have GetWatchdog().SetExpiration() set to 100 seconds, not 100 milliseconds. You probably want GetWatchdog().SetExpiration(0.1)

I'm not positive this is the cause of your problem, but it may be (it would make sense, 100s = 1m40s, so the watchdog might starve after not being fed for so long).
__________________
SANTOSH ANDREW DECKER RICK WYNNIE SEAN DEREK MATT
(alamo (semis), p'tree (CHAMPS!), nc (CHAMPS!), newton (quarters))


Best four years of my life. Thanks to everyone who made it happen.
Reply With Quote
  #9   Spotlight this post!  
Unread 05-02-2010, 22:21
Thxe Thxe is offline
Registered User
FRC #2535
 
Join Date: Jan 2009
Location: Tigears
Posts: 17
Thxe is an unknown quantity at this point
Re: Problems with the watchdog (I think)

Good Call, thanks. But even if thats the case, why isn't the watchdog getting fed? Seems to me that that would imply that there is something in the code freezing up, any idea what that might be? That would also explain why even during the time it was not disabled it was still not working. Anyway, thanks, that narrows my search for the problem a considerable amount.
Reply With Quote
  #10   Spotlight this post!  
Unread 08-02-2010, 15:41
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Problems with the watchdog (I think)

Not sure if this is the problem, but in your tele-op phase, you never enable the watchdog...


Not sure if that is the problem?
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
Problem with System Watchdog JSonntag NI LabVIEW 14 20-02-2010 11:31
System: Watchdog problems dboisvert C/C++ 7 16-02-2009 02:36
System: Watchdog problems dboisvert C/C++ 1 15-02-2009 20:12
Problems with the manual of the green target (for cmu cam) Kawashima Kit & Additional Hardware 1 28-01-2007 13:31
problems mounting the camera to the 'bot with the default servo/mount set up Redneck Programming 0 16-02-2005 20:53


All times are GMT -5. The time now is 13:48.

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