![]() |
Reading Driver Station Input to select Autonomous Routine
In past years, we had a little piece of code that was in our 'Disabled()' function which read some switches on our driver station to select an autonomous routine (basically set a variable to the number of the selected routine). This year we can't seem to get that to work at "real" fields. It works fine when we're testing but when we're hooked up to the field, the code within Disabled() never seems to get run before the match starts and we don't end up running the auto routine we intended to.
Someone said it should be ok to read the switches within our "Autonomous()" function but that seems to always give us all zeros. For now, we're just hard coding our selection and deploying new code but it would be nice to get the switches working again. Any ideas? |
Re: Reading Driver Station Input to select Autonomous Routine
Did you try wrapping a if (IsDisabled()) {} around the switch checking code in Disabled() so it doesn't get zeroed out on the last run as it transitions into auto. It sounds like you are using SimpleTemplate, correct?
Good luck at Las Vegas |
Re: Reading Driver Station Input to select Autonomous Routine
Thats a great idea. Thanks!
|
Re: Reading Driver Station Input to select Autonomous Routine
Hmm, that can't be it because once we read a non-zero value, we ignore zero (the code won't over-write the sequence number with zero). We'll try some more things today and I'll report if we figure something out, maybe there's a mistake that we're missing.
|
Re: Reading Driver Station Input to select Autonomous Routine
are you reading digital switches or analog values? Ignoring a zero value on a digital switch is generally a problem, maybe post a code snippet?
|
Re: Reading Driver Station Input to select Autonomous Routine
Have you tested your code with the "Practice" option in the Driver Station? This function walks through the Disabled/Autonomous/Teleop states in a manner that is supposedly identical to FMS'.
|
Re: Reading Driver Station Input to select Autonomous Routine
I worked with 987 a little on this issue in San Diego, but not having used the cypress or C++ before, we weren't able to figure it out.
Quote:
Quote:
987, did you ever get a chance to try it with the virtual I/O? |
Re: Reading Driver Station Input to select Autonomous Routine
Quote:
|
Re: Reading Driver Station Input to select Autonomous Routine
We're using a rotary switch which is just like 4 dip switches. Using 4 bits you get a number from 0-15. We normally call this in "Disabled()". In 'practice' mode it works, we can run different auto sequences at will but we always switch the robot to 'Disabled', then line it up, then 'Enable' again.
Here is the code to read the switch. I do see a logic/comment flaw in that if the inputs were really all zero, then the seq number would be 15 not zero. So maybe in auto the inputs are all pulled high? I recall in previous years, if you ran code like this during auto, you'd always get zero back as the desired sequence. We're using 'SimpleRobot' and this function is called from 'Disabled()' Code:
void Read_Auto_Switch(void)With a little experimentation, I think we could have sorted out what was going on yesterday but the auto is working so well we decided not to touch anything! :-) |
Re: Reading Driver Station Input to select Autonomous Routine
Quote:
Wrapping an IsDisabled() around this function as suggested before would work (stop AutoSeq being set to 15). You can also check that (seq != 15) before setting AutoSeq. Also a CD posting tip for the future: there are code tag that you can wrap around posted code to preserve the indentation and make it easier to read. You just need to press the # icon on top of the post box to put code tags in your post. Code tags also work well for tab spaced tables (like one you might copy from Excel) Quote:
I watched the impressive LV archive you guys set up. Congrats on your first 2 regional win season! |
Re: Reading Driver Station Input to select Autonomous Routine
Sorry, I haven't conveyed exactly whats going on as well as I should. That code generates seq=0 when in autonomous. So that would imply to me that all of the switches read 1 during auto making the comment in the code incorrect. (thanks for the code tag idea too, I'll try to go back and edit that)
When I get time with the robot again, I'll look over the wiring and do some experiments to re-test the assumptions we're making. If I recall correctly the switch is wired to simply connect the digital inputs to ground so we're assuming there are pullup resistors on the DS board. That would be consistent with reading all 1's and also consistent with the way the code is inverting each bit before adding everything up. Thanks very much for your brain cycles! It was a pleasure working with 365 a couple of years ago in Atlanta! You guys have a terrific team. We do use the line sensor and encoders to know when to move to the next state. Thanks for the compliments. My son (8th grade) wrote most of the code for the robot. He's really picking up programming; he's already published an indie xbox 360 game too (its named "Phat Fly" if you want to look it up). |
| All times are GMT -5. The time now is 13:25. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi