Go to Post FIRST always talks about grandmothers and making them proud. So FIRST---you made my grandmother proud. - Collin Fultz [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-04-2008, 19:47
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Delay code isn't delaying.

I'm working with Kevin Watson's 3.0 compatible FRC framework. I have code in the begining of my Autonomous() function that should cause the robot to wait, based on a few constants defined in Autonomous.h. It doesn't seem to work, and just takes off immediately. Could it have something to do with the fact that the field control system spends a moment in teleop before jumping to autonomous in the begining?

I attached a .zip archive with my entire workspace.

Thank you for helping.

-Guy Davidson
Attached Files
File Type: zip 2008.zip (716.2 KB, 86 views)
__________________
  #2   Spotlight this post!  
Unread 13-04-2008, 20:13
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Delay code isn't delaying.

Might it have something to do with this line in autonomous.h?
Code:
#define WAITING_TIME 0
  #3   Spotlight this post!  
Unread 13-04-2008, 20:29
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Re: Delay code isn't delaying.

That line is commented out as part of this block:
Code:
/*
#define LOOPS_IN_A_SECOND 38
#define WAITING_TIME 0
#define TICKS_IN_A_FOOT 156 //163 * 23 / 24
#define DRIVE_FORWARD_1 10 //45 //in ft
#define DRIVE_FORWARD_2 10 //in ft
#define DRIVE_FORWARD_3 40 //in ft
#define DRIVE_FORWARD_4 10 //in ft
#define TURN_LEFT_1 65 // in diffs
#define TURN_LEFT_2 57 // in diffs
#define ANGULAR_INCREMENT 5 //in diffs
#define LINEAR_INCREMENT 156 //163 * 23 / 24
#define POSITION_INPUT_1 rc_dig_in17 //0 && 0 = LEFT, 1 && 0 or 0 && 1 = CENTER, 1 && 1 = RIGHT
#define POSITION_INPUT_2 rc_dig_in18 //0 && 0 = LEFT, 1 && 0 or 0 && 1 = CENTER, 1 && 1 = RIGHT
*/
The copy I hope it's using is defined a few lines later:
Code:
#define LOOPS_IN_A_SECOND 38
#define WAITING_TIME 8
Is there any way that's causing issues?
__________________
  #4   Spotlight this post!  
Unread 13-04-2008, 20:37
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Delay code isn't delaying.

I didn't think the preprocessor cared about comment lines. Are you getting any compiler errors or warnings about trying to redefine a symbol?
  #5   Spotlight this post!  
Unread 13-04-2008, 20:38
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Re: Delay code isn't delaying.

Nope. No errors or warnings what-so-ever, as far as I can see.
__________________
  #6   Spotlight this post!  
Unread 13-04-2008, 20:47
iTHOS=awesome iTHOS=awesome is offline
Registered User
FRC #1258
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Seattle
Posts: 16
iTHOS=awesome is an unknown quantity at this point
Send a message via MSN to iTHOS=awesome
Re: Delay code isn't delaying.

The best thing to do for delays is make a counter that does everything. Here is a few lines that I used for our robot in the Tacoma Regional:

int timer = 0;

if(timer < 72)
/* 72, if I remember right, is about 2 seconds, this number can be adjusted however you need it to be */
{
timer ++;
}
else
{
// This is where the remainder of autonomous functions occured
}
__________________
  #7   Spotlight this post!  
Unread 13-04-2008, 20:52
Ctrl Alt Delete's Avatar
Ctrl Alt Delete Ctrl Alt Delete is offline
Code Monkey
AKA: David Weitz
FRC #0177 (Bobcats)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Connecticut
Posts: 89
Ctrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to behold
Send a message via AIM to Ctrl Alt Delete Send a message via MSN to Ctrl Alt Delete
Re: Delay code isn't delaying.

It cycles 40 times a second right? So you can just make a function that returned i / 40 so you can say if(timer < 2) which would be the actual amount of seconds. I know it's basic math to just multiply by 40, but it makes the code a little more readable for someone that doesn't know that.
__________________

Life lessons learned at robot:
1.) Never take apart power strips
2.) Sleep is required, but not essential to survival

Failure to abide by these lessons will result in headaches...and flaming pants.

"Here at Bobcat Robotics, we pride ourselves in having 60-table MySQL databases, girlfriend cookies, and a vinyl cutter." -Chris Jelly
  #8   Spotlight this post!  
