OCCRA
Go to Post Besides, if you look back on anything you've already made and can't find any flaws that can be improved, you're doing it wrong. - artdutra04 [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 04-28-2010, 04:02 PM
johncap100 johncap100 is offline
Registered User
FTC #0658
 
Join Date: Aug 2009
Location: Capital High School
Posts: 95
johncap100 is an unknown quantity at this point
Older FRC autonomous code

I have the 2007 FRC bot (along with the 2006, 2005). I am programming using mplab 7.2. I am trying to install an autononmous code. I just want a short code that moves the bot forward a short distance , turns and returns to the original location.
Does anyone have a default workspace that has the autonomous code imbedded, who might be willing to share?
thanks john
  #2   Spotlight this post!  
Unread 04-28-2010, 05:00 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Itinerant Programmer
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: 7,354
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: Older FRC autonomous code

Do you mean the original default code?
Or Kevin Watson's default variation?

Or did you want direction on how to implement autonomous code?

Or were you looking for someone to drop your simple autonomous movements into the default to use as a starting example?
__________________
Deduction is limited by knowledge, and knowledge is limited by preconceptions
358 Beta notes & results

Last edited by Mark McLeod : 04-28-2010 at 05:26 PM.
  #3   Spotlight this post!  
Unread 04-28-2010, 05:19 PM
billbo911's Avatar
billbo911 billbo911 is offline
Registered User
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 1,873
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Older FRC autonomous code

Quote:
Originally Posted by johncap100 View Post
I have the 2007 FRC bot (along with the 2006, 2005). I am programming using mplab 7.2. I am trying to install an autononmous code. I just want a short code that moves the bot forward a short distance , turns and returns to the original location.
Does anyone have a default workspace that has the autonomous code imbedded, who might be willing to share?
thanks john
I can't offer code from 2007, but I do have our 2008 code. The Autonomous code drives the robot the length of the field, makes a u-turn and drives back toward the starting line. There is a bit more to it than that, but that basic part is there. By the way, it is built on Kevin Watson's framework instead of IFI's. Honestly, Kevin's is way better! PM me and I'll zip it and send it to you.
__________________
So long and thanks for all the fish!
CalGames 2009 Semi Finalist, CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist, 2010 Madtown Creative Design Award
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2013 Pow3rhou53 Pwnage Gracious Professionalism Award.
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division, Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up.
  #4   Spotlight this post!  
Unread 04-28-2010, 06:12 PM
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
no team
Team Role: Alumni
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Appleton, WI
Posts: 993
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
Re: Older FRC autonomous code

Do you want a smart or dumb autonomous (sensors or none?)

If you don't want any sensors, then this should be a pretty straight forward task. If you do want sensors, it'll be a little more complicated.


This is where you should start:
http://kevin.org/frc/
__________________
Former member / mentor of FRC team 868
Go TechHOUNDS!


  #5   Spotlight this post!  
Unread 04-28-2010, 09:22 PM
johncap100 johncap100 is offline
Registered User
FTC #0658
 
Join Date: Aug 2009
Location: Capital High School
Posts: 95
johncap100 is an unknown quantity at this point
Re: Older FRC autonomous code

Hello to Mark

well i have the kevin watson version i think.

and yes i wuold like to know how to drop in the autononmous code and
also create if you cuodl help.
basically on all three.

i do have the default code working so i have the teleop working both tank ans arcade., i would just like to do the autononmous too.
thanks john
  #6   Spotlight this post!  
Unread 04-28-2010, 09:23 PM
johncap100 johncap100 is offline
Registered User
FTC #0658
 
Join Date: Aug 2009
Location: Capital High School
Posts: 95
johncap100 is an unknown quantity at this point
Re: Older FRC autonomous code

and billbo911 yes if you could zip your code i would like that too if you could
thanks a bunch.
john
  #7   Spotlight this post!  
Unread 04-28-2010, 09:37 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: 662
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: Older FRC autonomous code

We try and archive all our code here:

http://www.frcsoft.com/forums/index....ocom=downloads
__________________
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
  #8   Spotlight this post!  
Unread 04-29-2010, 12:59 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Itinerant Programmer
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: 7,354
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: Older FRC autonomous code

In the Watson version you drop your autonomous code into the file "autonomous.c", specifically into the routine "Autonomous()".

This routine gets executed ~38 times per second in sync with the driver station control transmission packets.

You write your autonomous code in such a way that it does a little bit and goes away. When it gets called again it does a little bit more and goes away again.

Two ways to dead reckon autonomous movements are:
  1. to keep track of and count the number of times you're Autonomous() has been called - 38 times = 1 second.
  2. use a system timer and check each time to see if you've driven long enough.
If your code already has a timer setup, then you can experiment with using that. It's the most accurate method.

Counting loops is accurate enough for what you're doing at first, and it's trivial to implement and understand right away, so you can start with that.

On top of these methods of keeping track of time you might want a state machine to keep track of the steps you should be doing.

