Go to Post Before joining FIRST, I sure wanted to be SUPERMAN or SPIDER MAN!....but after joining FIRST, I realized that there are other ways I can help people and the world. - RoboMadi [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #32   Spotlight this post!  
Unread 23-02-2015, 17:40
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: functions for auto

Quote:
Originally Posted by Arhowk View Post
Code:
			chassis.arcadeDrive(-0.25, angle * Kp);
you never defined a "Kp" variable as far as I can see (which by the way is bad formatting, kP). First of all, you probably want to define a "Kp" variable.
Also, I assume you want this code to use the gyro to keep straight. In this case, you might want to add a reset() before the while(true) loop to ensure the gyro is 0.

Code:
				turn(90); //COULD 90 OR 180!
If you don't want to deal with the ambiguous, do the same as above and throw a reset() before the while(true) loop in your turn() function. This way, turn(90) will always turn right 90 degrees, it won't depend on the previous angle.

in Robot.java
Code:
		Auto.run(this, autoMethod);
this is still static. Since you now have a constructor and stuff, this should be "autonManager.run...".

also in Robot.java
Code:
	public AutonManager autonManager; //PUBLIC OR DOES IT MATTER?

		autonManager = new AutonManager(this);
your class is named "Auto", not "AutonManager"

Code:
 it would be greatly appreciated I am hoping this will all work for Wednesday we are having a little show casing with other schools.
#1 rule of code - it won't. I may have quite finely-tuned intuitions, but I'm not perfect.

Your "kP" value(s?) need to be tuned, the 0.01 I gave you was just a rough estimate. For example, if it doesn't turn fast enough, than this should be increased to 0.015 or something. If it turns too fast, than it should be 0.005. If it's turning the wrong way, than it should be -0.01. (honestly, I'd probably start off with 0.035, seems like a decent starting number)
Okay for the kP I just added a double like this and I added a reset to the drive forward and turn so everything works nicely. I also got rid of the autonmanager's and changed it to Auto.

Code:
	double kP = 0.035;
	private void forwardDrive(double distanceToGo) {
		reset();
		while (true) {
			double distance = encoder.get();
			double angle = gyro.getAngle();
			if (!isAutonomous() || !isEnabled()) return;
			chassis.arcadeDrive(-0.25, angle * kP);
			//chassis.drive(-0.40, 0);
			if (distance < -distanceToGo) {
				reset();
				return;
			}
			Timer.delay(0.02);
		}
	}
But I am a bit confused with:

Auto.run(this, autoMethod);
this is still static. Since you now have a constructor and stuff, this should be "autonManager.run...".
Reply With Quote
 


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 11: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