Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Receiving info from OI to select autonomous mode (http://www.chiefdelphi.com/forums/showthread.php?t=34702)

cabbagekid2 16-02-2005 14:40

Re: Receiving info from OI to select autonomous mode
 
Quote:

Originally Posted by Alan Anderson
Whoops. SlimBoJones pointed out the way to do it. If the FIRST field system sets the autonomous mode pin active early, even before field setup, and doesn't release it until the beginning of teleoperated mode, that would indeed keep the robot from ever getting information from the OI controls until after the match begins.

It would also break every autonomous program I've ever seen, since they universally assume the autonomous_mode flag will become active at the start of the match. They would blindly start running as soon as communication with the OI was established, but the robot would still be disabled. Default code version 2.4 works that way. Can someone with both a copy of the "scripted autonomous" software and a grasp of the software issues involved look to see how it's handled there?

To look at the OI switches during disabled mode (before autonomous is on) do we have to add a fuction that looks at the variable disable_mode and then if it is on, stores the operator joystick values in a temporary variable.

This is what we have added into our program for now. But my question is that...if your program in main.c checks to see if disable_mode is on before autonomous_mode won't it still be able to recieve values from the joysticks? Even if it only does it one time? Or is there some other program in the master processor somewhere that prevents this from happening if both autonomous and disable are on at start up.

CmptrGk 16-02-2005 15:13

Re: Receiving info from OI to select autonomous mode
 
ok, so if we were to put the variables for autonomus switches in the Process_data_from_local_IO section the robot would never see these numbers while autonomus is enabled. im asking this becasue this is where i have the switches now and even there they are causing trouble. the way i have it set up, is that the values are read from four swiches. they are p4_sw_trig, p4_sw_aux1, p4_sw_aux2, and p1_sw_trig(due to that whole port duplication thing).

so if i had this code in Process_data_from_local_IO

if(p4_sw_trig == 0 && p4_sw_aux==0 && p4_sw_aux2== 0 && p1_sw_trig == 0)
{
auton_state = 0;
}

would these values never acutally get to the rc?

ive already lost to much sleep working on the code, i really want to finish it before atlanta comes around.

Deetman 16-02-2005 16:03

Re: Receiving info from OI to select autonomous mode
 
Quote:

Originally Posted by CmptrGk
ok, so if we were to put the variables for autonomus switches in the Process_data_from_local_IO section the robot would never see these numbers while autonomus is enabled. im asking this becasue this is where i have the switches now and even there they are causing trouble. the way i have it set up, is that the values are read from four swiches. they are p4_sw_trig, p4_sw_aux1, p4_sw_aux2, and p1_sw_trig(due to that whole port duplication thing).

so if i had this code in Process_data_from_local_IO

if(p4_sw_trig == 0 && p4_sw_aux==0 && p4_sw_aux2== 0 && p1_sw_trig == 0)
{
auton_state = 0;
}

would these values never acutally get to the rc?

ive already lost to much sleep working on the code, i really want to finish it before atlanta comes around.


Just a quick reply here, but...

You need to make sure you grab the state of the switches in a seperate variable BEFORE autonomous mode is enabled or else you will lose your inputs. We did this in main.c last year and we are planning on doing it again this year.

An example of this can be found at http://www.osufirst.org/twiki/pub/OS...nalCode/main.c

Specifically:
Code:

autonomous_on = ( winchPneuSwitch == 1 ) ? 0 : autonomous_on;
We expanded upon this further for nationals last year, but I don't think I have that code readily available on the web.

russell 16-02-2005 23:01

Re: Receiving info from OI to select autonomous mode
 
Earlier this year I got to our shop early one day, and a new person interested in programming was there too. So we busted out kitbot and I decided it would be cool to write a dead reckoning code that would just make it drive really fast, then spin in place (I had never written dead reckoning code before so yeah...). The point is that I used a counter to tell it when to do what, and it incremented the counter within the autonomous section. I worried that if both my autonomous switch, and my disabled switch were on the counter would start counting early, but it did not. To me this means that if the bot is in autonomous and disabled (at least using a dongle) the autonomous code doesnt run. Now I forget why that was important to this conversation, but I do remember that it was somehow.... Oh yeah and I cant 100% garuntee that I was using the latest firmware there either.

dlavery 16-02-2005 23:24

Re: Receiving info from OI to select autonomous mode
 
Quote:

Originally Posted by dlavery
Actually, this would not work. A similar question came up in another thread, so I asked Tony Norman at IFI exactly how and when various data may be passed between the OI and RC. Tony double-checked and said that the field control system will not allow any data to be passed between the OI and the RC prior to the start of the match and the completion of the autonomous period. The OI and RC will both be active, but the field control system (which is different this year than last year) will prevent them from communicating.

So if you want to have a switch or dial setting to choose between autonomous programs, you should put it on the robot and not on the OI. The RC will be able to read the state of any switches, sensors, etc. that are local to the robot when it is powered up, and can use that information during the autonomous period.

Just to complete the story, if the robot is disabled later during the teleoperated period (like when the human player steps off the pressure pad sensor) communications between the RC and OI can continue. But the field control system will disable all the outputs from the RC so the system cannot activate any motors or actuate any other devices.

-dave

OK, forget (almost) everything that I just said. I talked to Tony again tonight, and we are revising our answer (in other words, I got it wrong; I blame it on sunspots affecting my cell phone and causing static so I could not hear what he really said the first time). The CORRECT correct answer is that prior to the start of the match, the OI and RC do indeed communicate. The motor outputs are disabled, but data from the OI can be received by the RC (in other words, the robot is in "disabled" mode as described earlier). When the match starts and the autonomous period begins, the communication channel between the OI and RC is interupted, and they can no longer pass data. Then the autonomous period ends and normal operations begin.

So, yes it appears that it is indeed technically possible to set switches/controls on the OI prior to the start of the match, and have the RC receive the information. However, before we all rush off to implement that capability, note Question #1598 just posted on the FIRST Q&A system:

Quote:

Q: At the start, the robot is disabled and then in autonomous mode. While disabled, is it possible to set switches (on the OI, and not the RC) to tell the robot which autonomous program to run?
A: Yes it is technically possible, but you will not be allowed once the vision tetras are placed on the field.
Oh well, so much for that idea...

-dave

DKolberg 17-02-2005 00:38

Re: Receiving info from OI to select autonomous mode
 
One method I have used for the last two years is storing data in the EEProm while in disabled mode. This way the value is there independent of whatever method they choose to use on the field. There was some code posted last year with some routines for accessing the EEProm. Just load some autonomous Variables from EEProm in the initialization area. While in disabled mode use buttons or joystick position along with a button to select the autonomous variables.

Workaphobia 17-02-2005 00:56

Re: Receiving info from OI to select autonomous mode
 
Thanks, that's a big relief. :) If we couldn't use the switches we set up today on the OI, I'd have to grab some jumpers and hope that the person switching them on the digital input pins wouldn't break the RC. Or I might've tried using an EEPROM module. This is a lot easier.


All times are GMT -5. The time now is 10:39.

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