Here's an example:
Code:
// Drive forward, turn, return, and stop
 
void Autonomous()
{
 static int counter=0; //keep track of loops to use as a crude timer - static keeps it around from call to call
 static int autostate=1;   //keep track of what step we're supposed to be doing
 
  switch (autostate)
  {
    case 1:   // Drive forward
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
        if (counter>38)  //1 second
        {  
           autostate = 2;  // move on to the next step
           counter = 0;    // reset our timer for the next step
        }
 
    case 2:   // Turnaround
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 200;  //motor is reversed
        if (counter>76)  //2 seconds
        {  
           autostate = 3;
           counter = 0;
        }
 
    case 3:   // Drive forward (returning now)
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
        if (counter>38)  //1 second
        {  
           autostate = 4;
           counter = 0;
        }
 
     case 4:   // Stop - What to do when everything else is done
     default:  // also what to do if an invalid autostate occurs
 
       pwm01 = pwm02 = pwm03 = pwm04 = 127;   // Make sure the last thing you do is always stop
  }
  counter++;
}

Our team code from 2007 is here, but it's fairly complex as it implements a scripting system for autonomous, so I definitely wouldn't start learning at that level. Our robot was somewhat complex that year too.
__________________
Deduction is limited by knowledge, and knowledge is limited by preconceptions
358 Beta notes & results

Last edited by Mark McLeod : 04-29-2010 at 01:09 PM.
  #9   Spotlight this post!  
Unread 04-29-2010, 04:43 PM
johncap100 johncap100 is offline
Registered User
FTC #0658
 
Join Date: Aug 2009
Location: Capital High School
Posts: 95
johncap100 is an unknown quantity at this point
Re: Older FRC autonomous code

so after i open up the default workspace then i can open the autonomous.c and edit it there?

i think in the default code there is a place to drop in code but i forget which file i need to open up once the workspace is opened.

i would like to start with the dumb code but actually it would be nice to do some 'smart" code
thanks john
  #10   Spotlight this post!  
Unread 04-29-2010, 06:03 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Itinerant Programmer
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: 7,354
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: Older FRC autonomous code

Quote:
Originally Posted by johncap100 View Post
so after i open up the default workspace then i can open the autonomous.c and edit it there?
Yep.
Do you need instruction in using MPLAB and downloading code using IFI_Loader or do you already know about that or can figure it out?
__________________
Deduction is limited by knowledge, and knowledge is limited by preconceptions
358 Beta notes & results
  #11   Spotlight this post!  
Unread 04-30-2010, 09:47 AM
johncap100 johncap100 is offline
Registered User
FTC #0658
 
Join Date: Aug 2009
Location: Capital High School
Posts: 95
johncap100 is an unknown quantity at this point
Re: Older FRC autonomous code

no i can open the mplab and can upload from the ifi loader
thanks
  #12   Spotlight this post!  
Unread 04-30-2010, 11:06 AM
johncap100 johncap100 is offline
Registered User
FTC #0658
 
Join Date: Aug 2009
Location: Capital High School
Posts: 95
johncap100 is an unknown quantity at this point
Re: Older FRC autonomous code

mark i tried the following code from one of my students and it does not seem to work, i will try your code above.

any help is greatly appreciated.

by the way i am opening up the user-routine_fast.c to modify the autonomous code is that correct?
thanks


// Drive forward, turn, return, and stop

void Autonomous()
{
static int counter=0; //keep track of loops to use as a crude timer - static keeps it around from call to call
static int autostate=1; //keep track of what step we're supposed to be doing

switch (autostate)
{
case 1: // Drive forward
pwm01 = pwm02 = 200;
pwm03 = pwm04 = 54; //motor is reversed
if (counter>38) //1 second
{
autostate = 2; // move on to the next step
counter = 0; // reset our timer for the next step
}

case 2: // Turnaround
pwm01 = pwm02 = 200;
pwm03 = pwm04 = 200; //motor is reversed
if (counter>76) //2 seconds
{
autostate = 3;
counter = 0;
}

case 3: // Drive forward (returning now)
pwm01 = pwm02 = 200;
pwm03 = pwm04 = 54; //motor is reversed
if (counter>38) //1 second
{
autostate = 4;
counter = 0;
}

case 4: // Stop - What to do when everything else is done
default: // also what to do if an invalid autostate occurs

pwm01 = pwm02 = pwm03 = pwm04 = 127; // Make sure the last thing you do is always stop
}
counter++;
}
  #13   Spotlight this post!  
Unread 04-30-2010, 11:55 AM
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
no team
Team Role: Alumni
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Appleton, WI
Posts: 993
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
Re: Older FRC autonomous code

Did that compile OK?
When you loaded it and ran autonomous, I (hope) the robot just stayed still. Luckily your last state was no movement, because without break statements, it'll run through all the states.

Should be:

switch(variable)
{
case 0:
//do stuff
break;

case 1:
//do other stuff
break;

case 2:
//do some stuff, and case 3's stuff

case 3:
//do something else
break;

default:
//do nothing
break;
}

