Go to Post For those of you who don't want to read a block of text: Respect the Tools. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-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 01-26-2007, 12:11 PM
Raikon's Avatar
Raikon Raikon is offline
Cameraman
AKA: CJ
FRC #2220 (Blue Twilight)
Team Role: Animator
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Eagan, Minnesota
Posts: 17
Raikon is infamous around these partsRaikon is infamous around these partsRaikon is infamous around these parts
Automous Code?

I was wondering if anyone had some basic automous code I could look at to start us off with something

Links are great

THANKS IN ADVANCE!
__________________
Quote:
Enter the Shadows, The Darkness, The Mists, The Corruption consumes me
Blue Twilight Robotics
  #2   Spotlight this post!  
Unread 01-26-2007, 12:44 PM
Stuart's Avatar
Stuart Stuart is offline
#include coffee.h
FRC #1745 (P51- Mustangs)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Dallas, TX
Posts: 408
Stuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond repute
Send a message via AIM to Stuart
Re: Automous Code?

pwm1 = 255;
pwm2 = 255;
while(1)
{
}

that will drive you forward will the end of time.
__________________
Proud mentor of Team #1745 the P-51 Mustangs

If at first it doesn't work, use a hammer.
If that doesn't work, use a bigger hammer.
  #3   Spotlight this post!  
Unread 01-26-2007, 01:05 PM
Chris_Elston's Avatar
Chris_Elston Chris_Elston is offline
Controls Engineer
AKA: chakorules
None #1501 (Team THRUST)
Team Role: Engineer
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Huntington, Indiana
Posts: 661
Chris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond reputeChris_Elston has a reputation beyond repute
Send a message via AIM to Chris_Elston Send a message via Yahoo to Chris_Elston
Re: Automous Code?

We have some done in EasyC last year.


http://www.frcsoft.com/forums/index.php?download=11
__________________
Team T.H.R.U.S.T. 1501
Download all of our past robot's source code here:Repository

Favorite CD quote:
"That can't be their 'bot. not nearly enough (if any) rivets to be a 1501 machine." ~RogerR: Team #1369
  #4   Spotlight this post!  
Unread 01-28-2007, 08:03 PM
Andrew Schreiber's Avatar
Andrew Schreiber Andrew Schreiber is offline
6 events this season?
FRC #0125 (NUTRONS) (EWCP)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 3,097
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: Automous Code?

Quote:
Originally Posted by Stuart View Post
pwm1 = 255;
pwm2 = 255;
while(1)
{
}

that will drive you forward will the end of time.
Actually that will make the dreaded code error light turn red... I think, something about the putData() function not being called every 26.3 microseconds.

On the topic of auton code:

Code:
int autonStep = 1;
int timeCounter = 0;

switch(autonStep)
{
case 1:
pwm01=pwm02 = 255; //drives pwm01 and pwm02 forward.
if(timeCounter >= 100)
{
autonStep++;
}
break;
case 2:
pwm01=pwm02= 127;//stop pwm01 and pwm02.
break;
}

timeCounter ++;
the above code will drive the specified pwms forward for 100 fall throughs of the code. This would be put in user_routines_fast.c. Using this concept it is possible to write any autons you need. Just remember to increment that step variable so you dont get caught up. If you have pots or limit switches you can use them in your if statements too. Autons (for us at least) are usually defined by lots of if statements. Thought writing functions to do things like move arms and such makes this simpler.
  #5   Spotlight this post!  
Unread 01-28-2007, 09:21 PM
ebowla's Avatar
ebowla ebowla is offline
The Overmind
FRC #2016
Team Role: Programmer
 
Join Date: Dec 2006
Rookie Year: 2006
Location: Ewing High School
Posts: 15
ebowla is on a distinguished road
Re: Automous Code?

I wouldn't use a switch statement for so few options, it would be cleaner with just an if() and else if() statements. Thats what I use pretty much all the time.

Damien is right about the complication of the code. It all depends on what you want it to do of course.

Oh and as a general rule, I cant think of any exceptions, you should never add any loops to the code. Ever. It causes problems. There is only the one big main() loop and thats it. There might have been another general one for automomous code, but that would be in the default code.(if is there at all, cant remember)
__________________
Progamming Master
Disclaimer: May not be actually as good as claimed, not reliable for advice, and shirks away any real work.
  #6   Spotlight this post!  
Unread 01-29-2007, 12:13 AM
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: Automous Code?

Quote:
Originally Posted by ebowla View Post
Oh and as a general rule, I cant think of any exceptions, you should never add any loops to the code. Ever. It causes problems.
There's nothing wrong with using loops IF they're of deterministic length and obviously don't make your code execute longer than the 26.2 milliseconds allotted for each pass through the main loop. What you can't do is loop in while waiting for some event. If the event hasn't happened, give it up and check the next pass through the main loop.

There are many calculations that would be foolish coding without loops. CORDIC trig functions leaps to mind. But the time in the loop is deterministic.
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
Problems Combining Camera Code and Driving Code cmurdoch Programming 20 02-10-2007 03:34 PM
problems using gyro/adc code with camera default code tanstaafl Programming 7 01-22-2006 10:09 PM
so lost we need help with automous evilhunter Programming 2 02-21-2005 12:54 PM
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 01-31-2005 09:28 PM
2001 2002 in Automous SpaceOsc Control System 12 05-17-2004 12:52 AM


All times are GMT -5. The time now is 02:47 AM.

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


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