Go to Post And another big factor in winning. Luck. - Carol [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-01-2011, 20:03
el-zoroo el-zoroo is offline
Chief Operating Officer
AKA: Zuhair
FRC #2374 (Crusaderbots)
Team Role: Leadership
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Beaverton, OR
Posts: 13
el-zoroo is an unknown quantity at this point
Encoder fixed in WPILib 2011?

Hi,

Our team is planning to use Encoders and PID for our robot this year. According to this thread, there was a bug in how the Encoder class worked last year. I have already looked through the Encoder.java source code from this year and it appears to have been changed from what was reported in the thread. I just wanted to confirm that Encoder.getRate() indeed has been fixed for this year.

Thanks!
  #2   Spotlight this post!  
Unread 17-01-2011, 03:17
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Encoder fixed in WPILib 2011?

We believe we have fixed it. Please let us know if you have any problems.

-Joe
  #3   Spotlight this post!  
Unread 17-01-2011, 09:23
ajlapp ajlapp is offline
Registered User
AKA: Anthony Lapp
None #0118 (Team RUSH and Robonauts)
 
Join Date: Sep 2001
Rookie Year: 1996
Location: Ortonville, MI
Posts: 648
ajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond repute
Re: Encoder fixed in WPILib 2011?

We tried it saturday and had problems.

We had defined two encoders, one encoder would get both rate and distance properly, the second encoder would only get distance.

I'll confirm with my team that we were using the newest encoder block.
__________________
Anthony Lapp
FIRST Engineering Mentor
Owner/Operator 221 Robotic Systems
221 Robotics Systems - Quality Hardware, Made in the USA
RobotOpen
anthony@221robotics.com
Twitter us: @221RobotSystems
Team 1 --> 94 --> 68 --> 221 --> 857 --> 27 --> 118
Design Engineer/Fabricator and 17 year vet
Team Rush (FRC27) and Robonauts (FRC118)
  #4   Spotlight this post!  
Unread 17-01-2011, 09:46
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by ajlapp View Post
We tried it saturday and had problems.

We had defined two encoders, one encoder would get both rate and distance properly, the second encoder would only get distance.

I'll confirm with my team that we were using the newest encoder block.
wow. I had that EXACT SAME ISSUE, in LabVIEW. I switched one from 1x to 4x (so it uses an FPGA encoder instead of an FPGA Counter) and it worked, until I rebooted, and it happened again.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #5   Spotlight this post!  
Unread 17-01-2011, 17:40
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Encoder fixed in WPILib 2011?

Can any of you try changing the averaging setting on the timer for the Counter or Encoder that you're using (with the ConfigureTimer VI). I'd really like to know what effect if any that has.

Thanks,
-Joe
  #6   Spotlight this post!  
Unread 23-01-2011, 06:56
tluks tluks is offline
Registered User
None #1126 (sparx)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: new york
Posts: 5
tluks is an unknown quantity at this point
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by ajlapp View Post
We tried it saturday and had problems.

We had defined two encoders, one encoder would get both rate and distance properly, the second encoder would only get distance.

I'll confirm with my team that we were using the newest encoder block.
We had a similar issue yesterday in java. We have a "left" encoder and a "right" encoder and only the right encoder would get rate correctly. The left encoder would return NAN. After testing a few other possibilities, we feel that we've solved the problem by only using an "even" encoder. This probably won't make sense without some pseudo code.

Encoder leftEncoder = new Encoder(args); //this will return NAN
leftEncoder = new Encoder(args); //this will return a good rate
Encoder rightEncoder = new Encoder(args); // returns NAN rate
rightEncoder = new Encoder(args); //this will return a good rate

So the reason why our right encoder was working before was because it was the second encoder we constructed....

Jhersh- Is there anything we can do to help you work/understand this issue?

Last edited by tluks : 23-01-2011 at 06:56. Reason: improving the pretend code
  #7   Spotlight this post!  
Unread 23-01-2011, 08:03
MagiChau's Avatar
MagiChau MagiChau is offline
Registered User
AKA: Michael Chau
FRC #0085 (B.O.B. (Built on Brains))
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Zeeland, Michigan
Posts: 875
MagiChau is just really niceMagiChau is just really niceMagiChau is just really niceMagiChau is just really nice
Re: Encoder fixed in WPILib 2011?

Wonder if this code might work for you to cling onto hope you don't need to have that pseudo code.

Quote:
Encoder leftEncoder;
leftEncoder = new Encoder;
Encoder rightEncoder;
rightEncoder = new Encoder;
I think I understand you are saying you need to initialize the encoders twice for each one.

Last edited by MagiChau : 23-01-2011 at 08:06.
  #8   Spotlight this post!  
Unread 23-01-2011, 09:31
tluks tluks is offline
Registered User
None #1126 (sparx)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: new york
Posts: 5
tluks is an unknown quantity at this point
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by ZonChau View Post
Wonder if this code might work for you to cling onto hope you don't need to have that pseudo code.



I think I understand you are saying you need to initialize the encoders twice for each one.
I'd describe just a little differently. I don't think it has to do with the variable initialization. It is more like every other "new'ed" encoder's getRate method doesn't work right. So you have to new one and throw it away, to new the next one which will work. It is like something in the construction of one encoder has side effects that impact the construction of the next one.
  #9   Spotlight this post!  
Unread 23-01-2011, 09:40
MagiChau's Avatar
MagiChau MagiChau is offline
Registered User
AKA: Michael Chau
FRC #0085 (B.O.B. (Built on Brains))
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Zeeland, Michigan
Posts: 875
MagiChau is just really niceMagiChau is just really niceMagiChau is just really niceMagiChau is just really nice
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by tluks View Post
I'd describe just a little differently. I don't think it has to do with the variable initialization. It is more like every other "new'ed" encoder's getRate method doesn't work right. So you have to new one and throw it away, to new the next one which will work. It is like something in the construction of one encoder has side effects that impact the construction of the next one.
Hmm, maybe it has something to do with the channels the encoders use and how they are programmed to be used? I kind of see it as you are making a "space" or else there will be a conflict like possibly of an address being taken by one encoder from another.

Unless, you are implying that it is a problem with the program to receive data.
  #10   Spotlight this post!  
Unread 23-01-2011, 09:59
tluks tluks is offline
Registered User
None #1126 (sparx)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: new york
Posts: 5
tluks is an unknown quantity at this point
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by ZonChau View Post
Unless, you are implying that it is a problem with the program to receive data.
I think I might be implying something along those lines. It seems like something might be going wrong in the lower level wpilibj or fpga software running on the crio. So I am just trying to do a mental dump of everything I have seen so one of our resident masters of the low level code might see a pattern in the behavior we are seeing that points at something in that code or gives them more questions to ask us so we can help get to the root of this "getRate returns NaN" thing
  #11   Spotlight this post!  
Unread 23-01-2011, 10:17
MagiChau's Avatar
MagiChau MagiChau is offline
Registered User
AKA: Michael Chau
FRC #0085 (B.O.B. (Built on Brains))
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Zeeland, Michigan
Posts: 875
MagiChau is just really niceMagiChau is just really niceMagiChau is just really niceMagiChau is just really nice
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by tluks View Post
I think I might be implying something along those lines. It seems like something might be going wrong in the lower level wpilibj or fpga software running on the crio. So I am just trying to do a mental dump of everything I have seen so one of our resident masters of the low level code might see a pattern in the behavior we are seeing that points at something in that code or gives them more questions to ask us so we can help get to the root of this "getRate returns NaN" thing
It you did not already open up the source code for the encoder inside of the WPIlib. That probably will help you. I will try and analyze possible areas that could be the problem before Monday. Will try testing the encoders then. Hopefully someone will be able to find the solution, though I would have confidence in a person that understands low level programming rather than me.
  #12   Spotlight this post!  
Unread 23-01-2011, 12:59
flameout flameout is offline
AKA Ryan Van Why
FRC #0957 (SWARM)
Team Role: Alumni
 
Join Date: Sep 2009
Rookie Year: 2009
Location: Oregon
Posts: 168
flameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to all
Re: Encoder fixed in WPILib 2011?

We encountered the same issue -- I worked around it by simply differentiating myself.

While it was stopped, it returned 0.0. While moving, it returned NaN.
  #13   Spotlight this post!  
Unread 24-01-2011, 03:04
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by tluks View Post
We had a similar issue yesterday in java. We have a "left" encoder and a "right" encoder and only the right encoder would get rate correctly. The left encoder would return NAN. After testing a few other possibilities, we feel that we've solved the problem by only using an "even" encoder. This probably won't make sense without some pseudo code.

Encoder leftEncoder = new Encoder(args); //this will return NAN
leftEncoder = new Encoder(args); //this will return a good rate
Encoder rightEncoder = new Encoder(args); // returns NAN rate
rightEncoder = new Encoder(args); //this will return a good rate

So the reason why our right encoder was working before was because it was the second encoder we constructed....

Jhersh- Is there anything we can do to help you work/understand this issue?
That's an interesting pattern you're seeing there. I'll try to reproduce it tomorrow.

On thing you can tell me is if you think it's related to the order in which they are constructed or the specific hardware that gets allocated. For instance, if you were to allocate one, delete it, then allocate it again, would it work? Or does it only work because the 2nd hardware resource is allocated due to the first one being in use?

Thanks,
-Joe
  #14   Spotlight this post!  
Unread 24-01-2011, 06:04
tluks tluks is offline
Registered User
None #1126 (sparx)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: new york
Posts: 5
tluks is an unknown quantity at this point
Re: Encoder fixed in WPILib 2011?

Quote:
Originally Posted by jhersh View Post
That's an interesting pattern you're seeing there. I'll try to reproduce it tomorrow.

On thing you can tell me is if you think it's related to the order in which they are constructed or the specific hardware that gets allocated. For instance, if you were to allocate one, delete it, then allocate it again, would it work? Or does it only work because the 2nd hardware resource is allocated due to the first one being in use?

Thanks,
-Joe
I'm not sure about the deletion. We aren't doing anything to explicitly delete the first one we construct before constructing the next one, and it is probably unlikely the garbage collector runs between those two lines every time.

For your testing, all the encoders will look ok at rest, returning 0.0. It isn't until they are pulsing that getRate starts to give NaN on the bad ones.

Also, the second encoder we construct works for us even if the digital IO ports are unrelated. We first noticed the pattern by doing the following with two completely separate encoders.

Encoder rightEncoder = new Encoder(rightArgs);
Encoder leftEncoder = new Encoder(leftArgs);

With the above code only the left encoder getRate worked. So we tried swapping the order of construction.

Encoder leftEncoder = new Encoder(leftArgs);
Encoder rightEncoder = new Encoder(rightArgs);

After doing the swap the right encoder getRate started working and the left's started returning 0.0 or NaN. After that, we tried the double construction for each encoder, that I described in the first post, which gave us two encoders with working getRate's!

I'll have access to the code this evening so if there might be anything interesting about the specific args we use they can get posted then.
  #15   Spotlight this post!  
Unread 15-02-2011, 23:08
Jeanne Boyarsky Jeanne Boyarsky is offline
Java Mentor
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 100
Jeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud of
Re: Encoder fixed in WPILib 2011?

How did you create the first (dummy) encoder? Instantiating using the same arguments gives channel in use errors, no?
__________________
Team 694 mentor 2010-present, FIRST Volunteer and Co-organizer of FIRST World Maker Faire Tent
2012 NYC Woodie Flowers Finalist
2015 NYC Volunteer of the Year
Closed Thread


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 13:11.

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