Skip to content

Commit

Permalink
pulled from alpha into auto
Browse files Browse the repository at this point in the history
  • Loading branch information
prawny-boy committed Feb 4, 2024
2 parents 880a70e + 0bd9a81 commit fa02ff2
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* text=auto
*.sh text eol=lf
*.bat text eol=crlf
*.gradle text eol=lf
*.java text eol=lf
*.json text eol=lf
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/comment-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Comment Commands
on:
issue_comment:
types: [ created ]

jobs:
format:
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/format')
runs-on: ubuntu-22.04
steps:
- name: React Rocket
uses: actions/github-script@v7
with:
script: |
const {owner, repo} = context.issue
github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: "rocket",
});
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch all history and metadata
run: |
git checkout -b pr
git branch -f master origin/master
- name: Checkout PR
run: |
gh pr checkout $NUMBER
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
NUMBER: ${{ github.event.issue.number }}
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install wpiformat
run: pip3 install wpiformat
- name: Run wpiformat
run: wpiformat
- name: Commit
run: |
# Set credentials
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Commit
git commit -am "Formatting fixes"
git push
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Fork this repository then open up a terminal and run :
```bash
git clone https://github.com/*yourusernamehere*/2024-Crescendo.git
cd 2024-Crescendo
chmod +x init.sh
./init.sh
```
Now look in [CONTRIBUTING.md](./CONTRIBUTING.md) before continuing!

Expand All @@ -24,7 +22,6 @@ Fork this repository then open up a terminal and run :
```powershell
git clone https:\\github.com\*yourusernamehere*\2024-Crescendo.git
cd 2024-Crescendo
.\init
```
Now look in [CONTRIBUTING.md](./CONTRIBUTING.md) before continuing!

Expand Down Expand Up @@ -53,11 +50,11 @@ Cleaning removes caches of your compiled code. If you do not understand an error
Simulation
----------
**Release**
`./gradlew :nativeSimulation`
`./gradlew :simulateNative`
Runs a simulation of your code at highest optimisation.

**Debug**
`./gradlew :nativeSimulationDebug`
`./gradlew :simulateNativeDebug`
Runs a debug simulation of your code, including a variety of debugging tools similar to glass but at lower optimisation.

