View Single Post
  #28   Spotlight this post!  
Unread 23-02-2015, 12:39
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
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.


Same with everyone else I've ever taught, its np.

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.


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)


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.

Always.

Okay so the actual function for driving and turning is RobotDrive.arcadeDrive? would chassis.drive do the same thing. Because I have been using chassis.drive in the past. Other than this I think my functions are looking good.

Last edited by curtis0gj : 23-02-2015 at 13:08.
Reply With Quote