Go to Post FIRST is the only high-school sport where everyone can become a pro - David Brinza [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 30-03-2015, 09:51
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: PID & One Second Delay Between Auto and TeleOp

Quote:
Originally Posted by WillNess View Post
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.)
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #2   Spotlight this post!  
Unread 30-03-2015, 12:09
WillNess's Avatar
WillNess WillNess is offline
Programmer
AKA: Will Ness
FRC #4944 (The Hi Fives)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: United States
Posts: 90
WillNess is just really niceWillNess is just really niceWillNess is just really niceWillNess is just really nice
Re: PID & One Second Delay Between Auto and TeleOp

Quote:
Originally Posted by GeeTwo View Post
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();
__________________

Outreach Lead // Lead Programmer // Junior

2014 FRC:
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Utah
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Colorado
2015 FRC:
Creativity In Engineering & Semifinalist @ Arizona West
Reply With Quote
  #3   Spotlight this post!  
Unread 30-03-2015, 12:24
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 575
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
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);
   }
}
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson
Reply With Quote
  #4   Spotlight this post!  
Unread 30-03-2015, 13:25
WillNess's Avatar
WillNess WillNess is offline
Programmer
AKA: Will Ness
FRC #4944 (The Hi Fives)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: United States
Posts: 90
WillNess is just really niceWillNess is just really niceWillNess is just really niceWillNess is just really nice
Re: PID & One Second Delay Between Auto and TeleOp

Thank you, I think this should work!

Quote:
Originally Posted by MrRoboSteve View Post
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);
   }
}
__________________

Outreach Lead // Lead Programmer // Junior

2014 FRC:
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Utah
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Colorado
2015 FRC:
Creativity In Engineering & Semifinalist @ Arizona West
Reply With Quote
  #5   Spotlight this post!  
Unread 30-03-2015, 13:30
WillNess's Avatar
WillNess WillNess is offline
Programmer
AKA: Will Ness
FRC #4944 (The Hi Fives)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: United States
Posts: 90
WillNess is just really niceWillNess is just really niceWillNess is just really niceWillNess is just really nice
Re: PID & One Second Delay Between Auto and TeleOp

Quote:
Originally Posted by MrRoboSteve View Post
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;
   }
}
__________________

Outreach Lead // Lead Programmer // Junior

2014 FRC:
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Utah
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Colorado
2015 FRC:
Creativity In Engineering & Semifinalist @ Arizona West
Reply With Quote
  #6   Spotlight this post!  
Unread 30-03-2015, 16:22
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: PID & One Second Delay Between Auto and TeleOp

Quote:
Originally Posted by WillNess View Post
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...
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #7   Spotlight this post!  
Unread 30-03-2015, 17:00
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 575
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
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.
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson
Reply With Quote
  #8   Spotlight this post!  
Unread 30-03-2015, 21:07
WillNess's Avatar
WillNess WillNess is offline
Programmer
AKA: Will Ness
FRC #4944 (The Hi Fives)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: United States
Posts: 90
WillNess is just really niceWillNess is just really niceWillNess is just really niceWillNess is just really nice
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.
__________________

Outreach Lead // Lead Programmer // Junior

2014 FRC:
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Utah
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Colorado
2015 FRC:
Creativity In Engineering & Semifinalist @ Arizona West
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 10:50.

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