Go to Post A charged battery beats a dead battery any day. - Al Skierkiewicz [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
  #11   Spotlight this post!  
Unread 22-04-2016, 14:01
bobcroucher's Avatar
bobcroucher bobcroucher is offline
Registered User
FRC #2471 (Team Mean Machine)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2008
Location: United States
Posts: 33
bobcroucher has a spectacular aura aboutbobcroucher has a spectacular aura about
Re: NavX: Trying to rotate to angle without PID

You can either create a new tiny class specifically to be used as your PIDOutput class, or you can have your robot class be that class too by using a line like this on your Robot class definition.

Code:
public class Robot extends SampleRobot implements PIDOutput {
Then you need to implement pidWrite() which tells the PID what you want to do with the output.

In your case, copying a line from above I assume you will want this:

Code:
@Override
  /* This function is invoked periodically by the PID Controller, */
  /* based upon navX-MXP yaw angle input and PID Coefficients.    */
  
public void pidWrite(double output) {
      Drive( output, 1.0 );
}
If the error between your setpoint and the gyro angle was 90 degrees or more you would want full 1.0 power, so I would start with a P constant of 1.0 / 90. So 0.01 should be a good starting place.

When you set your gyro up, here are some other suggestions straight from their example:
Code:
      turnController.setInputRange(-180.0f,  180.0f);
      turnController.setOutputRange(-1.0, 1.0);
      turnController.setAbsoluteTolerance(2.0);
      turnController.setContinuous(true);
Last, if you are trying to go to 0, then call

Code:
turnController.setSetpoint( 0.0 );
and to turn the controller on use,

Code:
turnController.enable();
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 02:29.

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