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)

WillNess 29-03-2015 14:09

PID & One Second Delay Between Auto and TeleOp
 
This year we have a giant arm that sticks behind our robot, with two joints. At the end of an arm is a claw. One of our autonomous modes is that the both parts will drop down, our robot will drive backwards, our claw will close on the bin on the center step, and the arm will then fold up and set the bin so that it is resting on our robot while still grabbing the bin. The problem is, during the one second between autonomous and teleop, our PID is disabled so the arm droops a little and some of the time we drop that bin. I've temporarily fixed the problem by storing the bin in a different position where if the PID disables none of the parts of the arm will droop, but it is vital for our drivers to start in the docked position.
So:
- Is it possible to operate the PID during this 1 second delay?
- Is this delay considered "disabledPeriodic"
- Are there any other fixes?

GeeTwo 29-03-2015 14:14

Re: PID & One Second Delay Between Auto and TeleOp
 
Something to try:

After the arm has reached the proper position and stabilized, get the voltage setting for the motor, set that voltage and disable the PID (or perhaps swap the order). This setting seems more likely to survive the transition from auto to teleop.

MrRoboSteve 29-03-2015 14:31

Re: PID & One Second Delay Between Auto and TeleOp
 
I believe the robot is in the disabled state during the period between autonomous and teleop, so no commanding will be sent to the motor controllers. Someone with a roboRIO at hand could validate that.

Without seeing your mechanism, it's hard to picture what would work. Bungees or constant force springs are often used in similar scenarios when you need a balancing force.

WillNess 29-03-2015 14:32

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

I tried creating two variables and setting it to the .getAverageVoltage() for each potentiometer on the arm during Auto Periodic and then in TeleOpInit I would set the setPoint for each part of the arm to their respective variable but I didn't seem to get the arm to jump back up to its previous position, and sometimes the first part of the arm had drooped too much and the bin had already fell.

GeeTwo 29-03-2015 14:42

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

Originally Posted by WillNess (Post 1463347)
GeeTwo:

I tried creating two variables and setting it to the .getAverageVoltage() for each potentiometer on the arm during Auto Periodic and then in TeleOpInit I would set the setPoint for each part of the arm to their respective variable but I didn't seem to get the arm to jump back up to its previous position, and sometimes the first part of the arm had drooped too much and the bin had already fell.

I was referring to the voltage applied to the motor (throttle, PID output value to actuator), not the voltage returned from the potentiometer (PID input value from sensor).

WillNess 29-03-2015 14:42

Re: PID & One Second Delay Between Auto and TeleOp
 

Above is the image of what we call our "Stinger"
It has two parts:
The shoulder and the elbow.
The shoulder is the bottom part and the elbow is the part that is turned, think of it as an actual human arm where the joint is where the elbow starts.
This is our old docked position, now our shoulder is a little farther up so it's not at 0 degrees.

GeeTwo 29-03-2015 14:46

Re: PID & One Second Delay Between Auto and TeleOp
 
Also, are you using the same motor controller object between auto and tele? Declaring a new motor controller at the beginning of teleop would presumably reset the throttle to zero.

WillNess 29-03-2015 14:50

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

Originally Posted by GeeTwo (Post 1463354)
Also, are you using the same motor controller object between auto and tele? Declaring a new motor controller at the beginning of teleop would presumably reset the throttle to zero.


Yes. The only time we declare motor controllers is in robotInit.

GeeTwo 29-03-2015 14:54

Re: PID & One Second Delay Between Auto and TeleOp
 
Glad to see the picture - not what I hand in mind (I was thinking of an overhead arm). Putting the arm vertical or nearly vertical leaning against the tall frame would presumably handle the temporary "storing the bin in a different position where if the PID disables none of the parts of the arm will droop".

Would it help if you used your temporary solution, then at the beginning of teleop, the robot automatically moved the arm to the "docked" position, without waiting on driver input?

WillNess 29-03-2015 15:27

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

Originally Posted by GeeTwo (Post 1463359)
Glad to see the picture - not what I hand in mind (I was thinking of an overhead arm). Putting the arm vertical or nearly vertical leaning against the tall frame would presumably handle the temporary "storing the bin in a different position where if the PID disables none of the parts of the arm will droop".

Would it help if you used your temporary solution, then at the beginning of teleop, the robot automatically moved the arm to the "docked" position, without waiting on driver input?

That sounds like a good idea.
What I'm doing temporarily is bringing the shoulder back down to 0 degrees, and then making the elbow go to 90 degrees, in which nothing falls.
I guess at teleop init I could set both of the positions to go to docked position.
Which raises another question:
- Is there any way to do something only if the robot is in practice mode or playing an actual match?

MrRoboSteve 29-03-2015 15:45

Re: PID & One Second Delay Between Auto and TeleOp
 
DriverStation::IsFMSAttached() helps you with part of your question.

Ben Wolsieffer 29-03-2015 15:48

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

Originally Posted by WillNess (Post 1463375)
- Is there any way to do something only if the robot is in practice mode or playing an actual match?

You could use:
Code:

DriverStation.getInstance().isFMSAttached()
to detect whether the robot is connected to the field, but I don't think this works for practice mode.

WillNess 30-03-2015 02:55

Re: PID & One Second Delay Between Auto and TeleOp
 
Do you guys think this would work?
Code:

robotInit(){
  boolean = false;
}
autonomousPeriodic(){
  boolean = true;
}
teleopInit(){
  if(boolean == true){
      shoulder.set(shoulderDocked);
      elbow.set(elbowDocked);
  }
  boolean = false;
}

The thing is I'd need to reset the roboRio if I wanted to ever test autonomous and teleop NOT in practice mode.

WillNess 30-03-2015 03:04

Re: PID & One Second Delay Between Auto and TeleOp
 
Or I could add
Code:

disabledInit(){
  Timer.start();
}
teleopInit(){
  if(Timer.getFPGATimestamp > 1.000){
      Timer.stop();
      Timer.reset();
  }else{
      shoulder.set(shoulderDocked);
      elbow.set(elbowDocked);
      Timer.stop();
      Timer.reset();
  }
 
}

Questions: Do I need the .stop() and .reset() or just one? does the .reset() start the timer again?

MrRoboSteve 30-03-2015 07:51

Re: PID & One Second Delay Between Auto and TeleOp
 
Remember you also have DisabledInit and DisabledPeriodic available.


All times are GMT -5. The time now is 10:49.

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