If you take the default case out in your current setup, you should drive forward forever (which is dangerous, so I suggest you don't).
I also suggest that you disconnect the motors and just watch lights to see if its doing what you want.
__________________
Former member / mentor of FRC team 868
Go TechHOUNDS!



Last edited by efoote868 : 04-30-2010 at 11:57 AM. Reason: a little clarification
  #14   Spotlight this post!  
Unread 04-30-2010, 02:01 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Itinerant Programmer
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: 7,354
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: Older FRC autonomous code

Those are the break;'s
The break statement concludes individual cases. Without it one case statement blends right into the next without a "break".
That is one of the reasons for stopping all motors at the end.

I unfortunately duplicated one block and missed copying the original break statement as part of the block of code.
Sorry about that...

Corrected version:
Code:
// Drive forward, turn, return, and stop
 
void Autonomous()
{
 static int counter=0; //keep track of loops to use as a crude timer - static keeps it around from call to call
 static int autostate=1;   //keep track of what step we're supposed to be doing
 
  switch (autostate)
  {
    case 1:   // Drive forward
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
        if (counter>38)  //1 second
        {  
           autostate = 2;  // move on to the next step
           counter = 0;    // reset our timer for the next step
        }
        break;
 
    case 2:   // Turnaround
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 200;  //motor is reversed
        if (counter>76)  //2 seconds
        {  
           autostate = 3;
           counter = 0;
        }
        break;

 
    case 3:   // Drive forward (returning now)
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
        if (counter>38)  //1 second
        {  
           autostate = 4;
           counter = 0;
        }
        break;

 
     case 4:   // Stop - What to do when everything else is done
     default:  // also what to do if an invalid autostate occurs
 
       pwm01 = pwm02 = pwm03 = pwm04 = 127;   // Make sure the last thing you do is always stop
  }
  counter++;
}
__________________
Deduction is limited by knowledge, and knowledge is limited by preconceptions
358 Beta notes & results

Last edited by Mark McLeod : 04-30-2010 at 02:13 PM.
  #15   Spotlight this post!  
Unread 04-30-2010, 02:28 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Itinerant Programmer
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: 7,354
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: Older FRC autonomous code

Quote:
Originally Posted by johncap100 View Post
by the way i am opening up the user-routine_fast.c to modify the autonomous code is that correct?
That means you're using the IFI default code rather than the Watson default code.

You'll need slightly different handling for that just because the framework structure is different. In user_routines_fast.c in the Autonomous() routine already there you'll want to keep some of the default code it uses. Below the lines in black are what you should already see in that default routine, and the lines in red are what need to be added. Really the critical part that's missing is the Getdata that tells the robot when autonomous mode is over and Putdata that sends your motor settings out to be used. Without that nothing would ever happen.

Code:
void User_Autonomous_Code(void)
{
 static int counter=0; //keep track of loops to use as a crude timer - static keeps it around from call to call
 static int autostate=1;   //keep track of what step we're supposed to be doing

  /* Initialize all PWMs and Relays when entering Autonomous mode, or else it
     will be stuck with the last values mapped from the joysticks.  Remember, 
     even when Disabled it is reading inputs from the Operator Interface. 
  */
  pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
  pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
  relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
  relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
  relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
  relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;

  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */
 
        // Drive forward, turn, return, and stop

        switch (autostate)
        {
    case 1:   // Drive forward
       pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
       if (counter>38)  //1 second
        {  
           autostate = 2;  // move on to the next step
           counter = 0;    // reset our timer for the next step
        }
        break;
 
    case 2:   // Turnaround
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 200;  //motor is reversed
        if (counter>76)  //2 seconds
        {  
           autostate = 3;
           counter = 0;
        }
        break;

 
    case 3:   // Drive forward (returning now)
        pwm01 = pwm02 = 200;
        pwm03 = pwm04 = 54;  //motor is reversed
        if (counter>38)  //1 second
        {  
           autostate = 4;
           counter = 0;
       }
       break;

 
     case 4:   // Stop - What to do when everything else is done
     default:  // also what to do if an invalid autostate occurs
 
       pwm01 = pwm02 = pwm03 = pwm04 = 127;   // Make sure the last thing you do is always stop
  }
  counter++;

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
}

__________________
Deduction is limited by knowledge, and knowledge is limited by preconceptions
358 Beta notes & results

Last edited by Mark McLeod : 04-30-2010 at 02:36 PM.
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
Autonomous 2010 FRC Drucifur Java 10 02-14-2010 07:06 AM
FRC...autonomous or driver-controlled competition? tribotec_ca88 General Forum 28 03-10-2005 01:47 PM
Autonomous code PBoss Programming 7 01-14-2003 02:29 PM
Autonomous Code Adrian Wong Robotics Education and Curriculum 1 11-18-2002 09:34 PM


All times are GMT -5. The time now is 04:28 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