View Single Post
  #2   Spotlight this post!  
Unread 16-02-2005, 01:54
ace123's Avatar
ace123 ace123 is offline
Registered User
AKA: Patrick Horn
FRC #0008 (Paly Robotics - http://robotics.paly.net/)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Palo Alto, CA
Posts: 50
ace123 has a spectacular aura aboutace123 has a spectacular aura about
Send a message via AIM to ace123
Re: Use of Functions in Autonomous

One thing that I would suggest is to change the part of user_routines_fast.c that says /*DO NOT CHANGE*/

No real code changes, but it is just a small thing to run something when it begins and ends... This is legal, and the "do not change" comment is referring to changing the order or deleting the loop.
Code:
void User_Autonomous_Code(void)
{
  /* 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=0;
  pwm05=pwm06=pwm07=pwm08=0;
  pwm09=pwm10=pwm11=pwm12=0;
  pwm13=pwm14=pwm15=pwm16=0;

  printf("Autonomous mode has begun!!!\r");
  // Code executes here when autonomous begins...;
  // Use this to reset all autonomous state variables (if any)

  do {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
      Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */
      if (!autonomous_mode) { // Autonomous stopped.

        printf("Autonomous mode has ended!!!\r");
        // Code executes here when autonomous mode ends...
        // Use this to stop camera, stop all motors.

      } else {

        // Normal autonomous code

      }
      Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
      Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  } while (autonomous_mode);   /* DO NOT CHANGE! */
}
Alternatives that require setting variables while in autonomous mode, etc. are a lot messier than a few if statements in the loop.
__________________
-Patrick Horn, Paly Robotics

Check out the space simulator called Vega Strike, modelled after the space simulator games Elite and Wing Commander. It's Open Source too!
If you have ever played Wing Commander, or especially Privateer, and had a feeling of nostalga derived from the you will enjoy these two Vega Strike mods: Privateer Gemini Gold and Privateer Remake!
I'm working on adding multiplayer support this year...