View Single Post
  #25   Spotlight this post!  
Unread 22-02-2015, 20:14
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: 543
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

Quite tired so I ca't give you another full sweep, but a few things
Code:
	public AutonManager autonManager; //PUBLIC OR DOES IT MATTER?
doesn't matter. Same issue in the following poing

Code:
	Robot robot
	public AutonManager(Robot r){
	this.robot = r;
	}
(first of all, bad indenting)
By not specifying a return type, you are making a constructor, which must have the same name of your class [in this case, "Auto"]. I called it "AutonManager" because I couldn't remember what you called it and chose the name I would've used. In this case, "AutonManager" would be "Auto" since the name of the class is "Auto" (as seen by: "Auto auto = new Auto();" (long story short: this should be public Auto(){))

Now, you chose the constructor, which was the proper choice since it followed wpi-standards. However, you left everything else static

Code:
	public static void run(AUTOS autoMode) {
The static method means that it doesn't need a constructor and thusly cannot access non-static variables, such as

Code:
	Robot robot
(since there is no "static" keyword, it is defaulted to "instanceable" so static methods cannot access it)

I have some homework to do so I'll have to cut the rest of this short. Please do some independent study on the "static" keyword, constructors, and other fundamentals of Java. I don't know your level of talent with Java and I code it professionally so I may be telling you what to write and not how to write it, which is a mistake that should never be made.

On a side note, what is your mentor situation?

Quote:
Originally Posted by curtis0gj View Post
Thanks for the awesome reply very detailed and understandable. I have made a lot of changes to the code and I think I am nearing completion. I am very pleased and grateful for the help! Later tonight I will give the code a build in eclipse to check for any syntax errors. If you don't mind giving it a final look over, I have removed all of the "r." and I have changed the name for robot, the RobotDrive variable that I define in my Robot.java class to chassis for less confusion.

Also I may have misunderstood you said I no longer needed the r parameter does this mean I will still need "r." or can I throw it out the window. My understanding of what a parameter is may be wrong.....
Yes, you misunderstood me. Let's break it down right fast. in Robot.java

Code:
public class Robot{
	public RobotDrive chassis;
	public Joystick stick;
By being in the class "Robot", the class robot must be accessed in some way in order for "chassis" and "stick" to be accessed, since nothing in Java is global.

The "public" keyword means that other stuff can access these variables, if you didn't want them to be changed than you can change them to private but you want these public in this case.

"RobotDrive" and "Joystick" are the classes. Somewhere in WPI code there is a

Code:
public class Joystick{
//code code code
}
and likewise for robotdrive. Calling Joystick.staticMethod() is only possible if staticMethod is indeed static, since no enclosing instance of Joystick is given. Calling stick.nonStaticMethod() is possible since the "Joystick" object "stick" is given.

Anyway, you're not specifying what you want to get "chassis", "gyro", "encoder", etc. You have to call "robot.chassis. ..." since you need to specify what instance of "Robot" you want to draw a variable called "chassis" from.

Quote:
The final concern/question I have is regarding an issue I had in the past. The issue was the robot would do two things at once for example, I wanted to the robot to lift a bin wait then move forward. What ended up happening was the robot attempted to lift the bin and move forward at the same time. This was very problematic... Anyway it could have been a bug in the old code I was using. It had some grotesque while and if loops in it.
Not 100% but that shouldn't be an issue now since all of your while(true) loops are isolated.

long story short: remove "static" keyword, fix indenting, gotta have "robot.chassis" and etc.

I'd also recommend not pushing to the github so much as it's not necessary / might cause a detached head (had a couple of those fun little puppies) (I apologize in advance if the link is too technical)

Last edited by Arhowk : 22-02-2015 at 20:18.
Reply With Quote