Unread 13-04-2008, 20:52
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Re: Delay code isn't delaying.

That's pretty much what I have there.
__________________
  #9   Spotlight this post!  
Unread 13-04-2008, 20:56
iTHOS=awesome iTHOS=awesome is offline
Registered User
FRC #1258
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Seattle
Posts: 16
iTHOS=awesome is an unknown quantity at this point
Send a message via MSN to iTHOS=awesome
Re: Delay code isn't delaying.

Quote:
Originally Posted by Guy Davidson View Post
That's pretty much what I have there.
if that is what you are doing, I don't know what the issue would be. Can you copy and paste your delay code here so I (or anyone else) can help you?
__________________
  #10   Spotlight this post!  
Unread 13-04-2008, 20:59
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Re: Delay code isn't delaying.

It's in autonomous.c in the attached archive. Since it's also based on stuff in autonomous.h, I left it in an archive. Would it help if I copy both .c and .h here?
__________________
  #11   Spotlight this post!  
Unread 13-04-2008, 21:03
Ctrl Alt Delete's Avatar
Ctrl Alt Delete Ctrl Alt Delete is offline
Code Monkey
AKA: David Weitz
FRC #0177 (Bobcats)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Connecticut
Posts: 89
Ctrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to beholdCtrl Alt Delete is a splendid one to behold
Send a message via AIM to Ctrl Alt Delete Send a message via MSN to Ctrl Alt Delete
Re: Delay code isn't delaying.

The only thing I can think of now is changing this:

if(auton_counter < WAITING_TIME * LOOPS_IN_A_SECOND)

to this:

if(auton_counter < (WAITING_TIME * LOOPS_IN_A_SECOND))

Maybe try printing out WAITING_TIME and LOOPS_IN_A_SECOND and see what it's outputting.
__________________

Life lessons learned at robot:
1.) Never take apart power strips
2.) Sleep is required, but not essential to survival

Failure to abide by these lessons will result in headaches...and flaming pants.

"Here at Bobcat Robotics, we pride ourselves in having 60-table MySQL databases, girlfriend cookies, and a vinyl cutter." -Chris Jelly
  #12   Spotlight this post!  
Unread 13-04-2008, 21:12
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Delay code isn't delaying.

What does your debug statement say for the value of counter?
  #13   Spotlight this post!  
Unread 13-04-2008, 21:16
iTHOS=awesome iTHOS=awesome is offline
Registered User
FRC #1258
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Seattle
Posts: 16
iTHOS=awesome is an unknown quantity at this point
Send a message via MSN to iTHOS=awesome
Re: Delay code isn't delaying.

The code is fairly confusing for me as to what you are trying to do. The way I learned programming makes this very hard to read, no offense. I just can't figure out what is wrong with it.
__________________
  #14   Spotlight this post!  
Unread 13-04-2008, 21:29
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Delay code isn't delaying.

Quote:
Originally Posted by iTHOS=awesome View Post
The way I learned programming makes this very hard to read, no offense.
I too find the highly compact style a hindrance to readability. I actually reformatted the relevant lines in order to make it easier for me to see what the code was trying to do.

I don't remember who said it, but I agree with the philosophy that says a programmer's job is to write documentation that compiles into a working program.
  #15   Spotlight this post!  
Unread 13-04-2008, 21:44
Guy Davidson Guy Davidson is offline
Registered User
AKA: formerly sumadin
FRC #0008 (Paly Robotics)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Ra'anana, Israel
Posts: 660
Guy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to beholdGuy Davidson is a splendid one to behold
Send a message via ICQ to Guy Davidson Send a message via AIM to Guy Davidson Send a message via MSN to Guy Davidson
Re: Delay code isn't delaying.

Quote:
Originally Posted by Joe Ross View Post
What does your debug statement say for the value of counter?
That's the next thing I was going to check. I put it in there during our last competition in hopes of getting around to test it there, and I haven't been able to yet. I'm hoping to do that early Thursday morning in Atlanta.
__________________
Closed Thread


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
Kevin Watson's gyro code isn't compling Griffin Programming 3 15-02-2008 20:34
Delay jasonpeinko Programming 8 18-01-2008 15:56
Delay Help! waiakea2024 Programming 7 21-02-2007 12:41
Delay Gal Longin Programming 1 09-12-2004 10:37
Delaying/Dampening motor response cadets Control System 4 05-02-2004 18:27


All times are GMT -5. The time now is 12:44.

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