Skip to content

Commit

Permalink
Added switch case for the variables in behaviour.cpp, and fixwed buil…
Browse files Browse the repository at this point in the history
…d errors. Has not been tested on robot.
  • Loading branch information
prawny-boy committed Feb 24, 2024
1 parent 7992cc3 commit 304e709
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/cpp/Intake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void Intake::OnUpdate(units::second_t dt) {
void Intake::SetState(IntakeState state) {
_state = state;
}
void Intake::SetBehaviourState(IntakeState behaviourState) {
void Intake::SetBehaviourState(IntakeBehaviourState behaviourState) {
_behaviourState = behaviourState;
}
void Intake::SetRaw(units::volt_t voltage) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/cpp/IntakeBehaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ void IntakeManualControl::OnTick(units::second_t dt) {

if (_codriver.GetBButtonReleased()) {
if (_rawControl) {
_intake->SetState(IntakeBehaviourState::kIdleing);
_intake->SetBehaviourState(IntakeBehaviourState::kIdleing);
_intake->SetState(IntakeState::kIdle);
} else {
_intake->SetState(IntakeBehaviourState::kRawControl);
_intake->SetBehaviourState(IntakeBehaviourState::kRawControl);
_intake->SetState(IntakeState::kRaw);
}
}

if (_intake->GetState() == IntakeBehaviourState::kRawControl) {
if (_intake->GetBehaviourState() == IntakeBehaviourState::kRawControl) {
if (_codriver.GetLeftTriggerAxis() > 0.1) {
_intake->SetRaw(_codriver.GetRightTriggerAxis() * 10_V);
} else if (_codriver.GetRightTriggerAxis() > 0.1) {
Expand All @@ -34,20 +34,20 @@ void IntakeManualControl::OnTick(units::second_t dt) {

} else {
if (_codriver.GetRightTriggerAxis() > 0.1) {
if (_intake->GetState() == IntakeBehaviourState::kIntaking) {
if (_intake->GetBehaviourState() == IntakeBehaviourState::kIntaking) {
_intake->SetBehaviourState(IntakeBehaviourState::kIdleing);
_intake->SetState(IntakeState::kIdle);
} else {
_intake->SetBehaviourState(IntakeBehaviourState::kIntaking)
_intake->SetBehaviourState(IntakeBehaviourState::kIntaking);
}
}

if (_codriver.GetLeftTriggerAxis() > 0.1) {
if (_intake->GetState() == IntakeBehaviourState::kEjecting) {
if (_intake->GetBehaviourState() == IntakeBehaviourState::kEjecting) {
_intake->SetBehaviourState(IntakeBehaviourState::kIdleing);
_intake->SetState(IntakeState::kIdle);
} else {
_intake->SetBehaviourState(IntakeBehaviourState::kEjecting)
_intake->SetBehaviourState(IntakeBehaviourState::kEjecting);
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/main/include/IntakeBehaviour.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@
#include "Intake.h"
#include "Wombat.h"

enum class IntakeBehaviourState { kIntaking, kPassing, kEjecting, kIdleing};

class IntakeManualControl : public behaviour::Behaviour {
public:
explicit IntakeManualControl(Intake* intake, frc::XboxController& codriver);

void SetBehaviourState(IntakeBehaviourState behaviourState);
void OnTick(units::second_t dt) override;
IntakeBehaviourState GetBehaviourState();

private:
Intake* _intake;
frc::XboxController& _codriver;

IntakeBehaviourState _behaviourState = IntakeBehaviourState::kIdleing;

units::volt_t _rawVoltage;
units::volt_t _setVoltage;
bool _rawControl = true;
Expand Down

0 comments on commit 304e709

Please sign in to comment.