Go to Post I think the only way I'd die from posting on CD is from my wife killing me. - Koko Ed [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #18   Spotlight this post!  
Unread 16-04-2016, 15:02
Oblarg Oblarg is online now
Registered User
AKA: Eli Barnett
FRC #0449 (The Blair Robot Project)
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Philadelphia, PA
Posts: 1,116
Oblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond repute
Re: Problem with NavX to turn around.

Quote:
Originally Posted by Ether View Post
Let S be your sensor angle reading (in degrees, can be any range, even outside the range +/-360)

Let T be your desired angle position (in degrees, can be any range, even outside the range +/-360)

the angle between them (let's call it ERR) is found by the equation:

ERR = (T-S) - 360*floor(0.5+(T-S)/360);

the above returns a value for ERR between -180 and +180 degrees,
the shortest angle path to the target. Don't believe me? Try it.

So it tells you which direction to rotate as well as how much to rotate.

To use this with a PID, use processVariable = setpoint-ERR


This is unnecessary with the NavX and WPILib, as one can simply call AHRS pidGet() (which always ranges from -180 to 180) and ensure that the PIDController object is set to have a continuous range and not have to ever explicitly do any of the math.
__________________
"Mmmmm, chain grease and aluminum shavings..."
"The breakfast of champions!"

Member, FRC Team 449: 2007-2010
Drive Mechanics Lead, FRC Team 449: 2009-2010
Alumnus/Technical Mentor, FRC Team 449: 2010-Present
Lead Technical Mentor, FRC Team 4464: 2012-2015
Technical Mentor, FRC Team 5830: 2015-2016

Last edited by Oblarg : 16-04-2016 at 15:06.
Reply With Quote
 


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

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