|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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) */
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 want to be sure I'm not misunderstanding anything before I procede. Thanks. Dan Rasmussen |
|
#2
|
|||||
|
|||||
|
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();
Last edited by Mark McLeod : 03-02-2004 at 14:22. |
|
#3
|
||||
|
||||
|
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
|
|||
|
|||
|
Re: User_Autonomous_Code() questions
Quote:
|
|
#5
|
||||
|
||||
|
Re: User_Autonomous_Code() questions
Quote:
![]() |
|
#6
|
|||
|
|||
|
Re: User_Autonomous_Code() questions
Quote:
|
|
#7
|
|||
|
|||
|
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. |
|
#8
|
|||||
|
|||||
|
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
|
||||
|
||||
|
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
}
...
}
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);
}
}
Code:
#define AUTO_TESTING ![]() Don't forget to comment the #define out when you're in competition. ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |