View Single Post
  #2   Spotlight this post!  
Unread 02-20-2015, 12:17 PM
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: functions for auto

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

Last edited by Arhowk : 02-20-2015 at 12:19 PM.
Reply With Quote