private Encoder leftEncoder, rightEncoder;
- public static Lidar leftLidar;
- public static Lidar rightLidar;
+ public static Lidar lidar;
private CANTalon frontLeft, frontRight, rearLeft, rearRight;
private RobotDrive robotDrive;
robotDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
- leftLidar = new Lidar(I2C.Port.kOnboard);
- rightLidar = new Lidar(I2C.Port.kOnboard); // TODO: find port for second
- // lidar
+ lidar = new Lidar(I2C.Port.kMXP);
leftEncoder = new Encoder(Constants.DriveTrain.ENCODER_LEFT_A,
Constants.DriveTrain.ENCODER_LEFT_B, false, EncodingType.k4X);
rightEncoder = new Encoder(Constants.DriveTrain.ENCODER_RIGHT_A,
rightEncoder.reset();
}
- public double getLeftLidarDistance() {
- return leftLidar.pidGet();
- }
-
- public double getsRightLidarDistance() {
- return rightLidar.pidGet();
+ public double getLidarDistance() {
+ return lidar.pidGet();
}
public double getRightSpeed() {
/*
* Method is a required method that the PID Subsystem uses to return the
* calculated PID value to the driver
- *
+ *
* @param Gives the user the output from the PID algorithm that is calculated
* internally
- *
+ *
* Body: Uses the output, does some filtering and drives the robot
*/
@Override
/*
* Checks the drive mode
- *
- * @return the current state of the robot in each state
- * Average distance from both sides of tank drive for Encoder Mode
- * Angle from the gyro in GYRO_MODE
+ *
+ * @return the current state of the robot in each state Average distance from
+ * both sides of tank drive for Encoder Mode Angle from the gyro in GYRO_MODE
*/
private double sensorFeedback() {
if (DRIVE_MODE == Constants.DriveTrain.ENCODER_MODE)
/*
* @param left and right setpoints to set to the left and right side of tank
* inverted is for Logan, wants the robot to invert all controls left = right
- * and right = left
- * negative input is required for the regular rotation because RobotDrive
- * tankdrive method drives inverted
+ * and right = left negative input is required for the regular rotation
+ * because RobotDrive tankdrive method drives inverted
*/
public void drive(double left, double right) {
robotDrive.tankDrive(-left, -right);
// dunno why but inverted drive (- values is forward)
if (!Constants.DriveTrain.inverted)
- robotDrive.tankDrive(-left,
- -right);
+ robotDrive.tankDrive(-left, -right);
else
robotDrive.tankDrive(right, left);
}
}
/*
- * Sets the encoder mode
- * Updates the PID constants sets the tolerance and sets output/input ranges
- * Enables the PID controllers
+ * Sets the encoder mode Updates the PID constants sets the tolerance and sets
+ * output/input ranges Enables the PID controllers
*/
public void setEncoderPID() {
DRIVE_MODE = Constants.DriveTrain.ENCODER_MODE;
}
/*
- * Sets the Gyro Mode
- * Updates the PID constants, sets the tolerance and sets output/input ranges
- * Enables the PID controllers
+ * Sets the Gyro Mode Updates the PID constants, sets the tolerance and sets
+ * output/input ranges Enables the PID controllers
*/
private void setGyroPID() {
DRIVE_MODE = Constants.DriveTrain.GYRO_MODE;
/*
* Turning method that should be used repeatedly in a command
- *
+ *
* First constrains the angle to within -360 and 360 since that is as much as
* we need to turn
- *
+ *
* Configures Gyro PID and sets the setpoint as an angle
*/
public void turnAngle(double angle) {
}
/*
- * @return a value that is the current setpoint for the piston
- * kReverse or kForward
+ * @return a value that is the current setpoint for the piston kReverse or
+ * kForward
*/
public Value getLeftGearPistonValue() {
return leftGearPiston.get();
}
/*
- * @return a value that is the current setpoint for the piston
- * kReverse or kForward
+ * @return a value that is the current setpoint for the piston kReverse or
+ * kForward
*/
public Value getRightGearPistonValue() {
return rightGearPiston.get();
leftGearPiston.set(gear);
rightGearPiston.set(gear);
}
+
}