Documentation
Expand Down
51 changes: 32 additions & 19 deletions src/main/cpp/Intake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,60 @@ IntakeConfig Intake::GetConfig() {
void Intake::OnUpdate(units::second_t dt) {
switch (_state) {
case IntakeState::kIdle: {
// _config.IntakeMotor.motorController->SetVoltage(0_V);
// if (_config.intakeSensor->Get()) {
// setState(IntakeState::kHold);
// }
if (_config.intakeSensor->Get() == false) {
setState(IntakeState::kHold);
}
_stringStateName = "Idle";
_setVoltage = 0_V;
} break;

case IntakeState::kRaw: {
// _config.IntakeMotor.motorController->SetVoltage(_rawVoltage);
_stringStateName = "Raw";
_setVoltage = _rawVoltage;
} break;

case IntakeState::kEject: {
// _config.IntakeMotor.motorController->SetVoltage(-5_V);
// if (_config.intakeSensor->Get() == 0 && _config.magSensor->Get() == 0) {
// setState(IntakeState::kIdle);
// }
_stringStateName = "Eject";
_setVoltage = -5_V;
_setVoltage = 7_V;
if (_config.intakeSensor->Get() == true) {
setState(IntakeState::kIdle);
_ejecting = false;
}
} break;

case IntakeState::kHold: {
// _config.IntakeMotor.motorController->SetVoltage(0_V);
_stringStateName = "Hold";
_setVoltage = 0_V;
// if (_config.intakeSensor->Get() == false) {
// setState(IntakeState::kHold);
// }
} break;

case IntakeState::kIntake: {
// _config.IntakeMotor.motorController->SetVoltage(5_V);
_stringStateName = "Intake";
_setVoltage = 5_V;
_setVoltage = -7_V;
if (_config.intakeSensor->Get() == false) {
setState(IntakeState::kHold);
_intaking = false;
}
} break;

case IntakeState::kPass: {
// _config.IntakeMotor.motorController->SetVoltage(5_V);
// if (_config.shooterSensor->Get()) {
// setState(IntakeState::kIdle);
// _stringStateName = "Pass";
// }
_setVoltage = 5_V;
_stringStateName = "Pass";
_setVoltage = -7_V;
if (_config.intakeSensor->Get() == true) {
setState(IntakeState::kIdle);
_passing = false;
}
} break;
default:
std::cout << "Error: Intake in INVALID STATE." << std::endl;
break;
}
_table->GetEntry("State: ").SetString(_stringStateName);
_table->GetEntry("Motor Voltage: ").SetDouble(_setVoltage.value());
_table->GetEntry("Intake Sensor: ").SetBoolean(_config.intakeSensor->Get());
// _table->GetEntry("Shooter Sensor: ").SetBoolean(_config.shooterSensor->Get());
// _table->GetEntry("Intake Sensor: ").SetBoolean(_config.intakeSensor->Get());
// _table->GetEntry("Shooter Sensor: ").SetBoolean(_config.shooterSensor->Get());
// _table->GetEntry("Magazine Sensor: ").SetBoolean(_config.magSensor->Get());
Expand All @@ -72,3 +82,6 @@ void Intake::setState(IntakeState state) {
void Intake::setRaw(units::volt_t voltage) {
_rawVoltage = voltage;
}
IntakeState Intake::getState() {
return _state;
}
79 changes: 61 additions & 18 deletions src/main/cpp/IntakeBehaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,79 @@ IntakeManualControl::IntakeManualControl(Intake* intake, frc::XboxController& co
}

void IntakeManualControl::OnTick(units::second_t dt) {
if (_codriver.GetBButtonPressed()) {
if (_rawControl == true) {
if (_codriver.GetBButtonReleased()) {
if (_rawControl) {
_rawControl = false;
_intaking = false;
_ejecting = false;
_intake->setState(IntakeState::kIdle);
} else {
_rawControl = true;
_intaking = false;
_ejecting = false;
_intake->setState(IntakeState::kRaw);
}
}

if (_rawControl) {
_intake->setState(IntakeState::kRaw);
if (_codriver.GetLeftBumper()) {
_intake->setRaw(10_V);
} else if (_codriver.GetRightBumper()) {
_intake->setRaw(-10_V);
if (_codriver.GetRightTriggerAxis() > 0.1) {
_intake->setRaw(_codriver.GetRightTriggerAxis() * 10_V);
} else if (_codriver.GetLeftTriggerAxis() > 0.1) {
_intake->setRaw(_codriver.GetLeftTriggerAxis() * -10_V);
} else {
_intake->setRaw(0_V);
}
_intake->setState(IntakeState::kRaw);

} else {
if (_codriver.GetRightTriggerAxis() > 0.1) {
if (_intaking) {
_intaking = false;
_intake->setState(IntakeState::kIdle);
} else {
_intaking = true;
_ejecting = false;
}
}

if (_codriver.GetLeftTriggerAxis() > 0.1) {
if (_ejecting) {
_ejecting = false;
_intake->setState(IntakeState::kIdle);
} else {
_ejecting = true;
_intaking = false;
}
}

if (_codriver.GetAButtonPressed()) {
if (_passing) {
_passing = false;
_intake->setState(IntakeState::kIdle);
} else {
_passing = true;
_intaking = false;
}
}

if (_intaking) {
if (_intake->getState() == IntakeState::kIdle) {
_intake->setState(IntakeState::kIntake);
}
}

// _intake->setRaw(_codriver.GetLeftBumper() * 10_V);
// _intake->setRaw(_codriver.GetRightBumper() * -10_V);
std::cout << "Raw" << std::endl;
if (_passing) {
if (_intake->getState() == IntakeState::kHold) {
_intake->setState(IntakeState::kPass);
}
}

if (_ejecting) {
if (_intake->getState() == IntakeState::kIdle || _intake->getState() == IntakeState::kHold) {
_intake->setState(IntakeState::kEject);
}
}
}
// } else {
// if (_codriver.GetYButtonPressed()) {
// _intake->setState(IntakeState::kIntake);
// }
// if (_codriver.GetAButtonPressed()) {
// _intake->setState(IntakeState::kPass);
// }
// }
}

AutoIntake::AutoIntake(Intake* intake, units::volt_t intakeVolt) : _intake(intake) {
Expand Down
5 changes: 1 addition & 4 deletions src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ void Robot::RobotInit() {

// robotmap.swerveBase.gyro->Reset();

// _swerveDrive = new wom::SwerveDrive(robotmap.swerveBase.config, frc::Pose2d());
// wom::BehaviourScheduler::GetInstance()->Register(_swerveDrive);
// _swerveDrive->SetDefaultBehaviour(
// [this]() { return wom::make<wom::ManualDrivebase>(_swerveDrive, &robotmap.controllers.driver); });
_swerveDrive = new wom::SwerveDrive(robotmap.swerveBase.config, frc::Pose2d());
wom::BehaviourScheduler::GetInstance()->Register(_swerveDrive);
_swerveDrive->SetDefaultBehaviour(
Expand Down Expand Up @@ -110,6 +106,7 @@ void Robot::RobotPeriodic() {

_swerveDrive->OnUpdate(dt);
alphaArm->OnUpdate(dt);
shooter->OnStart();
intake->OnUpdate(dt);

}
Expand Down
Loading

0 comments on commit fa02ff2

Please sign in to comment.