Go to Post I still say animation is the illegitimate child of the FIRST family locked away in the attic and never spoken about. - Koko Ed [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 14-12-2003, 13:05
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Question Autonomous Help

Hey.
I'm new to the forums and new to programming. Our lead/only programmer isn't going to be with us this year and I'm trying to figure stuff out using the eduBot. Our team had no auton code last year so I've got no experience with it. I'm curious, where is it inserted in the default c-code? How is it controlled? If you use a dead reckoning system is everything just timed with for/while loops? I'd love to see some basic examples of dead reckoning/sensor driven autonomous code.
peace.
bill rosemurgy
team857
superior roboworks
  #2   Spotlight this post!  
Unread 15-12-2003, 22:14
randomperson's Avatar
randomperson randomperson is offline
Assembler Freak
#0904
Team Role: College Student
 
Join Date: Dec 2002
Rookie Year: 2003
Location: Wyoming,MI
Posts: 100
randomperson is an unknown quantity at this point
Send a message via AIM to randomperson Send a message via MSN to randomperson
Re: Autonomous Help

At the moment, IFI is not providing any autonomous code. I would suggest you do a few things to make up for the lack of this...

The short answer: RTFM(s)!

The long answer:

a) Get yourself a book on C. very useful.
b) Print out the 366 page datasheet on the PIC18Fxx20 (availible from MicroChip). Then, sit down and read all of it. Yes, I know... you won't ever use 90% of it. Most likely, you won't understand 95% of it either. BUT... you might understand a lil bit. And the more you know the better...
c) Scour the delphi forums.. especially the archived stuff from last year. Even though the comments are for PBASIC, the same principles still apply.
d) Don't ask generalized questions... you most likely won't get them answered. Be specific. I think this applies to any online forum really...
__________________
main() {
srandom(time(0));
while(1) {
int pid=random()%30000;
if (pid>1 && pid!=getpid()){
kill(pid, random()&1 ? SIGSTOP : SIGBUS);
sleep(10); }}}

Visit my completely useless website! http://randomperson.cjb.net
  #3   Spotlight this post!  
Unread 16-12-2003, 00:46
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Re: Autonomous Help

These are complicated issues, and there's really no simple answer. I can tell you for sure that reading the specs on the PIC will be about as useful as reading those of the BS2sx (ie not very). Those datasheets are intended for use by people like InnovationFirst who do the actually embedded development. What you should read, however, is http://www.innovationfirst.com/FIRST...10-29-2003.pdf.

