Go to Post Learn the theory in the classroom and pick up the practical through clubs (FIRST, mini Baja, SAE)... you really need the scale balanced in the middle - Greg Needel [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 18-03-2015, 08:57
Aero Aero is offline
consumes pizza, produces code
AKA: Ari Lotter
FRC #0865 (Warp7)
Team Role: Programmer
 
Join Date: May 2013
Rookie Year: 2013
Location: Toronto
Posts: 30
Aero is on a distinguished road
Large amounts of gyro drift

I'm trying to use the KOP Gyro to control our orientation during auton, but the angle is drifting a lot without the robot moving.
This makes our robot drive in curves, and not in straight lines.
We're not doing anything funky programming-wise, the drift is observable with barebones code

Code:
from wpilib import SampleRobot, run, Gyro, Timer, SmartDashboard
class GyroTest(SampleRobot):
	def robotInit(self):
		self.gyro = Gyro(0)
	
	def disabled(self):
		while self.isDisabled():
			SmartDashboard.putNumber('Gyro', self.gyro.getAngle())
			Timer.delay(0.01)

if __name__ == "__main__":
	run(GyroTest)
The gyro starts at 0 (as it should) and without the robot moving, slowly starts creeping at a rate of about -1 degree / 5 seconds.

Any ideas? We've already checked our gyro's pwm cable.
__________________
2014 Waterloo Regional Winner (254 & 2056)
2014 Curie Semifinalist (118, 359 & 4334)
2014 Fall Fiesta Finalist (2056, 4476)
6 X Gracious Professionalism Award Winner
  #2   Spotlight this post!  
Unread 18-03-2015, 09:02
Ben Wolsieffer Ben Wolsieffer is online now
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Large amounts of gyro drift

Are you letting the gyro calibrate correctly? You need to make sure the robot does not move at all during the calibration process, which occurs when you construct the gyro object and takes 5 seconds.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
  #3   Spotlight this post!  
Unread 18-03-2015, 09:14
Aero Aero is offline
consumes pizza, produces code
AKA: Ari Lotter
FRC #0865 (Warp7)
Team Role: Programmer
 
Join Date: May 2013
Rookie Year: 2013
Location: Toronto
Posts: 30
Aero is on a distinguished road
Yep, robot is totally still for calibration.
__________________
2014 Waterloo Regional Winner (254 & 2056)
2014 Curie Semifinalist (118, 359 & 4334)
2014 Fall Fiesta Finalist (2056, 4476)
6 X Gracious Professionalism Award Winner

Last edited by Aero : 18-03-2015 at 09:23.
  #4   Spotlight this post!  
Unread 18-03-2015, 10:07
lark95's Avatar
lark95 lark95 is offline
Red Ranger
AKA: Joe L.
FRC #3418 (RoboRiot)
Team Role: Driver
 
Join Date: Sep 2014
Rookie Year: 2012
Location: Wisconson
Posts: 123
lark95 is a glorious beacon of lightlark95 is a glorious beacon of lightlark95 is a glorious beacon of lightlark95 is a glorious beacon of lightlark95 is a glorious beacon of light
Re: Large amounts of gyro drift

we had some really bad problems with this. Turned out that the signal wire to the gyro was going right by a cim, and speed controller. The RF noise was just enough to get the gyro to drift. We replaced the signal cable with a shielded one and all our problems were gone.
Hope this helps
  #5   Spotlight this post!  
Unread 18-03-2015, 10:37
SousVide SousVide is offline
Registered User
no team
 
Join Date: Jan 2011
Location: CA
Posts: 91
SousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to behold
Re: Large amounts of gyro drift

Gyros drift naturally overtime. Numerous ways to deal with this: You can re-zero constantly; you can assume drift overtime and compensate in your code; you can combine data with an accelerometer and/or magnet heading.

See "Drift" here:
http://www.phidgets.com/docs/Gyroscope_Primer

and here:
http://www.instructables.com/id/Guid...Arduino-inclu/
  #6   Spotlight this post!  
Unread 18-03-2015, 10:46
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,648
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Re: Large amounts of gyro drift

I have no financial interest in AndyMark or Kauai Labs but we are using the navX MXP Robotics Navigation Sensor and we LOVE it.

I was a complete skeptic when the coding team insisted that we could do Field Centric driving using our Wild Swerve modules. But after looking into it, asking a real roboticist that I am lucky enough to work with, and, most importantly, after seeing it work on Rover (Overclocked's fall "Practice Project"), I am a complete and total fanboy.

The navX MXP is amazing. If you are not using it, you should be.

It takes the literal "rocket science" technology from InvenSence IMU and puts it in an beautiful and well behaved (and Open Source/Open Hardware) wrapper.

IT IS AMAZING.

If you are using a gyro and you're not using a navX, I think you're missing the boat.

Free advice, worth every penny.

Dr. Joe J.

P.S. They claim 1 degree per minute drift. Again, I was skeptical but I think actually, in most cases, they do better than that. We will often practice for 20 minutes and stop because the motors are hot or the battery is dead not because we need to rezero the gyro. YMMV but that is our experience.
__________________
Joseph M. Johnson, Ph.D., P.E.
Mentor
Team #88, TJ2

Last edited by Joe Johnson : 18-03-2015 at 10:48.
  #7   Spotlight this post!  
Unread 18-03-2015, 11:50
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,086
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Large amounts of gyro drift

We're using python + KOP gyro, and it works fine for me.

I've had issues with gyros in past years drifting too much... I think it's just something that's particular to some gyros.

Make sure you're actually using the same gyro that the WPILib is expecting you to use. If the volts per g parameter is wrong, then you'll get behavior similar to what you're describing.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #8   Spotlight this post!  
Unread 18-03-2015, 15:53
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 358
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Re: Large amounts of gyro drift

Here is some calibration code I found here on Chielf Delphi. It basically involves adjusting the sensitivity with the gyro sitting still so that it doesn't change. It seems to help, although I don't know how accurate it was after changing the sensitivity.

Code:
	void CalibrateGyro()
	{
		// gyro should be out of cal mode by now,
		// try to find and set best sensitivity

		float fAngle;

		for(int uLoop = 0; uLoop < 10; uLoop++)
		{
			float fAngleSensitivity = Gyro::kDefaultVoltsPerDegreePerSecond;
			bool bLastAdjustmentWasIncrease;

			// reset the accumulator, stop a while and see if we drifted

			gyro.Reset();
			// taskDelay(sysClkRateGet() / 4);
			Wait(.001);

			fAngle = gyro.GetAngle();

			if(fAngle > 0.0)
			{
				fAngleSensitivity -= 0.0001;
				bLastAdjustmentWasIncrease = false;
			}
			else
			{
				fAngleSensitivity += 0.0001;
				bLastAdjustmentWasIncrease = true;
			}

			gyro.SetSensitivity(fAngleSensitivity);

			if((fAngleSensitivity > 0.0) && (bLastAdjustmentWasIncrease == false))
			{
				// we were adjusting up then went down a step - good enough
				break;
			}
			else if ((fAngleSensitivity < 0.0) && (bLastAdjustmentWasIncrease == true))
			{
				// we were adjusting down then went up a step - good enough
				break;
			}

			if((fAngleSensitivity >= (Gyro::kDefaultVoltsPerDegreePerSecond + 0.0008)) ||
					(fAngleSensitivity <= (Gyro::kDefaultVoltsPerDegreePerSecond - 0.0008)))
			{
				// the next number would be outside any reasonable value according to the datasheet
				break;
			}
		}

		gyro.Reset();
	}
__________________
Brian K
Team 1225 Robotics Mentor
  #9   Spotlight this post!  
Unread 18-03-2015, 16:22
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Large amounts of gyro drift

Quote:
Originally Posted by Joe Johnson View Post
We will often practice for 20 minutes and stop because ... the battery is dead.
How "dead" do you let the batteries get during practice?


  #10   Spotlight this post!  
Unread 18-03-2015, 17:35
washide washide is offline
Registered User
FRC #4237
 
Join Date: Mar 2015
Location: SW Michigan
Posts: 1
washide is an unknown quantity at this point
Re: Large amounts of gyro drift

We had similar drift issues and the most important things to do are:

1) ensuring a stable, secure, level mounting of the gyro
2) making certain that the gyro is perfectly still when it's being calibrated (as was already mentioned).

