Go to Post ...our football team was a state champion, but i don't see -them- going to atlanta and winning there! :D - Sam Lipscomb [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 08-11-2013, 14:57
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Gyro angle in simulation vs reality?

The gyro in the simulation gives angles between -180 to 180 and when it reaches 180 it goes to -180.
Is it like this in real life gyros?
It makes it hard to make the simulation robot turn 180 degrees or more
Reply With Quote
  #2   Spotlight this post!  
Unread 08-11-2013, 15:09
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Gyro angle in simulation vs reality?

See this post: http://www.chiefdelphi.com/forums/sh...6&postcount=18

There are also some other great posts in that thread on this topic.

Here's the thread: http://www.chiefdelphi.com/forums/sh....php?p=1182626
__________________
-
An ounce of perception is worth a pound of obscure.

Last edited by Chris Hibner : 08-11-2013 at 15:11.
Reply With Quote
  #3   Spotlight this post!  
Unread 08-11-2013, 15:22
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Gyro angle in simulation vs reality?

Quote:
Originally Posted by Chris Hibner View Post
See this post: http://www.chiefdelphi.com/forums/sh...6&postcount=18

There are also some other great posts in that thread on this topic.

Here's the thread: http://www.chiefdelphi.com/forums/sh....php?p=1182626
Ok, I understand now how to solve it.
Is it like this in the KIT gyro too?
Reply With Quote
  #4   Spotlight this post!  
Unread 08-11-2013, 15:30
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,362
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Gyro angle in simulation vs reality?

The gyro is not the issue. The issue is how the code is interpreting and displaying the data that sensor is sending to it. For all intents, any gyro running this particular could would behave the same way.

If you want the values to continue to increase/decrease, then the code must be written that way.

The gyro is just a sensor. What the code does is take the sensors output an converts it into something useable.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #5   Spotlight this post!  
Unread 08-11-2013, 16:08
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Gyro angle in simulation vs reality?

Quote:
Originally Posted by billbo911 View Post
The gyro is not the issue. The issue is how the code is interpreting and displaying the data that sensor is sending to it. For all intents, any gyro running this particular could would behave the same way.

If you want the values to continue to increase/decrease, then the code must be written that way.

The gyro is just a sensor. What the code does is take the sensors output an converts it into something useable.
Ok, so for my needs continuous increase/decrease would be the best "convertion" of the gyro volts readings.
Now, the default code is giving me +/-180 degrees range and I can't change it so I'll have to use it that way.
I'd like to have a vi that gets X degrees as an input and moves the robot X degrees CW, can I have some help with that?
If my current Angle is 90 and I want to move 100 degrees CW, I should end up at -170.. I don't know how to get to that.

Last edited by GuyM142 : 08-11-2013 at 16:56.
Reply With Quote
  #6   Spotlight this post!  
Unread 08-11-2013, 19:52
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,362
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Gyro angle in simulation vs reality?

I'm not sure which example you are using, but here is what I found.
If you open LV and click on "Support". Then select Find FRC Examples, you will find a Gyro example under the Analog folder.

The Get Angle vi returns two things: The current angle relative to where the robot started, and the current angular rate of rotation.

If you use the "Get Angle" output, I believe you will find what you are looking for.
See the attached image.
Attached Thumbnails
Click image for larger version

Name:	Gyro Example.jpg
Views:	43
Size:	440.3 KB
ID:	15401  
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #7   Spotlight this post!  
Unread 08-11-2013, 22:03
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,091
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: Gyro angle in simulation vs reality?

Quote:
Originally Posted by GuyM142 View Post
Ok, so for my needs continuous increase/decrease would be the best "convertion" of the gyro volts readings.
Would you mind sharing with us what you are trying to accomplish and how you determined that a continuous increase/decrease sensor output would be best?

Quote:
Now, the default code is giving me +/-180 degrees range...
Interesting. In Java, the gyro angle is returned as a continuous increase/decrease from the starting value:

Code:
    /**
     * Return the actual angle in degrees that the robot is currently facing.
     *
     * The angle is based on the current accumulator value corrected by the oversampling rate, the
     * gyro type and the A/D calibration values.
     * The angle is continuous, that is can go beyond 360 degrees. This make algorithms that wouldn't
     * want to see a discontinuity in the gyro output as it sweeps past 0 on the second time around.
     *
     * @return the current heading of the robot in degrees. This heading is based on integration
     * of the returned rate from the gyro.
     */

