-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
98 changed files
with
2,670 additions
and
1,616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"tags": [ | ||
{ | ||
"ID": 101, | ||
"pose": { | ||
"translation": { | ||
"x": 0.0, | ||
"y": 2.0, | ||
"z": 1.0 | ||
}, | ||
"rotation": { | ||
"quaternion": { | ||
"W": 1.0, | ||
"X": 0.0, | ||
"Y": 0.0, | ||
"Z": 0.0 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"ID": 102, | ||
"pose": { | ||
"translation": { | ||
"x": 8.0, | ||
"y": 2.0, | ||
"z": 1.0 | ||
}, | ||
"rotation": { | ||
"quaternion": { | ||
"W": 0.0, | ||
"X": 0.0, | ||
"Y": 0.0, | ||
"Z": 1.0 | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"field": { | ||
"length": 8.0, | ||
"width": 4.0 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
comp/swerve100/src/main/java/org/team100/frc2024/MockSensors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 96 additions & 89 deletions
185
comp/swerve100/src/main/java/org/team100/frc2024/RobotContainer.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
comp/swerve100/src/main/java/org/team100/frc2024/commands/climber/HomeClimber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package org.team100.frc2024.commands.climber; | ||
|
||
import java.util.OptionalDouble; | ||
|
||
import org.team100.frc2024.motion.climber.ClimberSubsystem; | ||
import org.team100.lib.dashboard.Glassy; | ||
import org.team100.lib.motion.LimitedLinearMechanism; | ||
import org.team100.lib.telemetry.SupplierLogger; | ||
import org.team100.lib.telemetry.Telemetry.Level; | ||
import org.team100.lib.util.Timer100; | ||
import org.team100.lib.util.Util; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
/** | ||
* The zeroing process has four states, which are indicated by the states of the | ||
* two timers: | ||
* | ||
* <pre> | ||
* initial: set the effort to low and start the start timer | ||
* | ||
* starting state (start timer running, end timer not running): run at the target speed | ||
* | ||
* transition: when the start timer runs out: | ||
* | ||
* running state (start timer > limit, end timer not running): run at the target speed | ||
* | ||
* transition: when the actual speed is below the threshold, start the stop timer | ||
* | ||
* stopping state (start timer > limit, end timer running): run at the target speed | ||
* | ||
* transition: when the stop timer runs out, zero the mechanism | ||
* | ||
* done state (start timer > limit, end timer > limit): set speed to zero | ||
* </pre> | ||
*/ | ||
public class HomeClimber extends Command implements Glassy { | ||
/** Target speed is negative, i.e. down. */ | ||
private static final double kTargetSpeedM_S = -0.03; | ||
/** Threshold is unsigned. */ | ||
private static final double kThresholdSpeedM_S = 0.003; | ||
/** Wait 0.5s to start moving. */ | ||
private static final double kStartTimeS = 0.2; | ||
/** Wait 0.5s to stop moving. */ | ||
private static final double kHomeTimeS = 0.2; | ||
|
||
private final SupplierLogger m_logger; | ||
private final ClimberSubsystem m_climber; | ||
private final Timer100 m_leftStart; | ||
private final Timer100 m_leftDone; | ||
private final Timer100 m_rightStart; | ||
private final Timer100 m_rightDone; | ||
|
||
public HomeClimber( | ||
SupplierLogger logger, | ||
ClimberSubsystem climber) { | ||
m_logger = logger.child(this); | ||
m_climber = climber; | ||
m_leftStart = new Timer100(); | ||
m_leftDone = new Timer100(); | ||
m_rightStart = new Timer100(); | ||
m_rightDone = new Timer100(); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
init(m_leftStart, m_leftDone); | ||
init(m_rightStart, m_rightDone); | ||
m_climber.setHomingForce(); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
oneSide("left", m_leftStart, m_leftDone, m_climber.getLeft()); | ||
oneSide("right", m_rightStart, m_rightDone, m_climber.getRight()); | ||
} | ||
|
||
private static void init(Timer100 start, Timer100 done) { | ||
done.stop(); | ||
done.reset(); | ||
start.restart(); | ||
} | ||
|
||
private void oneSide( | ||
String name, | ||
Timer100 start, | ||
Timer100 done, | ||
LimitedLinearMechanism mech) { | ||
m_logger.logDouble(Level.TRACE, name + " start timer (s)", start::get); | ||
m_logger.logDouble(Level.TRACE, name + " done timer (s)", done::get); | ||
OptionalDouble opt = mech.getVelocityM_S(); | ||
if (opt.isEmpty()) { | ||
Util.warn("HomeClimber: can't home, broken velocity sensor!"); | ||
mech.stop(); | ||
return; | ||
} | ||
if (start.get() < kStartTimeS) { | ||
// starting up, run the mech unconditionally | ||
mech.setVelocityUnlimited(kTargetSpeedM_S, 0, 0); | ||
} else { | ||
if (done.isStopped()) { | ||
// have not noticed speed decline, keep going. | ||
mech.setVelocityUnlimited(kTargetSpeedM_S, 0, 0); | ||
if (Math.abs(opt.getAsDouble()) < kThresholdSpeedM_S) { | ||
// mech seems stopped, start the done timer | ||
done.start(); | ||
} | ||
} else { | ||
if (done.get() < kHomeTimeS) { | ||
// speed is below the threshold, wait a bit. | ||
mech.setVelocityUnlimited(kTargetSpeedM_S, 0, 0); | ||
} else { | ||
// speed has been below the threshold for awhile, so we're done | ||
mech.stop(); | ||
mech.resetEncoderPosition(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return m_leftDone.get() > kHomeTimeS && m_rightDone.get() > kHomeTimeS; | ||
} | ||
|
||
@Override | ||
public String getGlassName() { | ||
return "HomeClimber"; | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
.../drivetrain/manual/ManualWithAmpLock.java → .../drivetrain/manual/ManualWithAmpLock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...vetrain/manual/ManualWithShooterLock.java → ...vetrain/manual/ManualWithShooterLock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.