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

Reef Positions and new states for Reef and SpitGamePiece different #82

Merged
merged 2 commits into from
Mar 8, 2025
Merged
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
8 changes: 4 additions & 4 deletions src/main/Commands/AlignToPose/AlignPositions.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include "Commands/UtilityFunctions/UtilityFunctions.h"
#include "Commands/AlignToPose/AlignToPose.h"

constexpr static const frc::Pose2d aLeft = { {3.900_m, 2.913_m}, {60_deg}};
constexpr static const frc::Pose2d aLeft = { {3.978_m, 2.884_m}, {60_deg}};
constexpr static const frc::Pose2d aCenter = { {4.056_m, 2.679_m}, {60_deg}};
constexpr static const frc::Pose2d aRight = { {4.202_m, 2.757_m}, {60_deg}};
constexpr static const frc::Pose2d aRight = { {4.241_m, 2.718_m}, {60_deg}};

constexpr static const frc::Pose2d bLeft = { {3.237_m, 3.986_m}, {0.0_deg}};
constexpr static const frc::Pose2d bLeft = { {3.260_m, 3.905_m}, {0.0_deg}};
constexpr static const frc::Pose2d bCenter = { {3.130_m, 3.723_m}, {0.0_deg}};
constexpr static const frc::Pose2d bRight = { {3.237_m, 3.655_m}, {0.0_deg}};
constexpr static const frc::Pose2d bRight = { {3.260_m, 3.555_m}, {0.0_deg}};

