Go to Post Reach out to successful teams and ask them for help, rather than complain about them. I have never seen a successful team deny help to anyone. - OZ_341 [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 03-02-2004, 12:24
sscanf sscanf is offline
Registered User
#0061
 
Join Date: Jan 2004
Location: Blackstone Valley Regional, Upton, MA
Posts: 4
sscanf is an unknown quantity at this point
Question User_Autonomous_Code() questions

OK. I'm new to FIRST but not new to C. I'm trying to understand the default FRC code. I see that main is calling User_Autonomous_Code() when the autonomous_mode flag is set and after calling Process_Data_From_Master_uP(). like so:

Code:
while (1)   /* This loop will repeat indefinitely. */
{
   if (statusflag.NEW_SPI_DATA)          
   {                                 
      Process_Data_From_Master_uP();  
      if (autonomous_mode)            
      {
        User_Autonomous_Code();       
      }
    }
    Process_Data_From_Local_IO();     
} /* while (1) */
What I don't understand is Process_Data_From_Master_uP() will in-turn call Default_Routine() which handles the operator interface. This doesn't seem correct but maybe I'm mis-understanding something.

It seems to me that the if check in main should be something more like this:

Code:
while (1)   /* This loop will repeat indefinitely. */
{
   if (statusflag.NEW_SPI_DATA)          
   {             
      GetData(&rxdata);  
      if (autonomous_mode)            
      {
        User_Autonomous_Code();        
      }
      else
      {  
         Process_Data_From_Master_uP(); //Modify to remove Get/PutData()
      }
      PutData(&txdata);
    }
    Process_Data_From_Local_IO();     
} /* while (1) */
I'm operating remotely from my team and finally got a hold of the edu robot kit and have managed to program and download it. I got started on this because there is no autonomous mode in the edu default code and want to add it, somehow simulating the autonomous_mode.

I want to be sure I'm not misunderstanding anything before I procede.

Thanks.

Dan Rasmussen
  #2   Spotlight this post!  
Unread 03-02-2004, 13:15
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
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: 8,801
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: User_Autonomous_Code() questions

It's not you.

I think there have been quite a few late, late nights at IFI getting this stuff ready, and you know there's always a bug in software. You just may not know what it is yet.

We changed this around to where it made sense as you have done.
We decided to go through Process_Data_From_Master_uP() to check switches like the competition bit, then do the branch to auto or driver code.

Ours looks like:
Code:
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {                                 /* I'm slow!  I only execute every 26.2ms because */
                                      /* that's how fast the Master uP gives me data. */
      Getdata(&rxdata);   /* Get fresh data from the master microprocessor. */

      Process_Data_From_Master_uP();  /* Process switch/joystick changes */

      if (autonomous_mode)            /* DO NOT CHANGE! */
      {
        User_Autonomous_Code();    /* Autonomous drive controls */
      }
      else
      {
        User_Driver();                     /* User driver controls */
      }

      Generate_Pwms(pwm13,pwm14,pwm15,pwm16); /* N/A for EDU */

      Putdata(&txdata);             /* DO NOT CHANGE! */
    }

    Process_Data_From_Local_IO();
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 03-02-2004 at 14:22.
  #3   Spotlight this post!  
Unread 03-02-2004, 15:13
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: User_Autonomous_Code() questions

I'm not sure about this, so don't quote me, but I believe you are actually able to read the operator inputs once at the start of the match. For instance, assuming that is true, you could have your autonomous function selected by switches that are part of whatever panel you have for the drivers instead of them having to be on the robot.

Of course, maybe I'm wrong and the thing is just incorrectly written...
__________________

  #4   Spotlight this post!  
Unread 03-02-2004, 15:21
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: User_Autonomous_Code() questions

Quote:
Originally Posted by Texan
I'm not sure about this, so don't quote me, but I believe you are actually able to read the operator inputs once at the start of the match. For instance, assuming that is true, you could have your autonomous function selected by switches that are part of whatever panel you have for the drivers instead of them having to be on the robot.

Of course, maybe I'm wrong and the thing is just incorrectly written...
This is based on last year, but I think it still applies. During the competition, when you turn the robot on it is in Disabled mode. The information from the OI is still being sent to the RC but the RC outputs are disabled. We had a thumbwheel switch (little plastic digit with a button to increment/decrement) on the OI to pick the program. While the robot was disabled we updated a global variable with the program number from the OI. Once autonomous started we used that global variable to pick which program to run.
  #5   Spotlight this post!  
Unread 03-02-2004, 15:25
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: User_Autonomous_Code() questions

Quote:
Originally Posted by seanwitte
This is based on last year, but I think it still applies.
And they all told me it was impossible when I suggested that...
__________________

  #6   Spotlight this post!  
Unread 03-02-2004, 15:33
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: User_Autonomous_Code() questions

Quote:
Originally Posted by Texan
And they all told me it was impossible when I suggested that...
Don't hold me to it, this is pure speculation. You can build the competition mode dongle using the plans on IFI's web site and test it for yourself.
  #7   Spotlight this post!  
Unread 05-02-2004, 19:58
Code\\Pilot Code\\Pilot is offline
< Only smart people see my avatar
AKA: Rafael Estrada
FRC #1065 (Tatsu)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Florida
Posts: 53
Code\\Pilot is an unknown quantity at this point
Send a message via AIM to Code\\Pilot Send a message via MSN to Code\\Pilot
Re: User_Autonomous_Code() questions

can you help me?

I have pasted a code in the part that says "add your own autonomous code here",.
Then I Closed the switch in the competition port, the controls disable, but autonomous didn't run.
What should i do?
Thanks.
__________________
Join the Red revolution, give me some RED rep!!!!
if it doesn't work, don't force it. Go get a bigger hammer.

int run = 0;
int robot_chasing_you = 1;

if (robot_chasing_you)
{
run = 254;
}

I got 48 Gmail invites left, pm me with your e-mail so i can send you one.
  #8   Spotlight this post!  
Unread 06-02-2004, 15:01
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: User_Autonomous_Code() questions

Close the switch for auto mode. Check the doc on IFI's site. But be careful: I already fried our OI doing that ("This is what happens when programmers get bored ...") Fortunately, That was Saturday and we got back Thursday .
  #9   Spotlight this post!  
Unread 07-02-2004, 07:16
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: User_Autonomous_Code() questions

Instead of risking frying stuff , for testing you could use preprossesor directives to make the tests for autonomous mode always true when a certain macro is/isn't defined. Something like this:

main.c (in main())
Code:
 while (1)   /* This loop will repeat indefinitely. */
 {
 
    ...
 
 	if (statusflag.NEW_SPI_DATA)	  /* 26.2ms loop area */
 	{
 	  Process_Data_From_Master_uP();
 
 #ifndef AUTO_TESTING
 	  if (autonomous_mode)
 	  {
 		User_Autonomous_Code();
 	  }
 #else
 		User_Autonomous_Code();
 #endif
 	}
 	
 	...
 
 }
user_routines_fast.c (in User_Autonomous_Code())
Code:
 #ifndef AUTO_TESTING
 while (autonomous_mode)   /* DO NOT CHANGE! */
 #else
 while(1)
 #endif
 { 
   if (statusflag.NEW_SPI_DATA)	  /* 26.2ms loop area */
   {
 	  Getdata(&rxdata);
 
 	  autonomousRun(autonomousModeSelection);
 	  Putdata(&txdata);
   }
 }
auto_testing_setting.h
Code:
 #define AUTO_TESTING
Just #include auto_testing_setting.h in main and user_routines fast and your autonomous stuff will run. This doesn't stop after 15 sec, but it can be useful for testing your IR homing works or something like that.

Don't forget to comment the #define out when you're in competition.
__________________

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
3 Questions!!! (1/5/04) Andy Grady General Forum 8 05-01-2004 16:01
$3500 limit - Who does not have questions Raul Rules/Strategy 5 12-01-2003 11:31
Update 7 - Behind Schedule (or out of questions)? archiver 2000 2 23-06-2002 22:58
height questions Team461 Off-Season Events 3 29-10-2001 21:51
Legal way to remove bottles? and other questions jrukes Off-Season Events 4 15-10-2001 22:35


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

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