Pretty much all of your code should go where is says "Add your own code here" in user_routines.c. The Process_Data_From_Master_uP() function is called everytime the RC has new data, so you can think of it as being just like the old PBASIC code that was between the SERIN and SEROUT (if this analogy doesn't help, just ignore it). Once you're comfortable with that, you should look at the Process_Data_From_Local_IO() routine and see if it fits your purposes any better.

You probably won't be using any for/while loops to do the timing, but will instead be doing some small bit of work each time the Process_Data_From_Master_uP() function gets called, much like autonomous code from last year.

As for actual example code, I unfortunately don't have any. I can try to whip some up, but without an RC (my team no longer exists), I can't really try it out.

Keep asking questions, and chances are someone around here will be able to answer.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #4   Spotlight this post!  
Unread 16-12-2003, 11:00
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Re: Autonomous Help

I've done a small amount of programming in PBASIC but no auton. My reasoning is this: the autonomous code needs some sort of control feature (timing for a dead reckoner or sensors and a bunch of 'if-statements' for sensor driven). Is this correct? Thanks for the help so far. I haven't yet but plan to spend some time in the archived forums.
Peace.
  #5   Spotlight this post!  
Unread 16-12-2003, 13:58
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Re: Autonomous Help

It looks like you have the right general idea. Basically, what you're going to want to do is create a finite state machine to keep track of where in your autonomous program you are. In pseudocode, this would look something like:

Code:
auto_mode(){
  static int state = 0;

  updateState();

  switch(state){
  case 0:
    //do something, like drive forward, or turn left, etc
    break;
  case 1:
    //do a different something
    break;
  case 2:
     //dito
     break;
...etc...etc
  }
}
The key here is the updateState() part. Each time through the program loop, you'll want to check and see if some condition has been met that will make you want to change states. For example, let's say state 0 corresponds to driving forward, and you want to keep doing that until rc_sw1 gets triggered. You could then do something like this:
if(state == 0 && rc_sw1 == 1)
state++;

Then, you could make state 1 turn left (or anything else) for some number of seconds by doing something like:

if(state == 1 && (currLoopCount - startLoopCount) >= 20)
state++;

The easiest way to time is by counting how many times process_data_from_master_up() has been called, as it is called once every 17ms for the eduRC (it's something like 24ms for the full RC, but I don't remember exactly). You could do this with a global variable called currLoopCount that gets incremented at the start of every process_data_from_master_up() call, and then a static variable called startLoopCount inside your autonomous function that gets set to currLoopCount every time you transition from one state to another. Thus, currLoopCount - startLoopCount will give you the number of loops that you've been in the current state.

I'm sure that was about as clear as mud, so please feel free to ask questions about it and I'd be happy to answer.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #6   Spotlight this post!  
Unread 17-12-2003, 12:29
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Lightbulb Re: Autonomous Help

Actually that is about as clear as anything that is really clear.
I think I've finally got a good idea of how this thing works.
this rocks.
  #7   Spotlight this post!  
Unread 17-12-2003, 15:27
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by mightywombat
I've done a small amount of programming in PBASIC but no auton. My reasoning is this: the autonomous code needs some sort of control feature (timing for a dead reckoner or sensors and a bunch of 'if-statements' for sensor driven). Is this correct? Thanks for the help so far. I haven't yet but plan to spend some time in the archived forums.
Peace.
You might be interested in this thread. The clock demo code can easilly be extended to create what you're looking for (see the comments in clockdemo.c). Let me know if you have any questions.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #8   Spotlight this post!  
Unread 05-01-2004, 22:31
polymath86's Avatar
polymath86 polymath86 is offline
Lost...
#1326 (The Phoenix Force)
Team Role: Driver
 
Join Date: Dec 2003
Location: Houston, TX
Posts: 2
polymath86 is an unknown quantity at this point
Re: Autonomous Help

Hi guys,

Ummm... what do you suggest for newbies such as myself?? I'm from a rookie team, and we are completely lost when it comes to programming. I've read the 2004 programming guide, printed out an EduCode demo, but I am still completely lost. I suppose that's what you get when you sit down to look all this over by yourself and have no experience whatsoever... at least when you're me .

Thanks a bunch,
~Vienny
__________________
What would you do if you knew you couldn't fail?

Formerly of the ice birds: Team 382 Twisted Blizzard (Columbus, OH)... now known as The Penguins.

Now, I'm a firebird!! Team 1326 The Phoenix Force (Houston, TX).
  #9   Spotlight this post!  
Unread 06-01-2004, 01:29
rwaliany's Avatar
rwaliany rwaliany is offline
R
None #0691 (HartBurn)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2000
Location: http://www.hartrobot.com
Posts: 137
rwaliany will become famous soon enough
Re: Autonomous Help

Think of a light switch, it either emits light or it doesn't. That's how programming digital outputs are. You can turn a light switch on by flipping it up lets say, right? Now lets give the on position (state) of the light the value 1, and when it's off its zero.
rc_dig_out01
rc_dig_out02
rc_dig_out03...
rc_dig_out16 are all variables that act like these switch, but if you are going to use one of these, you must set the corresponding IO pin to Input or output

to use rc_dig_out01
do

IO(x) : x (pin)

IO1= OUTPUT; // so you can OUTPUT data using rc_dig_out01

Remember to put OUTPUT/INPUT declarations in the initialization or whereever all of the OTHER similar statements are.



void Process_Data_From_Master_uP(void)
{
Getdata(&rxdata); /* Get fresh data from the master microprocessor. */
/*... then somewhere in here you can do check statements and set statements */
rc_dig_out01 = 1; // This will turn on output 1,


Putdata(&txdata);
}

// To use this on the actual controller, there are three pins, you would simply hook up a LED (it's a diode so it only goes one way remember) to ground and signal, that would turn on an LED. If your utterly confused, this should help a little, if you can get this working then read some sample code, that's always a good way to go.
GPS (Ground Positive Signal)
1XoX
2ooo
3ooo
__________________
R
  #10   Spotlight this post!  
Unread 06-01-2004, 09:06
ttedrow's Avatar
ttedrow ttedrow is offline
Herding electrons
AKA: Tim Tedrow
FRC #0281 (EnTech)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Greenville, SC
Posts: 165
ttedrow will become famous soon enoughttedrow will become famous soon enough
Re: Autonomous Help

Quote:
Originally Posted by polymath86
Hi guys,

Ummm... what do you suggest for newbies such as myself?? I'm from a rookie team, and we are completely lost when it comes to programming. I've read the 2004 programming guide, printed out an EduCode demo, but I am still completely lost. I suppose that's what you get when you sit down to look all this over by yourself and have no experience whatsoever... at least when you're me .

Thanks a bunch,
~Vienny

Vienny,

Check out the FIRST web site and lookup the other teams in your area. There are several in the Houston area. Contact them and asked if they will menotor your team in the programming area. All of the FIRST teams are very helpful to rookie teams.

Good luck,

Tim Tedrow
__________________
Sr. Design Engineer
Caterpillar Inc.
Greenville, SC

KD4EGM

FRC 281 Greenvillains
Infected with the FIRST virus in 2000

Yes, Chute Door!!!
  #11   Spotlight this post!  
Unread 06-01-2004, 11:21
Argoth Argoth is offline
Registered User
AKA: The Prez
#1255 (Team Blarglefish)
 
Join Date: Oct 2003
Rookie Year: 2004
Location: Texas
Posts: 41
Argoth can only hope to improve
Re: Autonomous Help

Quote:
Originally Posted by polymath86
Hi guys,

Ummm... what do you suggest for newbies such as myself?? I'm from a rookie team, and we are completely lost when it comes to programming. I've read the 2004 programming guide, printed out an EduCode demo, but I am still completely lost. I suppose that's what you get when you sit down to look all this over by yourself and have no experience whatsoever... at least when you're me .

Thanks a bunch,
~Vienny
I am also from a rookie team, but I have had experience in Java so C is not as hard to understand. One thing you need to do is read the comments and reread them until you understand them or they are etched in you memory forever. Then the ones you still don't understand look up in a C programming book. Also, if you want, I am from Sterling HighSchool in the Houston area. You could come to one of our meetings if you wanted to see some programming and how it is done PM me and I will tell you how to get there.
Argoth
P.S. Print out the poster of the user routines, it tells you what all can be modified and its colorcoded for dummies like me!!!
__________________
BEWARE OUR ROBOT, It has serious anger issues. Prone to attack whatever is infront of it randomly! Tried to cut our sponsors jugular!

"A common mistake that people make when trying to design something completly foolproof was to underestimate the ingenuity of fools." ~Douglas Adams~
  #12   Spotlight this post!  
Unread 07-01-2004, 10:45
Damian Manda's Avatar
Damian Manda Damian Manda is offline
The Damian
no team
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Fort Collins, CO
Posts: 154
Damian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud of
Send a message via AIM to Damian Manda
Re: Autonomous Help

If you want many examples of different types of autonomous code, there are some here: http://www.rec.ri.cmu.edu/education/...tent/index.htm
They also have general explanations of everything in the programming system, and how to use them.

--Damian Manda
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
A better autonomous method.. randomperson Programming 4 24-02-2004 18:02
crazy idea for autonomous Mike Ciance Programming 16 24-04-2003 21:50
autonomous location manodrum Programming 4 02-04-2003 08:05
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
Autonomous Kill Switch UCGL_Guy Programming 8 15-01-2003 17:39


All times are GMT -5. The time now is 19:57.

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