constexpr static const frc::Pose2d cLeft = { {3.822_m, 5.078_m}, {-60_deg}};
constexpr static const frc::Pose2d cCenter = { {3.549_m, 5.088_m}, {-60_deg}};
Expand Down
116 changes: 53 additions & 63 deletions src/main/Commands/ClosedCommand/ClosedCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,77 +10,67 @@ frc2::CommandPtr ClosedCommand(Arm *arm, Elevator *elevator, Intake *intake, Sup
> ([superStructure] {
return superStructure->getState();
},
std::pair {SuperStructureStates::EnterCoralStation, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
std::pair {SuperStructureStates::EnterCoralStation, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::EnterCoralGround, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::EnterCoralGround, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::EnterAlgaeGround, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::EnterAlgaeGround, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::EnterLowAlgae, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::AlgaeHold),
superStructure->setState(SuperStructureStates::HoldAlgae)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::EnterLowAlgae, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::AlgaeHold),
superStructure->setState(SuperStructureStates::HoldAlgae),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::EnterHighAlgae, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::AlgaeHold),
superStructure->setState(SuperStructureStates::HoldCoral)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::EnterHighAlgae, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::AlgaeHold),
superStructure->setState(SuperStructureStates::HoldCoral),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::SpitCoral, frc2::cmd::Sequence(
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral)),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::SpitCoral, frc2::cmd::Parallel(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(), intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::SpitAlgae, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::SpitAlgae, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::HoldCoral, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::HoldCoral, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}, std::pair {SuperStructureStates::HoldAlgae, frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::AlgaeHold),
superStructure->setState(SuperStructureStates::HoldAlgae)),
frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition)))
}, std::pair {SuperStructureStates::HoldAlgae, frc2::cmd::Parallel(
intake->moveIntake(IntakeConstants::AlgaeHold),
superStructure->setState(SuperStructureStates::HoldAlgae),
ArmMotion(elevator, arm, ArmConstants::ArmClosed, ArmConstants::WristClosed,
ElevatorConstants::ClosedPosition).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

}

Expand Down
7 changes: 4 additions & 3 deletions src/main/Commands/ReefCommands/ReefCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ frc2::CommandPtr L1Command(Arm *arm, Elevator *elevator, SuperStructure *superSt
return superStructure->getState();
},
std::pair {SuperStructureStates::HoldCoral, frc2::cmd::Sequence(
superStructure->setScoringState(SuperStructureScoringStates::L1),
frc2::cmd::Sequence(elevator->setElevatorCommand(ElevatorConstants::L1Position),
ArmMotion(elevator, arm, ArmConstants::ArmL1Reef, ArmConstants::WristClosed,
ElevatorConstants::L1Position).ToPtr(),
Expand All @@ -29,7 +30,7 @@ frc2::CommandPtr L2Command(Arm *arm, Elevator *elevator, SuperStructure *superSt
return superStructure->getState();
},
std::pair {SuperStructureStates::HoldCoral, frc2::cmd::Sequence(

superStructure->setScoringState(SuperStructureScoringStates::L2),
frc2::cmd::Sequence(elevator->setElevatorCommand(ElevatorConstants::L2Position),
ArmMotion(elevator, arm, ArmConstants::ArmL2Reef, ArmConstants::WristL2Reef,
ElevatorConstants::L2Position).ToPtr()))}
Expand All @@ -44,7 +45,7 @@ frc2::CommandPtr L3Command(Arm *arm, Elevator *elevator, SuperStructure *superSt
return superStructure->getState();
},
std::pair {SuperStructureStates::HoldCoral, frc2::cmd::Sequence(

superStructure->setScoringState(SuperStructureScoringStates::L3),
frc2::cmd::Sequence(elevator->setElevatorCommand(ElevatorConstants::L3Position),
ArmMotion(elevator, arm, ArmConstants::ArmL3Reef, ArmConstants::WristL3Reef,
ElevatorConstants::L3Position).ToPtr()))}
Expand All @@ -59,7 +60,7 @@ frc2::CommandPtr L4Command(Arm *arm, Elevator *elevator, SuperStructure *superSt
return superStructure->getState();
},
std::pair {SuperStructureStates::HoldCoral, frc2::cmd::Sequence(

superStructure->setScoringState(SuperStructureScoringStates::L4),
frc2::cmd::Sequence(elevator->setElevatorCommand(ElevatorConstants::L4Position),
ArmMotion(elevator, arm, ArmConstants::ArmL4Reef, ArmConstants::WristL4Reef,
ElevatorConstants::L4Position).ToPtr()))}
Expand Down
14 changes: 11 additions & 3 deletions src/main/Commands/SourceCommand/SourceCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#include "SourceCommand.h"
#include "Commands/ArmMotion/ArmMotion.h"

frc2::CommandPtr SourceCommand(Arm *arm, Elevator *elevator, Intake *intake, SuperStructure *superStructure) {
int nextButton = frc::XboxController::Button::kRightBumper;

frc2::CommandPtr SourceCommand(Arm *arm, Elevator *elevator, Intake *intake, SuperStructure *superStructure,
OverXboxController *gamepad) {
return frc2::cmd::Select < SuperStructureStates
> ([superStructure] {
return superStructure->getState();
Expand Down Expand Up @@ -36,8 +39,13 @@ frc2::CommandPtr SourceCommand(Arm *arm, Elevator *elevator, Intake *intake, Sup
})}

).AndThen(
frc2::cmd::Sequence(intake->moveIntake(IntakeConstants::StopIntake),
frc2::cmd::Parallel(superStructure->setState(SuperStructureStates::HoldCoral),
frc2::cmd::Sequence(
frc2::cmd::Parallel(intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::HoldCoral)),
WaitForButton(gamepad, nextButton),
frc2::cmd::Sequence(
arm->setArmCommand(ArmConstants::ArmCoralStationAway, ArmConstants::WristClosed),
frc2::cmd::Wait(0.5_s),
arm->setArmCommand(ArmConstants::ArmClosed, ArmConstants::WristClosed),
elevator->setElevatorCommand(ElevatorConstants::ClosedPosition))

Expand Down
4 changes: 3 additions & 1 deletion src/main/Commands/SourceCommand/SourceCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
#include "Subsystems/Intake/Intake.h"
#include <frc2/command/Commands.h>
#include "Subsystems/SuperStructure/SuperStructure.h"
#include "OvertureLib/Utils/WaitForButton/WaitForButton.h"

frc2::CommandPtr SourceCommand(Arm *arm, Elevator *elevator, Intake *intake, SuperStructure *superStructure);
frc2::CommandPtr SourceCommand(Arm *arm, Elevator *elevator, Intake *intake, SuperStructure *superStructure,
OverXboxController *gamepad);
48 changes: 23 additions & 25 deletions src/main/Commands/SpitGamePiece/SpitGamePiece.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,31 @@
#include "SpitGamePiece.h"

frc2::CommandPtr SpitGamePiece(Intake *intake, SuperStructure *superStructure, Elevator *elevator, Arm *arm) {
return frc2::cmd::Select < SuperStructureStates
return frc2::cmd::Select < SuperStructureScoringStates
> ([superStructure] {
return superStructure->getState();
return superStructure->getScoringState();
},
std::pair {SuperStructureStates::HoldCoral,
frc2::cmd::Sequence(
std::pair {SuperStructureScoringStates::L1, frc2::cmd::Sequence(
superStructure->setState(SuperStructureStates::SpitCoral),
intake->moveIntake(IntakeConstants::CoralSpit),
superStructure->setScoringState(SuperStructureScoringStates::DontScore))}, std::pair {
SuperStructureScoringStates::L2, frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmScore, ArmConstants::WristClosed,
elevator->getPosition()).ToPtr(), intake->moveIntake(IntakeConstants::StopIntake),
superStructure->setState(SuperStructureStates::SpitCoral))}, std::pair {
SuperStructureStates::HoldAlgae,
frc2::cmd::Sequence(
frc2::cmd::Parallel(
ArmMotion(elevator, arm, 30_deg, ArmConstants::WristClosed, elevator->getPosition()).ToPtr().BeforeStarting(
[arm] {
arm->changeArmSpeeds(ArmConstants::SlowVelocity,
ArmConstants::SlowAccelerationa);
}
).FinallyDo(
[arm] {
arm->changeArmSpeeds(ArmConstants::ArmCruiseVelocity,
ArmConstants::ArmCruiseAcceleration);
}
),
intake->moveIntake(IntakeConstants::AlgaeHold)), frc2::cmd::Wait(0.2_s),
intake->moveIntake(IntakeConstants::AlgaeRelease),
superStructure->setState(SuperStructureStates::SpitAlgae))}

);
elevator->getPosition()).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::L2SpitPosition),
superStructure->setState(SuperStructureStates::SpitCoral),
superStructure->setScoringState(SuperStructureScoringStates::DontScore))}, std::pair {
SuperStructureScoringStates::L3, frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmScore, ArmConstants::WristClosed,
elevator->getPosition()).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::L3SpitPosition),
superStructure->setState(SuperStructureStates::SpitCoral),
superStructure->setScoringState(SuperStructureScoringStates::DontScore))}, std::pair {
SuperStructureScoringStates::L4, frc2::cmd::Sequence(
ArmMotion(elevator, arm, ArmConstants::ArmScore, ArmConstants::WristClosed,
elevator->getPosition()).ToPtr(),
elevator->setElevatorCommand(ElevatorConstants::L4SpitPosition),
superStructure->setState(SuperStructureStates::SpitCoral),
superStructure->setScoringState(SuperStructureScoringStates::DontScore))});

}
18 changes: 0 additions & 18 deletions src/main/Commands/SpitL1/SpitL1.cpp

This file was deleted.

Loading