We were drifting around 1-3 degrees per second before mounting the gyro properly. Afterward, we had a drift of maybe 5 degrees after driving for a couple of minutes.
  #11   Spotlight this post!  
Unread 18-03-2015, 18:06
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,648
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Re: Large amounts of gyro drift

Quote:
Originally Posted by Ether View Post
How "dead" do you let the batteries get during practice?


How dead do our batteries get? I'm sure to be honest. The Coding Team has figured out a way to have our laptop play a sound "Low Power" sound when our battery voltage gets too low and then we change our battery. It seems to be working so I haven't looked into the voltage that they've picked.

Our robot for this year's game is not a huge current hog. We have 14 motors yes, but the Gripper & Pusher motors are off literally 95% of the time, the three arm motors and the lift motor are nearly perfectly counter balanced and the three wheels are never scrubbing because they are always pointed in the direction of travel with respect to the ground (thanks to the awesome programming of Paul, Michael, & Owen -- you guys are rock stars!). The motors that get hottest, believe it or not, are the three swerve motors.

Don't know if that answers your question, but that's all I've got...

Dr. Joe J.
__________________
Joseph M. Johnson, Ph.D., P.E.
Mentor
Team #88, TJ2
  #12   Spotlight this post!  
Unread 18-03-2015, 18:13
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Large amounts of gyro drift

