View Single Post
  #40   Spotlight this post!  
Unread 26-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
0.25 is INCREDIBLY slow, it probably could be ~0.6-0.7.


Only? As in, it measures distance instead of displacement? That would be bad. I'm assuming you just have your encoder mounted backwards, in which case you can just say
Code:
double encoder = -encoder.get();
or smth.



Can't say with any idea since I have no access to your robot
Well I bumped up the speeds to .6 but I don't know about the encoder.

I had a question with this whole function and I was wondering if it's necessary to have distanceToGo negative when I can just say it's negative when I am calling up the function. Also should I have it double -distanceToGo in the parameters?

And when I call the function forwardDrive(should it be 3000 or -3000)

Also when is it appropriate to use return; and when should I use break; when I look at my code it seems as I use break and return randomly. https://github.com/curtis0gj/5033-20...ster/Auto.java
Code:
	double kP = 0.035;
	private void forwardDrive(double distanceToGo) {
		reset();
		while (true) {
			double distance = encoder.get();
			double angle = gyro.getAngle();
			if (!robot.isAutonomous() || !robot.isEnabled()) return;
			chassis.arcadeDrive(-0.60, angle * kP);
			if (distance < -distanceToGo) {
				reset();
				return;
			}
			Timer.delay(0.02);
		}
	}

Last edited by curtis0gj : 26-02-2015 at 21:46.
Reply With Quote