View Single Post
  #3   Spotlight this post!  
Unread 02-20-2015, 02:19 PM
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
FYI you can build them to search for syntax errors... like this

Code:
	private static void wait(Robot r, double waittime) {
		while (true) {
			if (!.risAutonomous() || !r.isEnabled()) return;
			r.Timer.delay(waittime); //r or just timer?
			return;
		}
		private static void reset(Robot r) {
missing a } and i assume you mean ""!r.is..." not "!.ris..." (also, its just Timer.delay)

passing in Robot for everything is ugh-ly. just make Robot a singleton... or use a static initializer

Code:
			while (true) {
				double distance = r.encoder.get();
				double angle = r.gyro.getAngle();
				if (!r.isAutonomous() || !r.isEnabled()) return;
				r.robot.drive(-0.25, angle * r.Kp);
				//r.robot.drive(-0.40, 0);
				if (distance < -d) {
					reset(r);
					return;
				}
			}
the closed loop structure of this will hurt the robot, periodic ms timers are necessary

Code:
r.robot.drive(-.40, -1)
not Java-standard formatting

Code:
				Boolean maxarmlimit = r.limit4.get();
capital boolean (also that name scheme is bad, both on the variable and the limit)

Code:
					r.armmotor.set(Defines.ARM_SPEED);
					r.leftarmwheel.set(Relay.Value.kForward);
					r.rightarmwheel.set(Relay.Value.kReverse);
non-standard formatting (camelcase, descriptive names)

Code:
				if (angle > deg) {
comparing a double and an int

Code:
				r.robot.drive(-.40, -1);
constant loop? atleast a P loop, preferably PID

your "turn" and "turn2" functions are quite ineffective, basic angle averaging schemes should be used

other than that I'm losing my focus, but there are alot more issues
Alright thanks I am going to make those changes.
Reply With Quote