Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Help - Making the autonomous mode (http://www.chiefdelphi.com/forums/showthread.php?t=53137)

razer 31-01-2007 09:46

Help - Making the autonomous mode
 
Hi, this is my first year in the FIRST competition, and i dont know how to make an autonomous mode, i dont know where to write my code, and i dont know how to activate it at all. can someone tell me how can i do it?
1. where to write my code.
2. how to activate it.
3. a short example of it..

thanks, Nir.

whytheheckme 31-01-2007 10:00

Re: Help - Making the autonomous mode
 
Check out this post I just replied to.

http://www.chiefdelphi.com/forums/sh...d.php?p=568759

--
Remember, If my posts are helpful, Good Rep is always Good

Alan Anderson 31-01-2007 10:14

Re: Help - Making the autonomous mode
 
If you're using MPLab and the C18 compiler, you write your autonomous code in the User_Autonomous_Code(void) function found in the user_routines_fast.c file. Here's what it looks like in the default code:
Code:

/*******************************************************************************
* FUNCTION NAME: User_Autonomous_Code
* PURPOSE:      Execute user's code during autonomous robot operation.
* You should modify this routine by adding code which you wish to run in
* autonomous mode.  It will be executed every program loop, and not
* wait for or use any data from the Operator Interface.
* CALLED FROM:  main.c file, main() routine when in Autonomous mode
* ARGUMENTS:    none
* RETURNS:      void
*******************************************************************************/
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 = 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! */

        /* Add your own autonomous code here. */

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

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

You activate the autonomous code by flipping the "autonomous" switch on your competition port dongle. (What? You don't have one? Make one using the information found at http://www.ifirobotics.com/docs/comp...guide-reva.pdf .)

I think a short example would be insufficiently helpful, and a helpful example would be insufficiently short. What you need to write depends on 1) what you want your robot to do, 2) how you want your robot to do it, and 3) exactly what sensors and motors your robot has connected.

Dave Scheck 31-01-2007 10:41

Re: Help - Making the autonomous mode
 
You may also want to check out the white paper entitled C Programming and Autonomous Modes for Newbies. It was written a few years ago, but it should still be pertinent.

mluckham 31-01-2007 16:13

Re: Help - Making the autonomous mode
 
We are using EasyC this year - I highly recommend it, as it eliminates a lot of programming "stuff" you have to know about. No need to know about .c/.h files, what goes where, yada-yada.

With EasyC, you put the autonomous code into the Autonomous() routine.

xrabohrok 31-01-2007 16:25

Re: Help - Making the autonomous mode
 
Keep in mind that the code is executed from top to bottom 32 times a second. This can really affect the coding process.


All times are GMT -5. The time now is 04:21.

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