![]() |
Sending variables to Auto Mode
Hey,
As ship date ominously approaches, our team is scrambling to get some testing in. Currently our robot is set up to do all three autonomous positions (forward, middle, and back) however I've had some problems setting up our toggle switch so we can quickly toggle between positions. Basically we've got a custom 3-state DPDT switch hooked up to our OI through Port 3 so that Switch Forward makes p3_sw_trig true, and switch back makes p3_sw_top true... if you know what I mean. Anyway, the 3-state switch is used to determine our position in autonomous, but we also use it for harvesting and expelling balls in manual mode. It works properly in manual mode so I know it's wired and working properly. Getting it to work with auto mode is not so successful. Let me show you what I have set up: main.c: Code:
char position = 0;Code:
char pos = 0;Code:
void User_Autonomous_Code(char position)Thanks for the help! |
Re: Sending variables to Auto Mode
The problem is simple. When autonomous mode begins, all inputs from the OI are set to their neutral/off state. So neither trig_fwd nor trig_rev will be active when you read them the first time after the autonomous mode flag is set.
Fortunately, the solution too is simple. Instead of always calling Process_Data_From_Master_uP(), inside main(), only call it if you're not in autonomous mode. Make it the else clause of your if (autonomous_mode) statement. Make position a global (or static local) variable so you can use it later. |
Re: Sending variables to Auto Mode
Thanks for the response.
So basically you're saying that when autonomous_mode is true, everything from the OI is set to neutral, or off? So that means when we're at the real competition, as soon as the bots are activated, they're put into autonomous mode, right? So that wouldn't work because it would never go to Process_Data_From_Master_uP()... Although, when we start the bots up, they are running, but in a disabled state... Could the bots receive values from the OI before the match starts and then use them in auto mode? You know what I mean? |
Re: Sending variables to Auto Mode
Quote:
|
Re: Sending variables to Auto Mode
Try this:
instead of of doing: position = Process_Data_From_Master_uP(); do this: if (!autonomous_mode) { position = get_auto_mode(); } The write a new function that all it does is return the position of the switch. We put ours in a seperate file that is just the TOLTECH's code. During the disable and user modes you want the position to be updated. I'm not 100% sure how the game masters will transition to Autonomous. If they switch to autonomous BEFORE the loop hits the position assignment, then you'll get a 0 (or whatever you default case is). This solved the problem for us. Sean Quote:
|
| All times are GMT -5. The time now is 16:58. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi