Go to Post FIRST is good for us. It is good for our own Children. Don't give up, even if you are as tired as I am! - Kyle Hughes [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-03-2016, 15:13
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: Custom PI Loop not working

I believe at least part of your problem is the else clause (lines 100-106) in your teleop code. When no buttons are pressed, it zeroes out your flywheels, overriding the values set based on the PI processing.

Why a PI loop? While I have heard of PIDs occasionally working out to have a zero or near-zero value for D based on mechanical friction, I don't see any advantage to having a special class for PI.

Also, while this does not appear to be related to your observed problem, your PI class is not structured in a regular object-oriented fashion. Normally, you would only have one copy of the code in your "loop" class, and it would not know anything about any of the individual motors. Then, the subsystem classes (e.g. shooter) would each create its own instance of the calculator using its appropriate values. Much cleaner and easier to maintain.
__________________

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 13-03-2016, 15:42
teslalab2's Avatar
teslalab2 teslalab2 is offline
RogueBotix LLC
VRC #8091
Team Role: Mentor
 
Join Date: Feb 2015
Rookie Year: 2014
Location: Austin MN
Posts: 109
teslalab2 will become famous soon enoughteslalab2 will become famous soon enough
Re: Custom PI Loop not working

there really is no reason for an if statement in a PID! PID's in of their own aren't really that complicated, and if you start adding if statements and things like that it can only have the potential to cause problems. if you don't want to use the D component just don't give it a constant, If you want negative feedback,make the constant negative. here is the class I wrote last year in c++. Simplicity is king!

Code:
class myPID{
private:
double Kp,Ki,Kd;
double error, error1 = 0;
double integral;
float value;
public:
void Update(double,double);
float GetValue(void);
void SetConstants(double,double,double);
};

void myPID::Update(double target,double actual){
	error = target - actual;
	integral += error*.01; //todo add actualy eleapsed time
	value = (error*Kp) + (integral*Ki) + ((error-error1)/(.01)*Kd);
	error1 = error;
}
float myPID::GetValue(){
	return value;
}

void myPID::SetConstants(double Kp,double Ki,double Kd){
        this->Kp=Kp;
        this->Ki=Ki;
        this->Kd=Kd;
}
__________________
I need a jaguar development board for reprogramming a jaguars bootloader. if you have one that you want to sell, pm me. thanks

Run you CanJaguars on arduino with ArduRIO, you can also easily control Talons, Victors,Jaguars and Sparks on PWM. https://sourceforge.net/projects/ardurio/
Reply With Quote
  #3   Spotlight this post!  
Unread 13-03-2016, 15:59
Cinnamon Toast's Avatar
Cinnamon Toast Cinnamon Toast is offline
Registered User
FRC #3641 (The Flying Toasters)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Michigan
Posts: 32
Cinnamon Toast is an unknown quantity at this point
Re: Custom PI Loop not working

I'll take a look at re doing the PI class in the mean time. I don't need the D variable as the shooter articulation and gearing is heavy enough that I don't need the ramp down of velocity of angle change for my shooter. P will get it within range of my target setpoint, and I will eat up the remaining error so that I just don't sit under my setpoint with stall torque. Also, the PIloop does nothing to control the flywheels. The flywheels are simply the shooter wheels that will spin up to 100% and give the boulder velocity when they exit the shooter. I am however passing control of the shooter angle over to just a joystick when no buttons are pressed. Again, if I write a dummy P loop in one of the methods checking the button press, it acts just like i want it to. It's only when I use a function from the PILoop class that things don't work.
Reply With Quote
  #4   Spotlight this post!  
Unread 13-03-2016, 22:02
teslalab2's Avatar
teslalab2 teslalab2 is offline
RogueBotix LLC
VRC #8091
Team Role: Mentor
 
Join Date: Feb 2015
Rookie Year: 2014
Location: Austin MN
Posts: 109
teslalab2 will become famous soon enoughteslalab2 will become famous soon enough
Re: Custom PI Loop not working

I would try making a "dummy PI" loop and make sure its working. looking at your file, there is so much "if" logic and booleans and everything for testing different scenarios, you would have to be a god to code that in one sitting without checking for functionality, and just have it it work. Most of all that logic isn't even necessary.

simply write one class that works for everything once you get it working, and declare it for every application that you need it. In my experience I have never had code work when I just wrote everything in one sitting, you kinda have to test if its still working every time you add or change something, humans make mistakes. I could be wrong but thats why I think it isn't working.
__________________
I need a jaguar development board for reprogramming a jaguars bootloader. if you have one that you want to sell, pm me. thanks

Run you CanJaguars on arduino with ArduRIO, you can also easily control Talons, Victors,Jaguars and Sparks on PWM. https://sourceforge.net/projects/ardurio/
Reply With Quote
  #5   Spotlight this post!  
Unread 14-03-2016, 06:01
Cinnamon Toast's Avatar
Cinnamon Toast Cinnamon Toast is offline
Registered User
FRC #3641 (The Flying Toasters)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Michigan
Posts: 32
Cinnamon Toast is an unknown quantity at this point
Re: Custom PI Loop not working

Thank you guys for all of the help. I'll work through my code today, as it's back to school for me and that means more time with the practice robot. I'll post again when I get things sorted out letting you know what was going wrong.
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:19.

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