Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate debugoi controls for left and right climber #93

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions docs/OperatorInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ TODO: consider this customization.
<td><strong>Y-axis:</strong>Rotate counterclockwise/clockwise</td>
</tr>
<tr>
<td><strong>Button 9</strong>: Reset gyro</td>
<td><strong>Button 1 (Trigger)</strong>: Target lock (hold to auto-aim at speaker, release to stop)</td>
<td><strong>Button 1 (Trigger)</strong>: Fine driving<br>(slow down to 25%)</td>
</tr>
<tr>
<td><strong>Button 15</strong>: Reset position (odometry)</td>
<td><strong>Button 3</strong>: Cross wheels</td>
<td><strong>Button 3</strong>: Shoot note</td>
</tr>
<tr>
<td><strong>Button 9</strong>: Reset gyro</td>
<td></td>
</tr>
<tr>
<td colspan="2"><strong>NOTE: X-axis is up/down, Y-axis is sideways</strong></td>
Expand Down Expand Up @@ -87,19 +91,25 @@ We use a wired Xbox Controller (the Logitech gamepad in Xbox mode also works for
<td>DPAD DOWN</td>
<td>Nudge shoulder down.</td>
</tr>

<tr>
<td>RT</td>
<td>Hold to spin shooter</td>
</tr>

<tr>
<td>LB</td>
<td>Hold to run intake (in)</td>
</tr>
<tr>
<td>RB</td>
<td>Hold to run intake (out)</td>
</tr>
<tr>
<td>Left Stick</td>
<td>Control left climber (within soft limits)</td>
</tr>
<tr>
<td>Right Stick</td>
<td>Control right climber (within soft limits)</td>
</tr>
</table>

Expand All @@ -124,36 +134,36 @@ TODO: put together page with instructions on how to flash the firmware.
<td>1</td>
<td>Hold to control shoulder (with up/down or dials)</td>
</tr>
<tr>
<tr>
<td>2</td>
<td>Hold to control climber (with up/down or dials)<br>Work in progress.</td>
<td>Hold to run shooter. Can speed up and slow down (with up/down or dials).</td>
</tr>
<tr>
<td>3</td>
<td>Hold to run intake (in)</td>
<td>Hold to control left climber (with up/down or dials). Bypasses soft limits.
</tr>
<tr>
<td>4</td>
<td>Hold to run shooter. Can speed up and slow down (with up/down or dials).</td>
<td>Hold to control right climber (with up/down or dials). Bypasses soft limits.
</tr>
<tr>
<td>7</td>
<td>5</td>
<td>Hold to run intake (in)</td>
</tr>
<tr>
<td>6</td>
<td>Hold to run intake (out).</td>
</tr>

<tr>
<td>8</td>
<td>Moves mechanism being controlled (via another button) up.</td>
</tr>

<tr>
<td>12</td>
<td>Moves mechanism being controlled (via another button) down.</td>
</tr>

<tr>
<td>9</td>
<td>Reset relative encoders on shoulder.</td>
<td>16</td>
<td>Reset relative encoders on climber.</td>
</tr>

</table>
57 changes: 41 additions & 16 deletions src/main/java/com/team766/robot/reva/DebugOI.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
* └───┴───┴───┴───┘
*
* 1 + 8/12 = Control Shoulder + Nudge Up/Down
* 2 + 8/12 = Control Climber + Nudge Up/Down
* 4 + 8/12 = Control Shooter + Nudge Up/Down
* 3 = Intake In
* 7 = Intake Out
* 2 + 8/12 = Control Shooter + Nudge Up/Down
* 3 + 8/12 = Control Left Climber + Nudge Up/Down (BYPASSES SOFT LIMITS)
* 4 + 8/12 = Control Right Climber + Nudge Up/Down (BYPASSES SOFT LIMITS)
* 5 = Intake In
* 6 = Intake Out
* 16 = Resets climber relative encoders to 0.
*/
public class DebugOI extends OIFragment {
private final JoystickReader macropad;
Expand All @@ -40,7 +42,8 @@ public class DebugOI extends OIFragment {
private final Intake intake;
private final Shooter shooter;
private final OICondition controlShoulder;
private final OICondition controlClimber;
private final OICondition controlLeftClimber;
private final OICondition controlRightClimber;
private final OICondition controlShooter;
private final OICondition intakeIn;
private final OICondition intakeOut;
Expand All @@ -59,8 +62,11 @@ public DebugOI(

controlShoulder =
new OICondition(() -> macropad.getButton(InputConstants.CONTROL_SHOULDER));
controlClimber = new OICondition(() -> macropad.getButton(InputConstants.CONTROL_CLIMBER));
controlShooter = new OICondition(() -> macropad.getButton(InputConstants.CONTROL_SHOOTER));
controlLeftClimber =
new OICondition(() -> macropad.getButton(InputConstants.CONTROL_LEFT_CLIMBER));
controlRightClimber =
new OICondition(() -> macropad.getButton(InputConstants.CONTROL_RIGHT_CLIMBER));
intakeIn = new OICondition(() -> macropad.getButton(InputConstants.INTAKE_IN));
intakeOut = new OICondition(() -> macropad.getButton(InputConstants.INTAKE_OUT));
}
Expand All @@ -79,37 +85,56 @@ protected void handleOI(Context context) {
shoulder.nudgeUp();
} else if (macropad.getButtonPressed(InputConstants.NUDGE_DOWN)) {
shoulder.nudgeDown();
} else if (macropad.getButtonPressed(InputConstants.MACROPAD_RESET_SHOULDER)) {
shoulder.reset();
}
} else if (controlShoulder.isFinishedTriggering()) {
context.releaseOwnership(shoulder);
}

// fine-grained control of the climber
// used for testing and tuning
// press down the climber control button and nudge the climber up and down
if (controlClimber.isTriggering()) {
if (controlClimber.isNewlyTriggering()) {
// press down the climber control buttons and nudge the climber up and down
// NOTE: this bypasses the soft limits - use with care
if (controlLeftClimber.isTriggering()) {
if (controlLeftClimber.isNewlyTriggering()) {
context.takeOwnership(climber);
climber.enableSoftLimits(false);
}

if (macropad.getButtonPressed(InputConstants.NUDGE_UP)) {
climber.setLeftPower(0.25);
climber.setRightPower(0.25);
} else if (macropad.getButtonPressed(InputConstants.NUDGE_DOWN)) {
climber.setLeftPower(-0.25);
climber.setRightPower(-0.25);
} else if (macropad.getButtonReleased(InputConstants.NUDGE_UP)
|| macropad.getButtonReleased(InputConstants.NUDGE_DOWN)) {
climber.stopLeft();
}
} else if (controlLeftClimber.isFinishedTriggering()) {
climber.stopLeft();
climber.enableSoftLimits(true);
context.releaseOwnership(climber);
}

if (controlRightClimber.isTriggering()) {
if (controlRightClimber.isNewlyTriggering()) {
context.takeOwnership(climber);
climber.enableSoftLimits(false);
}

} else if (controlClimber.isFinishedTriggering()) {
climber.stop();
if (macropad.getButtonPressed(InputConstants.NUDGE_UP)) {
climber.setRightPower(0.25);
} else if (macropad.getButtonPressed(InputConstants.NUDGE_DOWN)) {
climber.setRightPower(-0.25);
} else if (macropad.getButtonReleased(InputConstants.NUDGE_UP)
|| macropad.getButtonReleased(InputConstants.NUDGE_DOWN)) {
climber.stopRight();
}
} else if (controlRightClimber.isFinishedTriggering()) {
climber.stopRight();
climber.enableSoftLimits(true);
context.releaseOwnership(climber);
}

if (macropad.getButtonPressed(16)) {
if (macropad.getButtonPressed(InputConstants.RESET_CLIMBER_ENCODERS)) {
climber.resetLeftPosition();
climber.resetRightPosition();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ public final class InputConstants {

// Macropad buttons
public static final int CONTROL_SHOULDER = 1;
public static final int CONTROL_CLIMBER = 2;
public static final int INTAKE_IN = 3;
public static final int CONTROL_SHOOTER = 4;
public static final int INTAKE_OUT = 7;
public static final int CONTROL_SHOOTER = 2;
public static final int CONTROL_LEFT_CLIMBER = 3;
public static final int CONTROL_RIGHT_CLIMBER = 4;
public static final int INTAKE_IN = 5;
public static final int INTAKE_OUT = 6;
public static final int NUDGE_UP = 8;
public static final int MACROPAD_RESET_SHOULDER = 9;
public static final int NUDGE_DOWN = 12;
public static final int MACROPAD_PRESET_1 = 13;
public static final int MACROPAD_PRESET_2 = 14;
public static final int MACROPAD_PRESET_3 = 15;
public static final int MACROPAD_PRESET_4 = 16;
public static final int RESET_CLIMBER_ENCODERS = 16;

// Xbox buttons
// TODO: change
Expand Down
Loading