![]() |
Is my Java code ok?
Hi, I'm head programmer of Team 6077 (rookie team). I was wondering if one of you could be kind enough to look through my code (Java) to make sure it follows the rules, and theoretically works.
Code:
package org.usfirst.frc.team6077.robot; |
Re: Is my Java code ok?
the last line where you set your solenoid to kOff: it will cut the input pressure to your mechanism, meaning it will not hold the last position. you likely don't want this line
|
Re: Is my Java code ok?
Quote:
|
Re: Is my Java code ok?
I see that you initialized the RobotDrive with the port numbers of your speed controllers. I believe that this will work correctly because you are using victors, but it would be better practice to initialize it with the two speed controllers you already initialized.
Code:
drive = new RobotDrive(drivermotor1, drivemotor2); |
Re: Is my Java code ok?
On the tank drive line, you want to be using axis 2 and 5 for left and right Y axis'.
|
Re: Is my Java code ok?
Quote:
also, your condition testing with Math.abs removes the negative sign, so your second if test will never work This is how it could be made Code:
// Move sliding mechanism forwards and backwards |
Re: Is my Java code ok?
Won't this only work if I move the stick up? Shouldn't I need both > and < .1 if I'd like to both increase and decrease
Example of what I mean: Code:
if (Math.abs(xboxController.getRawAxis(5)) > .1) { |
Re: Is my Java code ok?
Quote:
|
Re: Is my Java code ok?
For us, although the code said "build successful" for code similar as shown below, it will throw an error (on the robot) and the driver station noted no code on the robot.
Code:
drivemotor1 = new Victor(0);Quote:
|
Re: Is my Java code ok?
Quote:
if (Math.abs(xboxController.getRawAxis(5) < .1) is equivalent to if(xboxController.getRawAxis(5) < .1 && xboxController.getRawAxis(5) > -.1) Let's say you put Math.abs(-0.05). that will output 0.05. I recommend you try it out and print in the Riolog. That saves you a few lines in your code, instead of testing for both positive and negative values. |
Re: Is my Java code ok?
Quote:
|
Re: Is my Java code ok?
Quote:
|
| All times are GMT -5. The time now is 05:33. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi