-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from 4201VitruvianBots/dev-climberFixes
Fixed Climber Code
- Loading branch information
Showing
12 changed files
with
144 additions
and
131 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
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
110 changes: 52 additions & 58 deletions
110
src/main/java/frc/robot/commands/climber/ToggleClimbMode.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 |
---|---|---|
@@ -1,58 +1,52 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.climber; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import frc.robot.constants.ROBOT; | ||
import frc.robot.constants.ROBOT.CONTROL_MODE; | ||
import frc.robot.subsystems.Arm; | ||
import frc.robot.subsystems.Climber; | ||
|
||
public class ToggleClimbMode extends InstantCommand { | ||
private final Climber m_climber; | ||
private final Arm m_arm; | ||
|
||
/** Creates a new ToggleClimberControlMode. */ | ||
public ToggleClimbMode(Climber climber, Arm arm) { | ||
m_climber = climber; | ||
m_arm = arm; | ||
|
||
// Use addRequirements() here to declare subsystem dependencies. | ||
addRequirements(m_climber, m_arm); | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
// m_climber.setClimbState(!m_climber.getClimbState()); | ||
// m_arm.setControlMode(CONTROL_MODE.OPEN_LOOP); | ||
ROBOT.CONTROL_MODE climberControlMode = m_climber.getClosedLoopControlMode(); | ||
|
||
switch (climberControlMode) { | ||
case OPEN_LOOP: | ||
m_climber.setClosedLoopControlMode(CONTROL_MODE.CLOSED_LOOP); | ||
m_climber.resetMotionMagicState(); | ||
m_climber.holdClimber(); | ||
break; | ||
default: | ||
case CLOSED_LOOP: | ||
m_climber.setClosedLoopControlMode(CONTROL_MODE.OPEN_LOOP); | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public void execute() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return true; | ||
} | ||
} | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.climber; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import frc.robot.constants.ROBOT.CONTROL_MODE; | ||
import frc.robot.subsystems.Arm; | ||
import frc.robot.subsystems.Climber; | ||
|
||
public class ToggleClimbMode extends InstantCommand { | ||
private final Climber m_climber; | ||
private final Arm m_arm; | ||
|
||
/** Creates a new ToggleClimberControlMode. */ | ||
public ToggleClimbMode(Climber climber, Arm arm) { | ||
m_climber = climber; | ||
m_arm = arm; | ||
|
||
// Use addRequirements() here to declare subsystem dependencies. | ||
addRequirements(m_climber, m_arm); | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
// m_climber.setClimbState(!m_climber.getClimbState()); | ||
// m_arm.setControlMode(CONTROL_MODE.OPEN_LOOP); | ||
var climbMode = m_climber.getClimbState(); | ||
|
||
if (!climbMode) { | ||
m_climber.setClimbState(true); | ||
// m_climber.setClosedLoopControlMode(CONTROL_MODE.CLOSED_LOOP); | ||
// m_climber.resetMotionMagicState(); | ||
// m_climber.holdClimber(); | ||
m_arm.setControlMode(CONTROL_MODE.CLOSED_LOOP); | ||
m_arm.resetMotionMagicState(); | ||
} else { | ||
m_climber.setClimbState(false); | ||
// m_climber.setClosedLoopControlMode(CONTROL_MODE.OPEN_LOOP); | ||
m_arm.setControlMode(CONTROL_MODE.OPEN_LOOP); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
} |
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.