Quote:
Originally Posted by curtis0gj
Okay I will start making these changes and to you also asked about my experience in java and mentors and I have about 1-2 months of experience using java and programming in general. I'm fairly new to it all.
Unfortunately, we don't have any programming mentors and I am the only one programming this year so everything has been very daunting. 
|
Heh, same here, except I have ~10 years of programming experience along with ~3 years of Java experience. Too bad I don't have an active passport, else I'd be willing to physically mentor :/ not a whole fan of the text-per-day thing.
Quote:
|
Also I have a few questions to verify some things. Sorry I may be a bit slow with all of this stuff and you may have to repeat things...
|
Same with everyone else I've ever taught, its np.
Quote:
Anyway I think I understand the static part I just need to get rid of them because I now have a construction. But you kind of lost me with:
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.
With this ^ do you mean like this.chassis = ??; and this.gyro =??;
Okay I put a bit more thought into this and read the older posts and I think I am on the right track here's what I have done to call up variables.
Code:
public class Auto {
Robot robot;
RobotDrive chassis;
DigitalInput limit;
DigitalInput limit2;
DigitalInput limit3;
Gyro gyro;
Encoder encoder;
Relay leftArmWheel;
Relay rightArmWheel;
Victor screwMotor1;
Victor screwMotor2;
Victor armMotor;
public Auto(Robot r){
this.robot = r;
this.chassis = r.chassis;
this.gyro = r.gyro;
this.encoder = r.encoder;
this.limit = r.limit;
this.limit2 = r.limit2;
this.limit3 = r.limit3;
this.leftArmWheel = r.leftArmWheel;
this.rightArmWheel = r.rightArmWheel;
this.screwMotor1 = r.screwMotor1;
this.screwMotor2 = r.screwMotor2;
this.armMotor = r.armMotor
}
|
First thing, when you dont specify an object to draw from (referring to the "robot" in "robot.armMotor"), it automatically draws from either the local space (ex. if you wrote "int i = 0") or it draws from the "this" space.
What you're doing here is a few things
Code:
public Auto(Robot r){
this.chassis = r.chassis;
(aside from the constructor stuff I talked about)
1) You're recieving an instance of Robot to draw data from
2) You're drawing the object "chassis" out of the recieved instance of robot
3) You are then storing the recieved "chassis" object into an object contained within the "Auto" instance also named "chassis". (Note: Java is pass-by-value, which means that if "chassis" inside of the "Robot" instance were to be changed after the time that it was sent to the "Auto" instance, the "chassis" object will remain the same "chassis" object that it was when it was initially constructed. ex.
Code:
int i = 0;
Integer integ = new Integer(i);
System.out.println(integ.intValue());//will print 0 since it was passed 0
i = 55;
System.out.println(integ.intValue());//will still print 0 since it was passed 0, it was passed the value 0 not the variable "i"
</endtangent>)
Anyway, now that you're taking the chassis object from the robot and placing it inside of the "Auto" instance, the "r." is no longer needed since it is now inside the "this." namespace which is automatic.
Quote:
|
And the detached head issue the link was a bit technical for me but should I consider using google code or something else?
|
Nah, I'd just try to slow down on the commits. Once/twice per day is fine, with upwards of 10/12 per competition day (1 before, 1 before every match, 1 at the end of the day)
Also note that detached heads are really only an issue if you have more than one user accessing the git repo; since you are the only on it probably isn't a huge deal (unless you code with 4 laptops or something silly like that)
Quote:
Also: chassis.drive(0, deltaAngle * kp_rotate);
should I change 0 to 0.25 for a speed?
|
Again, this was pseudocode. (maybe I should stop that

) The actual function is
Code:
RobotDrive.arcadeDrive(move,rotate);
as used in your Robot.java. "move" defines the value to move forward or backward and "rotate" defines left or right. Having a 0 move will cause the robot to spin in place. If you want the robot to turn without actually moving anywhere, than a 0 move is needed.
Quote:
|
my apologies for not understanding I will read it a few more times but if you are available later some further explanation would be awesome.
|
Always.