![]() |
functions for auto
Hey guys I just finished my autonomous program on bag night and the next day realised how long and messy it was. So I got some help and made functions but I can't test them :mad: . So if anyone is able to help me here's the github link https://github.com/curtis0gj/5033-2014-15?files=1.
|
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) {passing in Robot for everything is ugh-ly. just make Robot a singleton... or use a static initializer Code:
while (true) {Code:
r.robot.drive(-.40, -1)Code:
Boolean maxarmlimit = r.limit4.get();Code:
r.armmotor.set(Defines.ARM_SPEED);Code:
if (angle > deg) {Code:
r.robot.drive(-.40, -1);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 |
Re: functions for auto
Quote:
|
Re: functions for auto
should distance be an int or a double and how should I add the periodic timer?
|
Re: functions for auto
Quote:
for distance, i usually go with doubles for most things so I don't accidentally mess data up with division. don't know what the second thing you asked is in reference to. If it's the closed loop, than just do a Timer.delay(0.02) (20ms, standard 50hz operating cycle) inside the while(true) loop |
Re: functions for auto
Quote:
https://github.com/curtis0gj/5033-20...ster/Auto.java |
Re: functions for auto
Preferably it would be the last line (with it at the first, theres a 20ms delay before any actions are performed)
Your indenting for everything after "wait" is now wrong AUTOS should not be capitalized (and should be descriptive: "AutonMode", "SelectedAutonMode", "AutonEnum", etc) turn and turn2 still need to be turned into feedback loops but for now rename them to turnLeft and turnRight and make one function- turn- that if gyro < desired than turnLeft(angle) else turnRight(angle) capitalization schemes are wrong in Robot.java (http://java.about.com/od/javasyntax/...onventions.htm) Code:
if (autoMethod == Defines.AUTOS.AUTO_ONE) {Why is your wait function inside of a while(true) loop? |
Re: functions for auto
Quote:
Code:
public static void turn(Robot r, double deg) { |
Re: functions for auto
Quote:
Code:
public static void turn(Robot r, double deg) {E/ misunderstood the point of the code, fixed. |
Re: functions for auto
Quote:
|
Re: functions for auto
Quote:
note that I edited that post like 5 times. Anyway, heres a (maybe) working function Code:
public static double angleError(double setpointDegressZeroToThreeSixty, double experimentalDegrees){ |
Re: functions for auto
Quote:
|
Re: functions for auto
Quote:
|
Re: functions for auto
Quote:
|
Re: functions for auto
apologies, wrapped up in poe.
Quote:
Quote:
Timer.delay will wait the desired time. For the new loops, they automatically wait untill finished so this isn't needed. If you wanted to add an extra wait, just throw in a Timer.delay() before turn, drive, etc. calls |
| All times are GMT -5. The time now is 13:05. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi