Skip to content

Commit

Permalink
[wombat] standardise setters (#49)
Browse files Browse the repository at this point in the history
* Standerdised setters

* run wpiformat

---------

Co-authored-by: Paul Hodges <paul.hodges@student.education.wa.edu.au>
  • Loading branch information
spacey-sooty and Superbro525Alt authored Jan 1, 2024
1 parent a3a0ef4 commit 8831fab
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
15 changes: 6 additions & 9 deletions wombat/src/main/cpp/subsystems/Arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,20 @@ void wom::subsystems::Arm::SetArmSpeedLimit(double limit) {
// defines information needed for the functions and connects the states to their
// respective function

void wom::subsystems::Arm::SetIdle() {
_state = ArmState::kIdle;
}

void wom::subsystems::Arm::SetRaw(units::volt_t voltage) {
_state = ArmState::kRaw;
_voltage = voltage;
}

void wom::subsystems::Arm::SetVelocity(units::radians_per_second_t velocity) {
_velocityPID.SetSetpoint(velocity);
}

void wom::subsystems::Arm::SetAngle(units::radian_t angle) {
_state = ArmState::kAngle;
_pid.SetSetpoint(angle);
}

void wom::subsystems::Arm::SetVelocity(units::radians_per_second_t velocity) {
_state = ArmState::kVelocity;
_velocityPID.SetSetpoint(velocity);
void wom::subsystems::Arm::SetState(wom::subsystems::ArmState state) {
_state = state;
}

wom::subsystems::ArmConfig& wom::subsystems::Arm::GetConfig() {
Expand Down
15 changes: 6 additions & 9 deletions wombat/src/main/cpp/subsystems/Elevator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,24 @@ void wom::subsystems::Elevator::OnUpdate(units::second_t dt) {
}

void wom::subsystems::Elevator::SetManual(units::volt_t voltage) {
_state = ElevatorState::kManual;
_setpointManual = voltage;
}

void wom::subsystems::Elevator::SetPID(units::meter_t height) {
_state = ElevatorState::kPID;
_pid.SetSetpoint(height);
}

void wom::subsystems::Elevator::SetElevatorSpeedLimit(double limit) {
speedLimit = limit;
}

void wom::subsystems::Elevator::SetVelocity(
units::meters_per_second_t velocity) {
_velocityPID.SetSetpoint(velocity);
_state = ElevatorState::kVelocity;
}

void wom::subsystems::Elevator::SetIdle() {
_state = ElevatorState::kIdle;
void wom::subsystems::Elevator::SetState(wom::subsystems::ElevatorState state) {
_state = state;
}

void wom::subsystems::Elevator::SetElevatorSpeedLimit(double limit) {
speedLimit = limit;
}

wom::subsystems::ElevatorConfig& wom::subsystems::Elevator::GetConfig() {
Expand Down
5 changes: 2 additions & 3 deletions wombat/src/main/cpp/subsystems/Shooter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void wom::subsystems::Shooter::OnUpdate(units::second_t dt) {
}

void wom::subsystems::Shooter::SetManual(units::volt_t voltage) {
_state = ShooterState::kManual;
_setpointManual = voltage;
}

Expand All @@ -58,8 +57,8 @@ void wom::subsystems::Shooter::SetPID(units::radians_per_second_t goal) {
_pid.SetSetpoint(goal);
}

void wom::subsystems::Shooter::SetIdle() {
_state = ShooterState::kIdle;
void wom::subsystems::Shooter::SetState(ShooterState state) {
_state = state;
}

bool wom::subsystems::Shooter::IsStable() const {
Expand Down
2 changes: 2 additions & 0 deletions wombat/src/main/include/subsystems/Arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Arm : public behaviour::HasBehaviour {
void SetRaw(units::volt_t voltage);
void SetVelocity(units::radians_per_second_t velocity);

void SetState(wom::subsystems::ArmState state);

void SetArmSpeedLimit(double limit); // units, what are they??

ArmConfig& GetConfig();
Expand Down
4 changes: 2 additions & 2 deletions wombat/src/main/include/subsystems/Elevator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class Elevator : public behaviour::HasBehaviour {

void SetManual(units::volt_t voltage);
void SetPID(units::meter_t height);
void SetIdle();
void SetRaw();

void SetState(ElevatorState state);

void SetVelocity(units::meters_per_second_t velocity);

Expand Down
2 changes: 1 addition & 1 deletion wombat/src/main/include/subsystems/Shooter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Shooter : public behaviour::HasBehaviour {

void SetManual(units::volt_t voltage);
void SetPID(units::radians_per_second_t goal);
void SetIdle();
void SetState(ShooterState state);

void OnUpdate(units::second_t dt);

Expand Down

0 comments on commit 8831fab

Please sign in to comment.