Quote:
I'd like to have a vi that gets X degrees as an input and moves the robot X degrees CW
Is there a reason you always want to rotate the robot clockwise? In other words, if "X" is 359 degrees wouldn't it be better to rotate the robot 1 degree counter-clockwise?


Reply With Quote
  #8   Spotlight this post!  
Unread 09-11-2013, 03:27
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Quote:
Originally Posted by billbo911 View Post
I'm not sure which example you are using, but here is what I found.
If you open LV and click on "Support". Then select Find FRC Examples, you will find a Gyro example under the Analog folder.

The Get Angle vi returns two things: The current angle relative to where the robot started, and the current angular rate of rotation.

If you use the "Get Angle" output, I believe you will find what you are looking for.
See the attached image.
That's the vi I'm using, but it works differently in the simulator.
I think that the cRIO version of it would work the way I want to.

What I'm trying to accomplish is a vi which turns X degrees (rather than the shortest way to a certain angle), it doesn't even matter in which direction because I get stuck whenever the (current angle + degrees to rotate) is bigger than 180 or smaller than -180.
(The problem is the same for "rotate the shortest way to angle X, but leave it for now)
I hope I've explained it well
__________________
2016-2017 - Programming Mentor
Curie Sub-Division Champions with 694, 379 & 1511
2015 - Team Captain & Head of Programming Crew
Carson Sub-Division Champions with 1325, 20 & 1711
First ever Israeli team on Einstein
2014 - Team Captain & Head of Programming Crew
2013 - Head of Programming Crew
2012 - Member of Programming Crew
Reply With Quote
  #9   Spotlight this post!  
Unread 09-11-2013, 06:22
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Gyro angle in simulation vs reality?

The WPILiib VIs should behave the same for a simulated, analog, and digital gyro. The conventions of the simulator were quite different and had to be manipulated in order to fit into WPILib, and it seems like you've discovered a bug.

If you select the gyro VI in your code and choose Edit>>Create SubVI, it will wrap the WPILib version in a simple subVI. Try to modify it to make the simulated one behave the same as real-world, then use that instead until the bug gets fixed.

Greg McKaskle
Reply With Quote
  #10   Spotlight this post!  
Unread 09-11-2013, 10:51
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Gyro angle in simulation vs reality?

Quote:
Originally Posted by Greg McKaskle View Post
The WPILiib VIs should behave the same for a simulated, analog, and digital gyro. The conventions of the simulator were quite different and had to be manipulated in order to fit into WPILib, and it seems like you've discovered a bug.

If you select the gyro VI in your code and choose Edit>>Create SubVI, it will wrap the WPILib version in a simple subVI. Try to modify it to make the simulated one behave the same as real-world, then use that instead until the bug gets fixed.

Greg McKaskle
I can't really change the code inside the gyro VI, I get to a level where I need to enter a password in order to make changes to the VI.
But i noticed that the angle value is coming from a a Honeywell Compass reference.
I don't get it.. why would the VI called gyro and inside it'll be a compass?
The gyro output really does behave like a compass would.
Reply With Quote
  #11   Spotlight this post!  
Unread 09-11-2013, 15:02
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,091
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: Gyro angle in simulation vs reality?

Quote:
Originally Posted by GuyM142 View Post
What I'm trying to accomplish is a vi which turns X degrees (rather than the shortest way to a certain angle), it doesn't even matter in which direction...

I hope I've explained it well
It's still not clear to me what you are trying to do. If it doesn't matter which direction, what's wrong with taking the shortest angle to get to the target?

Let's say at some point in time your gyro reads "g" degrees and you want the robot to rotate X degrees CW from that reading.

Compute target_angle = g + X at that point in time. Then use that target_angle in each iteration of your closed-loop controller as follows:

error = target_angle - gyro_reading;
error = error - 360.0*floor(0.5 + error/360.0);

Then set your SetPoint and ProcessVariable inputs to your closed-loop controller as follows:

SetPoint= error;
ProcessVariable = 0;

or

SetPoint=0;
Process_Variable= -error;

( choose one or the other depending on how your closed-loop controller handles d/dt(error) )

Once you've turned the desired X degrees, you can receive a new X command and compute a new target_angle and start the process anew. Or you can re-start the process if you receive a new X command before the previous one has completed.


Example:

The gyro reads 179 degrees and you want to rotate 10 degrees CW.

Compute target_angle = 179 + 10 = 189 degrees

first iteration:

error = 189 - 179 = 10
error = 10 - 360.0*floor(0.5 + 10/360.0) = 10
SetPoint= 10;
ProcessVariable = 0;

assume that the gyro angle increases by 2 degrees (from 179 to -179) and now look at the second iteration of the closed-loop controller:

error = 189 - (-179) = 368
error = 368 - 360.0*floor(0.5 + 368/360.0) = 8
SetPoint= 8;
ProcessVariable = 0;

... and so on until the target of 189 is reached (at which point the gyro will read -171 degrees).



Last edited by Ether : 09-11-2013 at 19:19. Reason: added example
Reply With Quote
  #12   Spotlight this post!  
Unread 10-11-2013, 07:34
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,573
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 angle in simulation vs reality?

Quote:
Originally Posted by GuyM142 View Post
I can't really change the code inside the gyro VI, I get to a level where I need to enter a password in order to make changes to the VI.
Greg's suggestion was to make your own VI that looked for a rollover from 180 to -180, and when that happened, add 360 to the gyro output. If you kept a running total of gyro rollovers, this would work forever. This doesn't require any changes to the simulation.

Quote:
Originally Posted by GuyM142 View Post
But i noticed that the angle value is coming from a a Honeywell Compass reference.
I don't get it.. why would the VI called gyro and inside it'll be a compass?
The gyro output really does behave like a compass would.
The trick in simulation is to make something that isn't real work "close enough" to something that is real. In this case, most teams are interested in the angle from the gyro. Rather then spend thousands of dollars to make a computer model of a gyro, they used a compass that was already implemented, and produced very similar data. As you noted, it is different in the rollover, however that is easily compensated for.
Reply With Quote
  #13   Spotlight this post!  
Unread 10-11-2013, 14:39
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,091
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: Gyro angle in simulation vs reality?


Here's a possible implementation of Joe's suggestion.

Code:
// initialization:
alpha=Go=getGyroReading();  // range -180 to +180

// iteration:
G=getGyroReading();
d=G-Go;
Go=G;
if (d>180) d-=360;
else if (d<-180) d+=360;
alpha+=d; // alpha is the continuous angle reading you've been asking for

Reply With Quote
  #14   Spotlight this post!  
Unread 13-11-2013, 13:22
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Gyro angle in simulation vs reality?

Quote:
Originally Posted by Ether View Post

Here's a possible implementation of Joe's suggestion.

Code:
// initialization:
alpha=Go=getGyroReading();  // range -180 to +180

// iteration:
G=getGyroReading();
d=G-Go;
Go=G;
if (d>180) d-=360;
else if (d<-180) d+=360;
alpha+=d; // alpha is the continuous angle reading you've been asking for

Thank you! that's what I was looking for.
My goal was to make the simulated gyro work like a real FRC gyro for new programmers training.
I've attached my implementation (this is in periodic tasks)
Attached Thumbnails
Click image for larger version

Name:	gyro.png
Views:	42
Size:	32.6 KB
ID:	15410  
Reply With Quote
  #15   Spotlight this post!  
Unread 14-11-2013, 08:59
Doug Norman's Avatar
Doug Norman Doug Norman is offline
Registered User
no team (National Instruments)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Austin, TX
Posts: 137
Doug Norman will become famous soon enoughDoug Norman will become famous soon enough
Re: Gyro angle in simulation vs reality?

I implemented the simulation code. The gyro should work the same as a real robot gyro. You should try a real one - if they differ I will fix the simulated. The reason you see compass VIs down within the simulated gyro is because I used subVIs that already existed as part of our robotics module (a separate commercial module that is not part of FRC). For simulation it doesn't matter what is in the bowels of the code, only that the top layer acts like a gyro.
__________________
Doug Norman
National Instruments
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 02:08.

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