Go to Post I even liked the Bieber commercial. - Andy Baker [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 31-01-2014, 23:27
owltheory owltheory is offline
Registered User
FRC #2172
 
Join Date: Jan 2014
Location: Ohio
Posts: 6
owltheory is an unknown quantity at this point
gyro.getAngle() only outputs 0.0

Greetings all,

With two weeks left, I hope everyone's robots are coming along well.

We're in the process of getting our sensors to work in Java, but we seem to have hit a wall when it comes to the gyro. As the title suggests, when we call the getAngle() method, all we consistently get is 0.0. We've tripled checked wiring based on this document, and we've tried multiple analog breakouts and multiple gyro sensors. We know the analog breakout works because we've gotten a rangefinder sensor to work off of the same unit. Based on this, I've concluded it has something to do with the programming. We are using java, the 2014 library (haven't checked for an update yet, but I don't think that would be the issue), and the cRio is running the 2014 image.

We're out of ideas and hoping you can help.

I attached the relevant snippets of code, but I can attach the whole class if necessary. We're planning to use the gyro for direction-sensitive mecanum drive.

Quote:
Gyro gyro;

public void robotInit()
{
...
gyro = new Gyro(1); // We've checked the port number
...
}

public void teleopInit()
{
gyro.reset();
}

public void teleopPeriodic()
{
System.out.println(gyro.getAngle());
}
Which yields a continuous stream of "0.0\n", regardless of how the gyro is moved.

We appreciate any help you can offer, and let me know if you need more information.
  #2   Spotlight this post!  
Unread 01-02-2014, 00:57
tStano tStano is offline
Registered User
AKA: Sparks
no team
Team Role: Electrical
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Madison, WI
Posts: 177
tStano will become famous soon enough
Re: gyro.getAngle() only outputs 0.0

It doesn't appear you've set the scale of the gyro. I believe you need to call the method gyro.setSensitivity(double voltsPerDegreePerSecond) in order to make things work.

Sensitivity is a constant that should be on your gyro spec sheet and it is measure in volts per degree per second.
  #3   Spotlight this post!  
Unread 01-02-2014, 01:37
mschwab013's Avatar
mschwab013 mschwab013 is offline
Registered User
AKA: Matt Schwabenbauer
FRC #0291
Team Role: College Student
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Erie, PA
Posts: 88
mschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to allmschwab013 is a name known to all
Re: gyro.getAngle() only outputs 0.0

The sensitivity has a default setting and shouldn't need need to be specified by the user

The problem could be due to GetAngle() not being capitalized. I hope you figure it out soon. Good luck!
__________________


2013 Pittsburgh- Gracious Professionalism award, 7th seed, 6th alliance captian, quarter-finalist(291,3492,4601)
2013 Queen CIty- Chairman's Award, 39th seed
2012 Pittsburgh- 23rd seed
2012 Buckeye- 34th seed, 2nd alliance, quarter-finalist(291,1241,4085)
2011 Pittsburgh- 13th seed, 5th alliance, quarter-finalist(291,337,3504)
2011 Buckeye- 18th seed, 8th alliance, quarter-finalist(279,291,3496)
2010 Finger Lakes- 15th seed, 5th alliance, quarter-finalist(291,1507,1559)
2010 Buckeye- Chairman's Award, Imagery Award, Quality Award, 4th seed, 1st pick, 1st alliance, semi-finalist(291,1014,1629)
  #4   Spotlight this post!  
Unread 01-02-2014, 09:25
owltheory owltheory is offline
Registered User
FRC #2172
 
Join Date: Jan 2014
Location: Ohio
Posts: 6
owltheory is an unknown quantity at this point
Re: gyro.getAngle() only outputs 0.0

Quote:
Originally Posted by tStano View Post
I believe you need to call the method gyro.setSensitivity(double voltsPerDegreePerSecond) in order to make things work.
Thanks for the tip, we'll give that a shot. I think we tried it with a bogus value just to see what would happen, but we'll try to find the actual value and give it a shot.

Quote:
Originally Posted by mschwab013
The problem could be due to GetAngle() not being capitalized. I hope you figure it out soon. Good luck!
Thanks for the suggestion, we'll give that shot too, but I didn't see anything in the javadoc about that method being static. Have you capitalized the method in the past?

I also looked over the example that I originally posted an realized that it stores the value in variable before printing it. I wouldn't think that this would make a difference either, but we're running out of options.

Thanks for the help, I'll keep you updated.
  #5   Spotlight this post!  
Unread 01-02-2014, 10:24
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: gyro.getAngle() only outputs 0.0

Quote:
Originally Posted by owltheory View Post
Thanks for the suggestion, we'll give that shot too, but I didn't see anything in the javadoc about that method being static. Have you capitalized the method in the past?
You are correct- "getGyro()" should be lowerCamelCase. If you try to use "GetGryo()," NetBeans will tell you that the method doesn't exist.

UpperCamelCase is correct if you are using C++, which it sounds like you are not.
__________________
Team 2052- KnightKrawler
Mentor and volunteer
  #6   Spotlight this post!  
Unread 01-02-2014, 18:57
owltheory owltheory is offline
Registered User
FRC #2172
 
Join Date: Jan 2014
Location: Ohio
Posts: 6
owltheory is an unknown quantity at this point
Re: gyro.getAngle() only outputs 0.0

Correct; GetGyro() does not work. But I figured it out.

Someone decided we needed to put a gyro.free() in there, and this was the reason it was happening.

Took that out and the gyro began working immediately. Thanks for taking the time to reply.
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 02:44.

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