|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#2
|
|||
|
|||
|
Re: Is my code good?
There is lots to like about your code. It's well organized and generally easy to read. A couple specific comments:
1. We like to use constants in RobotMap.java, organized by kind of interface. We can then print this out and use it as instructions for wiring. For example: Code:
/**
* PWM */
public static final int CHASSIS_JAGUAR_FRONT_LEFT = 2;
public static final int CHASSIS_JAGUAR_BACK_LEFT = 3;
public static final int CHASSIS_JAGUAR_FRONT_RIGHT = 0;
public static final int CHASSIS_JAGUAR_BACK_RIGHT = 1;
public static final int BALL_SHOOTER_LEFT_SPEED_CONTROLLER = 4;
public static final int BALL_SHOOTER_RIGHT_SPEED_CONTROLLER = 5;
public static final int ARM_EXTEND_SPEED_CONTROLLER = 6;
public static final int CAMERA_TILT_MOTOR = 7;
You're almost there with your final references in the subsystems, but they are copies of reference and the actual controller/encoder/gyro is available to everyone. 2. In AvancerHerse, consider using more descriptive variable names: Code:
int h1 = 950; int h2 = 450; Code:
if (!Robot.pelle.herseAcotee()) {
// h1, h2 = hauteur pelle
if ((Robot.bras.distPot() > h1)) {
Robot.chassis.reculer(-0.4, 0);
} else if ((Robot.bras.distPot() > h2) && !(Robot.bras.distPot() < h1)) {
Robot.chassis.reculer(-0.6, 0);
} else {
Robot.chassis.reculer(-0.9, 0);
}
}
Code:
Timer.delay(0.005); 4. In BrasCommand, you didn't put this in braces: Code:
} else Robot.bras.controlBras(0); 5. Generally you want the same code in end() and interrupted() -- see Reculer. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|