Go to Post That wheel appears to have been forged deep within the fires of Mount Awesome. - viking1902 [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 20-02-2015, 13:15
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 490
tomy has a spectacular aura abouttomy has a spectacular aura about
Gyro Turning in Auto Mode

We trying to manipulate the kp so that we turn slow at the beginning then increase the speed of rotation when we approach the angle we want. It works kinda of just spins way to fast at the beginning of the rotate. Suggestions?

Code:
	
if(stage_one_complete){
		gyro.Reset();
		while(IsAutonomous() && IsEnabled() ){
			float angle = gyro.GetAngle();

			if(angle > + 70){
				kp = 0.005;
			}else if(angle < + 70){
				kp = 0.02;
			}

			myRobot.MecanumDrive_Cartesian( 0, 0, ((angle + 82) * kp), 0);
			timer ++;
			Wait (0.004);

			if(timer > 400){
				myRobot.MecanumDrive_Cartesian(0, 0, 0, 0);
				stage_one_complete = false;
				stage_two_complete = true;
				break;
			}
		}
	}
Reply With Quote
  #2   Spotlight this post!  
Unread 20-02-2015, 15:21
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,495
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: Gyro Turning in Auto Mode

Quote:
Originally Posted by tomy View Post
We trying to manipulate the kp so that we turn slow at the beginning then increase the speed of rotation when we approach the angle we want. It works kinda of just spins way to fast at the beginning of the rotate. Suggestions?

Code:
	
if(stage_one_complete){
		gyro.Reset();
		while(IsAutonomous() && IsEnabled() ){
			float angle = gyro.GetAngle();

			if(angle > + 70){
				kp = 0.005;
			}else if(angle < + 70){
				kp = 0.02;
			}

			myRobot.MecanumDrive_Cartesian( 0, 0, ((angle + 82) * kp), 0);
			timer ++;
			Wait (0.004);

			if(timer > 400){
				myRobot.MecanumDrive_Cartesian(0, 0, 0, 0);
				stage_one_complete = false;
				stage_two_complete = true;
				break;
			}
		}
	}
The first thing I notice is that you're resetting the gyro in the method. Unless you're using sampleRobot, the gyro will get reset again and again.

Also, in the first if statement, you did not cover the angle == 70 case; you'd probably be better off with a simple else. You also give it a larger number at the beginning, which is what I would expect that you want, but does not agree with the description at the top. Try changing the > to a < in the if and see if that's what you wanted.
__________________

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
  #3   Spotlight this post!  
Unread 20-02-2015, 15:31
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 490
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Gyro Turning in Auto Mode

Yes we are using a sampleRobot. The code works just not as expected. We want to have to robot turn and correct itself. If we were to put an else code something like:

Code:
else if (angle == 70) {
    myRobot.MecanumDrive_Cartesian(0, 0, 0, 0);
}
Then as soon as the the gyro hit 70 degrees it would stop moving. If the robot rotated to fast, which it is, it would not be able to correct itself.

We are trying to make the robot correct itself because the robot turns to fast. That's the point of changing the KP. If the angle is high KP should be low such that the robot turns slow. As the angle approaches the set angle we change KP to a bigger number such that the robot moves fast enough to turn it.

Also to note when we rotate the robot it returns a negative value. If we were to say:

Code:
                        if(angle > - 70){
				kp = 0.005;
			}else if(angle < - 70){
				kp = 0.02;
			}

myRobot.MecanumDrive_Cartesian( 0, 0, ((angle - 82) * kp), 0);
The robot rotated the wrong way.

Last edited by tomy : 20-02-2015 at 15:37.
Reply With Quote
  #4   Spotlight this post!  
Unread 20-02-2015, 16:06
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Gyro Turning in Auto Mode

It sounds like you might get what you want if you just limit the maximum turn rate. Compute Kp * angle and clip it at 0.6, or 0.4, or whatever works for you.

If you are having problems with the turn command not being enough to get the heading all the way to the target, you could add some Integral to the equation of control. That's what it's for.
Reply With Quote
  #5   Spotlight this post!  
Unread 20-02-2015, 17:32
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,495
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: Gyro Turning in Auto Mode

Quote:
Originally Posted by tomy View Post
We trying to manipulate the kp so that we turn slow at the beginning then increase the speed of rotation when we approach the angle we want.
I still can't quite figure out what you're trying to accomplish. You want to creep up on the angle until you're almost there, then gun it (and, if you do it right, force an overshoot of the target)? Or are you trying to correct for something else?
__________________

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
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 09:58.

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