Go to Post Thats what makes FIRST so unique how culture and the time is reflected through our bots, but at the same time we all get along...with no problem. - Dan Richardson [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 12-02-2014, 01:50
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Gyro reset() troubles

We were testing out some autonomous code over the weekend which utilized the gyro for turning. We were noticing that about 50% of the time our code didn't seem to be working. After placing in some debug print statements (see below) we confirmed the source of the problem.
The value printed before and after the reset are quite often the same non-zero number. About 50% of the time. This is quite repeatable on our hardware. I've tried multiple gyro sensors with similar results.

Code:
public void resetGyro() {
    double before = getGyroAngle();
    gyro.reset();
    System.out.println("Gyro Before: " + before + " After: " + getGyroAngle());
}
Other than it not resetting reliably, the gyro appears to be working as expected.

I was wondering if any one else was experiencing this behavior. It looks like the gyro.reset() call ultimately just boils down to the following:
Code:
NiFpga.writeU32(m_DeviceHandle, kReset_Addresses[m_SystemIndex], 1, status);
I know there were changes made in the FPGA, was a bug introduced?


We have a workaround, but knowing others are seeing this problem would at least restore sanity to my world.
__________________
http://team2168.org
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2014, 05:54
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 108
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Gyro reset() troubles

My understanding of the gyro is that a reset is not instantaneous. It takes a bit of time for the gryo to zero itself and during this time it is best not to move. If you changed your code to the following, you might be more likely to see a value closer to zero:

Code:
public void resetGyro() {
    double before = getGyroAngle();
    gyro.reset();
    Timer.delay(2.0);
    System.out.println("Gyro Before: " + before + " After: " + getGyroAngle());
}
Adding delays to wait for the gyro to initialize is undesirable. Our general approach has been:
  • Avoid resetting the gyro (maybe reset it once during initialization, but avoid it during the autonomous and teleop periods).
  • Make autonomous turns based off the current gyro setting. For example, if the want to rotate 90 degrees, use (90.0 + getGryoAngle()) as your destination instead of resetting and using 90.0.
  • Add a smart dashboard button to reset the gyro while testing.
  • Determine a gain correction for the gyro and apply this to each reading. For example, if you rotate the robot 10 times and the gryo reports 3500 degrees, the gain correction would be (3600.0 / 3500.0) and you would then multiply the raw values reported by the gyro using this gain correction factor.

Hope that helps,
Paul
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2014, 12:33
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,590
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: Gyro reset() troubles

Quote:
Originally Posted by pblankenbaker View Post
My understanding of the gyro is that a reset is not instantaneous. It takes a bit of time for the gryo to zero itself and during this time it is best not to move. If you changed your code to the following, you might be more likely to see a value closer to zero:
The gyro open performs a gyro calibration which takes several seconds, but is blocking. Gyro reset does not calibrate and should be quick. It's just zeroing the accumulators. I wonder if there is a synchronization issue and a tiny delay would make it work reliably.

We also never reset the gyro except at the beginning of autonomous, and track everything relative to the starting angle. It ends up being much more accurate if you ever want to come back to the starting angle.
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2014, 14:32
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Gyro reset() troubles

Yea I was wondering if the gyro zeroed after the reset() was called myself, our command code was running after the code I listed above. This code was also printing out the current gyro angle. In the innumerable times I executed code, I never witnessed the current angle to suddenly jump to zero (what you would expect to happen if it were time related).

We are latching in our current heading at the beginning of commands as a workaround. There still seems to be a bug though.

Would anyone mind instrumenting their code and seeing if the problem is present on your hardware as well? All of my crios are tied up at the moment.
__________________
http://team2168.org

Last edited by otherguy : 12-02-2014 at 23:53. Reason: fixed autocorrect errs
Reply With Quote
  #5   Spotlight this post!  
Unread 12-02-2014, 16:12
Jared's Avatar
Jared Jared is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Aug 2013
Rookie Year: 2012
Location: Connecticut
Posts: 602
Jared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond repute
Re: Gyro reset() troubles

The reset() method is a bit goofy. It does some type of calibration with the cRIO when you call it, which can take up to a second to complete, or sometimes happens instantly.

The reset method not only sets the current angle to zero, but recalibrates and adjusts some unknown thing in the FPGA by writing some random value to it's memory.

To avoid this, I don't ever call their reset method, but instead add my own that will subtract the angle that was measured at the time of the reset from the current angle. This just zeros the angle rather than doing some weird calibration sequence.
Reply With Quote
  #6   Spotlight this post!  
Unread 12-02-2014, 20:50
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Gyro reset() troubles

As Joe pointed out, the reset() method only zeros the accumulator as you can see in this code from the Gyro class:

Code:
    public void reset() {
        if (m_analog != null) {
            m_analog.resetAccumulator();
        }
    }
I'm not sure why it isn't resetting immediately unless, as was suggested, there is some delay in the hardware. I'd also suggest to try adding a delay after doing the reset to see if it makes a difference.

Let us know if that helps.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #7   Spotlight this post!  
Unread 12-02-2014, 23:50
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Gyro reset() troubles

Quote:
Originally Posted by BradAMiller View Post
I'm not sure why it isn't resetting immediately unless, as was suggested, there is some delay in the hardware. I'd also suggest to try adding a delay after doing the reset to see if it makes a difference
As I stated in my last post, we had a command executing after the reset method was being called. The command was printing out the current gyro angle. If the gyro didn't zero after the reset call, it never was zeroed.

I don't think this is time related.

And I've never had to wait for the reset method to zero the gyro in the past. We've used this method extensively in the past and have never had a problem with it previously.
__________________
http://team2168.org
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 12:50.

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