Skip to content

Commit

Permalink
Intake - Manual/Auto fixes (CurtinFRC#114)
Browse files Browse the repository at this point in the history
* First version Tank Drive

* Intake draft

* Intake draft fixed errors 1

* Intake draft fixed errors 2

* Intake draft fixed errors 3

* Intake draft fixed errors 4

* Intake draft fixed errors 5

* Network files 1

* Network files 2

* Network files 3

* Almost done i think

* finished wpiformat errors

* finished wpiformat errors 2

* finished wpiformat errors 3

* finished wpiformat errors 4

* ran wpiformat

* finished wpiformat errors 5

* finished wpiformat errors 8

* finished wpiformat errors 9

* finished wpiformat errors 10

* Tested on robot

* Fixed github build errors after modifying during robot tests

* fixed more github build errors 2

* fixed more github build errors 3

* Tested on robot and works

* added beam break

* [docs] Update README.md (CurtinFRC#107)

* [docs] Update README.md

* Update README.md

* Added auto to intake

* [ci] add comment command action (CurtinFRC#111)

* [ci] add comment command action

* fix

* Tested on robot

* fixed intake manual auto, has not been tested on robot

* fixed github build errors

* Added intake better manual and verfied on robot!

* Bump actions/setup-python from 4 to 5 (CurtinFRC#116)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/github-script from 6 to 7 (CurtinFRC#115)

Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](actions/github-script@v6...v7)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fixed readme (CurtinFRC#118)

* ran wpiformat

* fix

* fix line endings

* builds

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Kingsley Wong <kingsley.wong@student.education.wa.edu.au>
Co-authored-by: Isaac Turner <spacey_sooty@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Paul Hodges <111325206+Superbro525Alt@users.noreply.github.com>
  • Loading branch information
5 people committed Feb 12, 2024
1 parent 7a95046 commit d5872bf
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 3 deletions.
24 changes: 23 additions & 1 deletion src/main/cpp/Intake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,33 @@ void Intake::OnUpdate(units::second_t dt) {
_setVoltage = 7_V;
if (_config.intakeSensor->Get() == true) {
setState(IntakeState::kIdle);
<<<<<<< HEAD
=======
_ejecting = false;
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
}
} break;

case IntakeState::kHold: {
_stringStateName = "Hold";
_setVoltage = 0_V;
<<<<<<< HEAD
=======
// if (_config.intakeSensor->Get() == false) {
// setState(IntakeState::kHold);
// }
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
} break;

case IntakeState::kIntake: {
_stringStateName = "Intake";
_setVoltage = -7_V;
if (_config.intakeSensor->Get() == false) {
setState(IntakeState::kHold);
<<<<<<< HEAD
=======
_intaking = false;
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
}
} break;

Expand All @@ -51,6 +65,10 @@ void Intake::OnUpdate(units::second_t dt) {
_setVoltage = -7_V;
if (_config.intakeSensor->Get() == true) {
setState(IntakeState::kIdle);
<<<<<<< HEAD
=======
_passing = false;
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
}
} break;
default:
Expand Down Expand Up @@ -78,4 +96,8 @@ void Intake::setRaw(units::volt_t voltage) {
}
IntakeState Intake::getState() {
return _state;
}
<<<<<<< HEAD
}
=======
}
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
76 changes: 75 additions & 1 deletion src/main/cpp/IntakeBehaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,45 @@ IntakeManualControl::IntakeManualControl(Intake* intake, frc::XboxController& co

void IntakeManualControl::OnTick(units::second_t dt) {
if (_codriver.GetBButtonReleased()) {
<<<<<<< HEAD
if (_intake->getState() == IntakeState::kRaw) {
_intake->setState(IntakeState::kIdle);
} else {
=======
if (_rawControl) {
_rawControl = false;
_intaking = false;
_ejecting = false;
_intake->setState(IntakeState::kIdle);
} else {
_rawControl = true;
_intaking = false;
_ejecting = false;
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
_intake->setState(IntakeState::kRaw);
}
}

<<<<<<< HEAD
if (_intake->getState() == IntakeState::kRaw) {
if (_codriver.GetRightBumper()) {
_intake->setRaw(8_V);
} else if (_codriver.GetLeftBumper()) {
_intake->setRaw(-8_V);
=======
if (_rawControl) {
if (_codriver.GetRightTriggerAxis() > 0.1) {
_intake->setRaw(_codriver.GetRightTriggerAxis() * 10_V);
} else if (_codriver.GetLeftTriggerAxis() > 0.1) {
_intake->setRaw(_codriver.GetLeftTriggerAxis() * -10_V);
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
} else {
_intake->setRaw(0_V);
}
_intake->setState(IntakeState::kRaw);

} else {
<<<<<<< HEAD
if (_codriver.GetRightBumperPressed()) {
if (_intake->getState() == IntakeState::kIntake) {
_intake->setState(IntakeState::kIdle);
Expand All @@ -43,21 +65,73 @@ void IntakeManualControl::OnTick(units::second_t dt) {
_intake->setState(IntakeState::kIdle);
} else {
_intake->setState(IntakeState::kEject);
=======
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;
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
}
}

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

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

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);
}
}
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
}
}

IntakeAutoControl::IntakeAutoControl(Intake* intake) : _intake(intake) {
Controls(intake);
}

void IntakeAutoControl::OnTick(units::second_t dt) {}
<<<<<<< HEAD
void IntakeAutoControl::OnTick(units::second_t dt) {}
=======
void IntakeAutoControl::OnTick(units::second_t dt) {}
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
16 changes: 16 additions & 0 deletions src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ void Robot::RobotInit() {

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

<<<<<<< HEAD
<<<<<<< HEAD
=======
// _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); });
>>>>>>> 0029f49 (fix some formatting)
=======
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
_swerveDrive = new wom::SwerveDrive(robotmap.swerveBase.config, frc::Pose2d());
wom::BehaviourScheduler::GetInstance()->Register(_swerveDrive);
_swerveDrive->SetDefaultBehaviour(
Expand Down Expand Up @@ -153,6 +156,7 @@ void Robot::RobotPeriodic() {
wom::BehaviourScheduler::GetInstance()->Tick();
sched->Tick();

<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
robotmap.swerveTable.swerveDriveTable->GetEntry("Encoder 0 offset: ")
Expand All @@ -169,6 +173,9 @@ void Robot::RobotPeriodic() {
->GetEntry("frontLeftEncoder")

>>>>>>> 57d11c0 (Shooter pid (#117))
=======
robotmap.swerveTable.swerveDriveTable->GetEntry("frontLeftEncoder")
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
.SetDouble(robotmap.swerveBase.moduleConfigs[0].turnMotor.encoder->GetEncoderPosition().value());
robotmap.swerveTable.swerveDriveTable->GetEntry("frontRightEncoder")
.SetDouble(robotmap.swerveBase.moduleConfigs[1].turnMotor.encoder->GetEncoderPosition().value());
Expand All @@ -182,6 +189,12 @@ void Robot::RobotPeriodic() {
// intake->OnUpdate(dt);
// alphaArm->OnUpdate(dt);
_swerveDrive->OnUpdate(dt);
<<<<<<< HEAD
=======
alphaArm->OnUpdate(dt);
shooter->OnStart();
intake->OnUpdate(dt);
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
}

void Robot::AutonomousInit() {
Expand All @@ -202,6 +215,7 @@ void Robot::TeleopInit() {
loop.Clear();
wom::BehaviourScheduler* sched = wom::BehaviourScheduler::GetInstance();
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
// shooter->OnStart();
// alphaArm->OnStart();
Expand All @@ -210,6 +224,8 @@ void Robot::TeleopInit() {
=======
shooter->OnStart();
>>>>>>> 57d11c0 (Shooter pid (#117))
=======
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
sched->InterruptAll();

// frontLeft->SetVoltage(4_V);
Expand Down
6 changes: 6 additions & 0 deletions src/main/include/Intake.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class Intake : public behaviour::HasBehaviour {
units::volt_t _rawVoltage = 0_V;
std::string _stringStateName = "error";
units::volt_t _setVoltage = 0_V;
<<<<<<< HEAD
=======
bool _intaking;
bool _ejecting;
bool _passing;
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))

std::shared_ptr<nt::NetworkTable> _table = nt::NetworkTableInstance::GetDefault().GetTable("Intake");
};
7 changes: 7 additions & 0 deletions src/main/include/IntakeBehaviour.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ class IntakeManualControl : public behaviour::Behaviour {

units::volt_t _rawVoltage;
units::volt_t _setVoltage;
<<<<<<< HEAD
=======
bool _rawControl = true;
bool _intaking = false;
bool _ejecting = false;
bool _passing = false;
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
};

class IntakeAutoControl : public behaviour::Behaviour {
Expand Down
20 changes: 19 additions & 1 deletion src/main/include/RobotMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ struct RobotMap {
struct Controllers {
frc::XboxController driver = frc::XboxController(0);
frc::XboxController codriver = frc::XboxController(1);
frc::XboxController testController = frc::XboxController(2);
};
Controllers controllers;

<<<<<<< HEAD
<<<<<<< HEAD
// struct AlphaArmSystem {
// rev::CANSparkMax alphaArmMotor{12, rev::CANSparkMax::MotorType::kBrushless};
Expand All @@ -52,6 +52,21 @@ struct RobotMap {
=======
AlphaArmConfig config{alphaArmGearbox, wristGearbox};
=======
=======
struct IntakeSystem {
rev::CANSparkMax intakeMotor{2, rev::CANSparkMax::MotorType::kBrushed};
// wom::CANSparkMaxEncoder intakeEncoder{&intakeMotor, 0.1_m};
frc::DigitalInput intakeSensor{4};
// frc::DigitalInput magSensor{0};
// frc::DigitalInput shooterSensor{0};

wom::Gearbox IntakeGearbox{&intakeMotor, nullptr, frc::DCMotor::CIM(1)};

IntakeConfig config{IntakeGearbox, &intakeSensor /*, &magSensor, &shooterSensor*/};
};
IntakeSystem intakeSystem;

>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
struct Shooter {
rev::CANSparkMax shooterMotor{11, rev::CANSparkMax::MotorType::kBrushless}; // Port 11
// frc::DigitalInput shooterSensor{2};
Expand All @@ -74,6 +89,7 @@ struct RobotMap {
};
Shooter shooterSystem;

<<<<<<< HEAD
struct IntakeSystem {
rev::CANSparkMax intakeMotor{2, rev::CANSparkMax::MotorType::kBrushed};
// wom::CANSparkMaxEncoder intakeEncoder{&intakeMotor, 0.1_m};
Expand Down Expand Up @@ -148,6 +164,8 @@ struct RobotMap {
>>>>>>> 0029f49 (fix some formatting)
=======
>>>>>>> 57d11c0 (Shooter pid (#117))
=======
>>>>>>> c30477a (Intake - Manual/Auto fixes (#114))
struct SwerveBase {
ctre::phoenix6::hardware::CANcoder frontLeftCancoder{16, "Drivebase"};
ctre::phoenix6::hardware::CANcoder frontRightCancoder{18, "Drivebase"};
Expand Down

0 comments on commit d5872bf

Please sign in to comment.