projects
/
3501
/
2017steamworks
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e12d690
)
fix bugs
author
Cindy Zhang
<cindyzyx9@gmail.com>
Fri, 27 Jan 2017 03:36:14 +0000
(19:36 -0800)
committer
Cindy Zhang
<cindyzyx9@gmail.com>
Sat, 28 Jan 2017 04:21:48 +0000
(20:21 -0800)
src/org/usfirst/frc/team3501/robot/Robot.java
patch
|
blob
|
blame
|
history
src/org/usfirst/frc/team3501/robot/commands/driving/DriveDistance.java
patch
|
blob
|
blame
|
history
src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java
patch
|
blob
|
blame
|
history
diff --git
a/src/org/usfirst/frc/team3501/robot/Robot.java
b/src/org/usfirst/frc/team3501/robot/Robot.java
index c2e4f996d49458d36e9e300d101888b341214047..a9dd0ffca26c681bc26f422abca97d940cea553a 100644
(file)
--- a/
src/org/usfirst/frc/team3501/robot/Robot.java
+++ b/
src/org/usfirst/frc/team3501/robot/Robot.java
@@
-1,6
+1,6
@@
package org.usfirst.frc.team3501.robot;
package org.usfirst.frc.team3501.robot;
-import org.usfirst.frc.team3501.robot.commands.driving.
TimeDriv
e;
+import org.usfirst.frc.team3501.robot.commands.driving.
DriveDistanc
e;
import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
import org.usfirst.frc.team3501.robot.subsystems.Intake;
import org.usfirst.frc.team3501.robot.subsystems.Shooter;
import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
import org.usfirst.frc.team3501.robot.subsystems.Intake;
import org.usfirst.frc.team3501.robot.subsystems.Shooter;
@@
-40,7
+40,7
@@
public class Robot extends IterativeRobot {
@Override
public void autonomousInit() {
@Override
public void autonomousInit() {
- Scheduler.getInstance().add(new
TimeDrive(1.5, 0.4
));
+ Scheduler.getInstance().add(new
DriveDistance(25, 10
));
}
@Override
}
@Override
diff --git
a/src/org/usfirst/frc/team3501/robot/commands/driving/DriveDistance.java
b/src/org/usfirst/frc/team3501/robot/commands/driving/DriveDistance.java
index 47fc46ea0303ed6689b3c2a03b6c918b30407c8f..5c0c20b92a7ee20f2a83d0fbaec3da6792462aba 100755
(executable)
--- a/
src/org/usfirst/frc/team3501/robot/commands/driving/DriveDistance.java
+++ b/
src/org/usfirst/frc/team3501/robot/commands/driving/DriveDistance.java
@@
-1,6
+1,5
@@
package org.usfirst.frc.team3501.robot.commands.driving;
package org.usfirst.frc.team3501.robot.commands.driving;
-import org.usfirst.frc.team3501.robot.MathLib;
import org.usfirst.frc.team3501.robot.Robot;
import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
import org.usfirst.frc.team3501.robot.utils.PIDController;
import org.usfirst.frc.team3501.robot.Robot;
import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
import org.usfirst.frc.team3501.robot.utils.PIDController;
@@
-31,8
+30,11
@@
public class DriveDistance extends Command {
private double driveI;
private double driveD;
private double driveI;
private double driveD;
- public DriveDistance(double distance, double m
otorVal
) {
+ public DriveDistance(double distance, double m
axTimeOut
) {
requires(driveTrain);
requires(driveTrain);
+ this.maxTimeOut = maxTimeOut;
+ this.target = distance;
+
this.driveP = driveTrain.driveP;
this.driveI = driveTrain.driveI;
this.driveD = driveTrain.driveD;
this.driveP = driveTrain.driveP;
this.driveI = driveTrain.driveI;
this.driveD = driveTrain.driveD;
@@
-69,12
+71,12
@@
public class DriveDistance extends Command {
.calcPID(this.driveTrain.getAngle() - this.driveTrain.getZeroAngle());
}
// System.out.println("turn: " + xVal);
.calcPID(this.driveTrain.getAngle() - this.driveTrain.getZeroAngle());
}
// System.out.println("turn: " + xVal);
- double leftDrive =
MathLib.calcLeftTankDrive(-xVal, yVal)
;
- double rightDrive =
MathLib.calcRightTankDrive(xVal, -yVal)
;
+ double leftDrive =
yVal - xVal
;
+ double rightDrive =
yVal + xVal
;
this.driveTrain.setMotorValues(leftDrive, rightDrive);
this.driveTrain.setMotorValues(leftDrive, rightDrive);
-
System.out.println(driveTrain.getAvgEncoderDistance()
);
+
driveTrain.printEncoderOutput(
);
// System.out.println("motorval: " + yVal);
}
// System.out.println("motorval: " + yVal);
}
diff --git
a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java
b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java
index ba5392a62075ba75f66adfa032e68391fb4a84a7..44744c4a078fa0f0edca7d3b0a6ca5e2290b481a 100644
(file)
--- a/
src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java
+++ b/
src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java
@@
-7,6
+7,7
@@
import org.usfirst.frc.team3501.robot.utils.BNO055;
import com.ctre.CANTalon;
import edu.wpi.first.wpilibj.Encoder;
import com.ctre.CANTalon;
import edu.wpi.first.wpilibj.Encoder;
+import edu.wpi.first.wpilibj.I2C.Port;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.command.Subsystem;
@@
-46,6
+47,10
@@
public class DriveTrain extends Subsystem {
// ROBOT DRIVE
robotDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
// ROBOT DRIVE
robotDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
+
+ this.imu = BNO055.getInstance(BNO055.opmode_t.OPERATION_MODE_IMUPLUS,
+ BNO055.vector_type_t.VECTOR_EULER, Port.kOnboard, (byte) 0x28);
+ gyroZero = imu.getHeading();
}
public static DriveTrain getDriveTrain() {
}
public static DriveTrain getDriveTrain() {
@@
-98,6
+103,11
@@
public class DriveTrain extends Subsystem {
return rightEncoder.getDistance();
}
return rightEncoder.getDistance();
}
+ public void printEncoderOutput() {
+ System.out.println("left: " + getLeftEncoderDistance());
+ System.out.println("right: " + getRightEncoderDistance());
+ }
+
public double getAvgEncoderDistance() {
return (leftEncoder.getDistance() + rightEncoder.getDistance()) / 2;
}
public double getAvgEncoderDistance() {
return (leftEncoder.getDistance() + rightEncoder.getDistance()) / 2;
}