public DriveTrain() { super(); front_left_motor = new Talon(1); back_left_motor = new Talon(2); front_right_motor = new Talon(3); back_right_motor = new Talon(4); drive = new RobotDrive(front_left_motor, back_left_motor, front_right_motor, back_right_motor); left_encoder = new Encoder(1, 2); right_encoder = new Encoder(3, 4); // Encoders may measure differently in the real world and in // simulation. In this example the robot moves 0.042 barleycorns // per tick in the real world, but the simulated encoders // simulate 360 tick encoders. This if statement allows for the // real robot to handle this difference in devices. if (Robot.isReal()) { left_encoder.setDistancePerPulse(0.042); right_encoder.setDistancePerPulse(0.042); } else { // Circumference in ft = 4in/12(in/ft)*PI left_encoder.setDistancePerPulse((4.0 / 12.0 * Math.PI) / 360.0); right_encoder.setDistancePerPulse((4.0 / 12.0 * Math.PI) / 360.0); } rangefinder = new AnalogInput(6); gyro = new AnalogGyro(1); // Let's show everything on the LiveWindow LiveWindow.addActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor); LiveWindow.addActuator("Drive Train", "Back Left Motor", (Talon) back_left_motor); LiveWindow.addActuator("Drive Train", "Front Right Motor", (Talon) front_right_motor); LiveWindow.addActuator("Drive Train", "Back Right Motor", (Talon) back_right_motor); LiveWindow.addSensor("Drive Train", "Left Encoder", left_encoder); LiveWindow.addSensor("Drive Train", "Right Encoder", right_encoder); LiveWindow.addSensor("Drive Train", "Rangefinder", rangefinder); LiveWindow.addSensor("Drive Train", "Gyro", gyro); }
// Called once after isFinished returns true protected void end() { // NOTE: Doesn't stop in simulation due to lower friction causing the can to fall out // + there is no need to worry about stalling the motor or crushing the can. if (!Robot.isSimulation()) Robot.claw.stop(); }