Go to Post "FIRST" is not a verb (yet - give us time, and we will see what happens). - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 31-03-2011, 23:32
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 147
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
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?
Reply With Quote
  #2   Spotlight this post!  
Unread 31-03-2011, 23:52
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
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
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"

Last edited by The Lucas : 31-03-2011 at 23:56.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-04-2011, 00:58
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 147
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
Re: Reading Driver Station Input to select Autonomous Routine

Thats a great idea. Thanks!
Reply With Quote
  #4   Spotlight this post!  
Unread 01-04-2011, 09:49
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 147
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-04-2011, 10:03
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
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?
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
Reply With Quote
  #6   Spotlight this post!  
Unread 01-04-2011, 10:42
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
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'.
Reply With Quote
  #7   Spotlight this post!  
Unread 01-04-2011, 11:49
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,576
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
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:
Originally Posted by The Lucas View Post
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?
They're using a rotary switch, I think it was 16 positions. They would only be ignoring the all switches 0 condition.

Quote:
Originally Posted by Jared341 View Post
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'.
They did run it in practice mode, and it worked.


987, did you ever get a chance to try it with the virtual I/O?
Reply With Quote
  #8   Spotlight this post!  
Unread 01-04-2011, 14:16
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Reading Driver Station Input to select Autonomous Routine

Quote:
Originally Posted by Joe Ross View Post
987, did you ever get a chance to try it with the virtual I/O?
Had it working with Cypress and C++ last year (only difference is we essentially use IterativeRobot Template). We eventually stopped using the Cypress because it is unreliable when the Classmate is not plugged in (it doesn't always get the required power).
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
Reply With Quote
  #9   Spotlight this post!  
Unread 03-04-2011, 10:00
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 147
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
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)
	{
		// Check the auto sequence number only in disabled mode!  During auto, all
		// DS inputs are zeroed.
		int seq = 0;
		bool Dec1 = !ds->GetDigitalIn(1); 
		bool Dec2 = !ds->GetDigitalIn(3);
		bool Dec4 = !ds->GetDigitalIn(5);
		bool Dec8 = !ds->GetDigitalIn(7);
		
		if (Dec1 == true)
		{
			seq += 1;
		}
		if (Dec2 == true)
		{
			seq += 2;
		}
		if (Dec4 == true)
		{
			seq += 4;
		}
		if (Dec8 == true)
		{
			seq += 8;
		}
		if (seq != 0) AutoSeq = seq;
	}
In our constructor, we have "ds = DriverStation::GetInstance();"

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! :-)

Last edited by Hjelstrom : 03-04-2011 at 16:24.
Reply With Quote
  #10   Spotlight this post!  
Unread 03-04-2011, 11:22
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Reading Driver Station Input to select Autonomous Routine

Quote:
Originally Posted by Hjelstrom View Post
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.

int seq = 0;
bool Dec1 = !ds->GetDigitalIn(1);
bool Dec2 = !ds->GetDigitalIn(3);
bool Dec4 = !ds->GetDigitalIn(5);
bool Dec8 = !ds->GetDigitalIn(7);
You are inverting all the switches when you get them (bool Dec1 = !ds->GetDigitalIn(1) so it makes sense that the the seq goes to 15 in auto. So in auto all the GetDigitalIn() calls return false then they are inverted to true and stored in Dec1-8. I am not sure exactly how your rotary is wired that you needed to invert the inputs (I imagine it is grounding one input at a time). In the past (we dont use the Cypress this year) we have used a rotary switch and soldered resistors between adjacent positions to make a variable voltage divider then read it in as an analog value check to see if it is in different ranges.

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:
Originally Posted by Hjelstrom View Post
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! :-)
Auto going well, that is an understatement. Great job on that consistent 2 uber tube auto! Are you checking the lines at times for alignment? It is truly unique set up for 2 tube with you starting at the Y and going across the other robot to get the tube at the other line.

I watched the impressive LV archive you guys set up. Congrats on your first 2 regional win season!
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
Reply With Quote
  #11   Spotlight this post!  
Unread 03-04-2011, 16:22
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 147
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
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).
Reply With Quote
Reply


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


All times are GMT -5. The time now is 03:07.

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