Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   PID & One Second Delay Between Auto and TeleOp (http://www.chiefdelphi.com/forums/showthread.php?t=136187)

GeeTwo 30-03-2015 09:51

Re: PID & One Second Delay Between Auto and TeleOp
 
Quote:

Originally Posted by WillNess (Post 1463599)
Questions: Do I need the .stop() and .reset() or just one? does the .reset() start the timer again?

The documentation isn't clear. Going back to the source code, it appears that the timer carries the "accumulated time" from a stop to a start, so if you want to zero the result of later get()s, you must do a reset(). (I'm presuming that the C++ and Java versions behave equivalently.)

WillNess 30-03-2015 12:09

Re: PID & One Second Delay Between Auto and TeleOp
 
Quote:

Originally Posted by GeeTwo (Post 1463632)
The documentation isn't clear. Going back to the source code, it appears that the timer carries the "accumulated time" from a stop to a start, so if you want to zero the result of later get()s, you must do a reset(). (I'm presuming that the C++ and Java versions behave equivalently.)

Ok so if we implement something equivalent to this code, right before I start it I will do a timer.reset();

MrRoboSteve 30-03-2015 12:24

Re: PID & One Second Delay Between Auto and TeleOp
 
I think this is closer to what you want. The logic is simpler if you move the timer check into disabledPeriodic(). The result of timer.getFPGATimestamp() is probably not what you want.

Code:


bool teleopAfterAutonomous = false;

autonomousInit() {
  teleopAfterAutonomous = true;
}

disabledInit(){
  disabledTimer.Reset();
  disabledTimer.Start();
}

disabledPeriodic(){
  if (disabledTimer.Get() > 1) {
    // If we're disabled for more than one second, assume that we are not in a match
    // Might be necessary to bump 1 above to a somewhat higher value.   
    teleopAfterAutonomous = false;
  }
}

teleopInit(){
  if(teleopAfterAutonomous || DriverStation.getInstance().isFMSAttached()){
      shoulder.set(shoulderDocked);
      elbow.set(elbowDocked);
  }
}


WillNess 30-03-2015 13:25

Re: PID & One Second Delay Between Auto and TeleOp
 
Thank you, I think this should work!

Quote:

Originally Posted by MrRoboSteve (Post 1463723)
I think this is closer to what you want. The logic is simpler if you move the timer check into disabledPeriodic(). The result of timer.getFPGATimestamp() is probably not what you want.

Code:


bool teleopAfterAutonomous = false;

autonomousInit() {
  teleopAfterAutonomous = true;
}

disabledInit(){
  disabledTimer.Reset();
  disabledTimer.Start();
}

disabledPeriodic(){
  if (disabledTimer.Get() > 1) {
    // If we're disabled for more than one second, assume that we are not in a match
    // Might be necessary to bump 1 above to a somewhat higher value.   
    teleopAfterAutonomous = false;
  }
}

teleopInit(){
  if(teleopAfterAutonomous || DriverStation.getInstance().isFMSAttached()){
      shoulder.set(shoulderDocked);
      elbow.set(elbowDocked);
  }
}



WillNess 30-03-2015 13:30

Re: PID & One Second Delay Between Auto and TeleOp
 
Quote:

Originally Posted by MrRoboSteve (Post 1463723)
I think this is closer to what you want. The logic is simpler if you move the timer check into disabledPeriodic(). The result of timer.getFPGATimestamp() is probably not what you want.

Code:


bool teleopAfterAutonomous = false;

autonomousInit() {
  teleopAfterAutonomous = true;
}

disabledInit(){
  disabledTimer.Reset();
  disabledTimer.Start();
}

disabledPeriodic(){
  if (disabledTimer.Get() > 1) {
    // If we're disabled for more than one second, assume that we are not in a match
    // Might be necessary to bump 1 above to a somewhat higher value.   
    teleopAfterAutonomous = false;
  }
}

teleopInit(){
  if(teleopAfterAutonomous || DriverStation.getInstance().isFMSAttached()){
      shoulder.set(shoulderDocked);
      elbow.set(elbowDocked);
  }
}


Except during teleopInit() I think I'd have to set the teleopAfterAutonomous = false. Because if I do the practice mode and then I start teleop the teleopAfterAutonomous would be true and then would go to the docked positions so it would look like this: (Correct me if I'm wrong)
Code:

teleopInit(){
  if(teleopAfterAutonomous || DriverStation.getInstance().isFMSAttached()){
      shoulder.set(shoulderDocked);
      elbow.set(elbowDocked);
      teleopAfterAutonomous = false;
  }
}


GeeTwo 30-03-2015 16:22

Re: PID & One Second Delay Between Auto and TeleOp
 
Quote:

Originally Posted by WillNess (Post 1463767)
Except during teleopInit() I think I'd have to set the teleopAfterAutonomous = false. Because if I do the practice mode and then I start teleop the teleopAfterAutonomous would be true and then would go to the docked positions so it would look like this: (Correct me if I'm wrong)
Code:

teleopInit(){
  if(teleopAfterAutonomous || DriverStation.getInstance().isFMSAttached()){
      shoulder.set(shoulderDocked);
      elbow.set(elbowDocked);
      teleopAfterAutonomous = false;
  }
}


Only if there's somewhere later in the code (e.g. in teleopPeriodic()) that uses teleopAfterAutonomous. As for what I see here, the variable is not going to be referenced again. That also means that it won't hurt anything...

MrRoboSteve 30-03-2015 17:00

Re: PID & One Second Delay Between Auto and TeleOp
 
WillNess, I think your change is a good one.

In my code, I assumed that you'd have at least a second of disabled between your practice runs. That delay causes teleopAfterAutonomous to become false. Your change resets things immediately.

WillNess 30-03-2015 21:07

Re: PID & One Second Delay Between Auto and TeleOp
 
Yes I don't think I'll ever be starting the robot within 1 second of code uploading or rebooting.


All times are GMT -5. The time now is 12:32.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi