mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 08:48:07 -06:00
TT timing in auto, idk if works
This commit is contained in:
@@ -454,7 +454,7 @@ public class RobotContainer {
|
|||||||
// * assume turret is already pointed towards target.
|
// * assume turret is already pointed towards target.
|
||||||
return new SequentialCommandGroup( new InstantCommand(() -> m_robotSwerveDrive.resetGyro(), m_robotSwerveDrive),
|
return new SequentialCommandGroup( new InstantCommand(() -> m_robotSwerveDrive.resetGyro(), m_robotSwerveDrive),
|
||||||
new DriveWithInputForTime(m_robotSwerveDrive, new double[] {0.5, 0.5, 0.0, 0.0}, 1.0),
|
new DriveWithInputForTime(m_robotSwerveDrive, new double[] {0.5, 0.5, 0.0, 0.0}, 1.0),
|
||||||
new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry));
|
new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry, true));
|
||||||
|
|
||||||
// * aim with RotateUntilTarget
|
// * aim with RotateUntilTarget
|
||||||
// return new SequentialCommandGroup( new InstantCommand(() -> m_robotSwerveDrive.resetGyro(), m_robotSwerveDrive),
|
// return new SequentialCommandGroup( new InstantCommand(() -> m_robotSwerveDrive.resetGyro(), m_robotSwerveDrive),
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public class TrackTarget extends CommandBase {
|
|||||||
BoomBoom m_boomBoom;
|
BoomBoom m_boomBoom;
|
||||||
Hood m_hood;
|
Hood m_hood;
|
||||||
|
|
||||||
|
boolean isAuto;
|
||||||
|
|
||||||
static double velocity;
|
static double velocity;
|
||||||
static double hoodPosition;
|
static double hoodPosition;
|
||||||
|
|
||||||
@@ -46,18 +48,35 @@ public class TrackTarget extends CommandBase {
|
|||||||
|
|
||||||
boolean isExecuted = false;
|
boolean isExecuted = false;
|
||||||
|
|
||||||
public TrackTarget (Turret turret, BoomBoom boomBoom, Hood hood, VisionOdometry visionOdometry) {
|
// timing
|
||||||
|
boolean isAimed;
|
||||||
|
|
||||||
|
boolean timerStarted;
|
||||||
|
long startTime;
|
||||||
|
private double timeTolerance;
|
||||||
|
|
||||||
|
public TrackTarget (Turret turret, BoomBoom boomBoom, Hood hood, VisionOdometry visionOdometry, boolean isAuto) {
|
||||||
m_turret = turret;
|
m_turret = turret;
|
||||||
m_boomBoom = boomBoom;
|
m_boomBoom = boomBoom;
|
||||||
m_hood = hood;
|
m_hood = hood;
|
||||||
m_visionOdometry = visionOdometry;
|
m_visionOdometry = visionOdometry;
|
||||||
|
|
||||||
|
this.isAuto = isAuto;
|
||||||
|
this.timeTolerance = 1000;
|
||||||
|
|
||||||
addRequirements(m_turret, m_boomBoom, m_hood, m_visionOdometry);
|
addRequirements(m_turret, m_boomBoom, m_hood, m_visionOdometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TrackTarget(Turret turret, BoomBoom boomBoom, Hood hood, VisionOdometry visionOdometry) {
|
||||||
|
this(turret, boomBoom, hood, visionOdometry, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Called when the command is initially scheduled.
|
// Called when the command is initially scheduled.
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
timerStarted = false;
|
||||||
|
startTime = 0;
|
||||||
|
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
hoodPosition = 0;
|
hoodPosition = 0;
|
||||||
}
|
}
|
||||||
@@ -110,6 +129,8 @@ public class TrackTarget extends CommandBase {
|
|||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timing
|
||||||
}
|
}
|
||||||
|
|
||||||
// public ArrayList<Point> filterPoints(ArrayList<Point> points) {
|
// public ArrayList<Point> filterPoints(ArrayList<Point> points) {
|
||||||
@@ -161,7 +182,15 @@ public class TrackTarget extends CommandBase {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return false;
|
if (this.isAuto) {
|
||||||
|
if (targetLocked& !timerStarted) {
|
||||||
|
timerStarted = true;
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
return (targetLocked && timerStarted && ((System.currentTimeMillis() - startTime) > timeTolerance));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// return isExecuted && Math.abs(output) < .1;
|
// return isExecuted && Math.abs(output) < .1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user