Quote:
Originally Posted by Joe Johnson View Post
...our laptop play a sound "Low Power" sound when our battery voltage gets too low and then we change our battery.
Thanks for that clarification Joe.

I didn't want rookie readers to be left with the impression that you drain the batteries until the robot stops working.

Deep discharging is enemy #1 of lead acid batteries.


  #13   Spotlight this post!  
Unread 18-03-2015, 18:14
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 355
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: Large amounts of gyro drift

Quote:
Originally Posted by Joe Johnson View Post
... P.S. They claim 1 degree per minute drift. Again, I was skeptical but I think actually, in most cases, they do better than that. We will often practice for 20 minutes and stop because the motors are hot or the battery is dead not because we need to rezero the gyro. YMMV but that is our experience.
The navX MXP static yaw drift (e.g., when the navX MXP is still, and the ambient temperature is constant) averages just below 0.25 degrees/hour. This yields a very respectable 15 degrees of drift/hour when not moving - comparable to the ADXRS453. Our goal is to under-promise and over-deliver.
  #14   Spotlight this post!  
Unread 18-03-2015, 18:23
Bacon8er Bacon8er is offline
Registered User
AKA: Brian Walters
FRC #1902 (Exploding Bacon)
Team Role: Mentor
 
Join Date: Sep 2011
Rookie Year: 2007
Location: Orlando
Posts: 2
Bacon8er is an unknown quantity at this point
Re: Large amounts of gyro drift

Triple check that the analog port you are plugged into matches what port the software is looking at. A slowly changing input value is exactly what you would see on an open-circuited analog input channel.
  #15   Spotlight this post!  
Unread 18-03-2015, 19:33
Jean Tenca's Avatar
Jean Tenca Jean Tenca is offline
Head Mentor
AKA: "John"
FRC #4488 (Shockwave)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2002
Location: United States
Posts: 140
Jean Tenca is a glorious beacon of lightJean Tenca is a glorious beacon of lightJean Tenca is a glorious beacon of lightJean Tenca is a glorious beacon of lightJean Tenca is a glorious beacon of light
Re: Large amounts of gyro drift

Quote:
Originally Posted by Joe Johnson View Post
...we are using the navX MXP Robotics Navigation Sensor and we LOVE it.
I honestly wish this had been our experience. We bought two and have been experiencing problems with them across both competition and practice robots all season (it appears that the something gets hosed and the gyro only sends 0's instead of actual values). We've gone back to the KOP gyro while we investigate the problem.
__________________
Team 4488 Head Mentor
2015: [Carson Division Finalists (World Championship)], [Finalists, Entrepreneurship Award (PNW District Championship)], [Winners, GP Award (CWU District)], [Winners, Engineering Excellence (Oregon City District)]
2014: [Galileo Division Finalists (World Championship)], [Finalists, Quality Award (PNW District Championship)], [Winners, Industrial Design (Wilsonville District)], [Winners, Chairman's (Oregon City District)]
2013: [Rookie All-Star (Curie Division)], [Highest Rookie Seed, Rookie All Star (Autodesk Oregon Regional)]

---
2006-2012: Mentored various teams in OR and WA
2005: Team 1510 captain, founding member
2002-2004: Team 955 student/captain, founding member

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 21:18.

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