Skip to content

Commit bdcb9fd

Browse files
committed
Fixed more build errors
2 parents d91b5e0 + ac6ce9b commit bdcb9fd

File tree

7 files changed

+102
-108
lines changed

7 files changed

+102
-108
lines changed

src/main/cpp/Mag.cpp

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,56 @@
1+
// Copyright (c) 2023-2024 CurtinFRC
2+
// Open Source Software, you can modify it according to the terms
3+
// of the MIT License at the root of this project
4+
15
#include "Mag.h"
26

37
Mag::Mag(MagConfig config) : _config(config) {}
48

59
void Mag::OnUpdate(units::second_t dt) {
610
switch (_state) {
7-
case MagState::kIdle:
8-
{
11+
case MagState::kIdle: {
912
if (_config.intakeSensor->Get()) {
1013
SetState(MagState::kHold);
11-
} else if (_config.intakeSensor->Get()){
14+
} else if (_config.intakeSensor->Get()) {
1215
SetState(MagState::kHold);
1316
}
1417
_setVoltage = 0_V;
1518
_stringStateName = "Idle";
16-
}
17-
break;
19+
} break;
1820

19-
case MagState::kHold:
20-
{
21+
case MagState::kHold: {
2122
if (_config.magSensor->Get() == 0) {
2223
SetState(MagState::kIdle);
2324
}
2425
_setVoltage = 0_V;
2526
_stringStateName = "Hold";
26-
}
27-
break;
27+
} break;
2828

29-
case MagState::kEject:
30-
{
31-
if (_config.magSensor->Get() == 0 && _config.intakeSensor->Get() == 0) {
29+
case MagState::kEject: {
30+
if (_config.magSensor->Get() == 0 && _config.intakeSensor->Get() == 0) {
3231
SetState(MagState::kIdle);
3332
}
3433
_setVoltage = -5_V;
3534
_stringStateName = "Eject";
36-
}
37-
break;
35+
} break;
3836

3937
case MagState::kRaw:
4038
_setVoltage = _rawVoltage;
4139
_stringStateName = "Raw";
42-
break;
40+
break;
4341

44-
case MagState::kPass:
45-
{
42+
case MagState::kPass: {
4643
if (_config.shooterSensor->Get()) {
4744
SetState(MagState::kIdle);
4845
} else {
4946
_setVoltage = 5_V;
5047
_stringStateName = "Pass";
5148
}
52-
}
53-
break;
49+
} break;
5450

5551
default:
5652
std::cout << "Error magazine in invalid state" << std::endl;
57-
break;
53+
break;
5854
}
5955
_config.magGearbox.motorController->SetVoltage(_setVoltage);
6056
_table->GetEntry("State: ").SetString(_stringStateName);
@@ -64,7 +60,6 @@ void Mag::OnUpdate(units::second_t dt) {
6460
_table->GetEntry("Magazine Sensor: ").SetDouble(_config.magSensor->Get());
6561
}
6662

67-
6863
void Mag::SetState(MagState state) {
6964
_state = state;
7065
}
@@ -75,7 +70,3 @@ void Mag::SetRaw(units::volt_t voltage) {
7570
MagState Mag::GetState() {
7671
return _state;
7772
}
78-
79-
80-
81-

src/main/cpp/Robot.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ void Robot::RobotInit() {
2323

2424
mag = new Mag(robotmap.magSystem.config);
2525
wom::BehaviourScheduler::GetInstance()->Register(mag);
26-
mag->SetDefaultBehaviour([this]() {
27-
return wom::make<MagManualControl>(mag, &robotmap.controllers.coDriver);
28-
});
26+
mag->SetDefaultBehaviour(
27+
[this]() { return wom::make<MagManualControl>(mag, &robotmap.controllers.coDriver); });
2928
}
3029

3130
void Robot::RobotPeriodic() {
3231
auto dt = wom::now() - lastPeriodic;
3332
lastPeriodic = wom::now();
34-
33+
3534
loop.Poll();
3635
wom::BehaviourScheduler::GetInstance()->Tick();
3736

@@ -41,7 +40,7 @@ void Robot::RobotPeriodic() {
4140

4241
void Robot::TeleopInit() {
4342
loop.Clear();
44-
wom::BehaviourScheduler *scheduler = wom::BehaviourScheduler::GetInstance();
43+
wom::BehaviourScheduler* scheduler = wom::BehaviourScheduler::GetInstance();
4544
scheduler->InterruptAll();
4645

4746
m_chooser.SetDefaultOption("Default Auto", "Default Auto");
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1+
// Copyright (c) 2023-2024 CurtinFRC
2+
// Open Source Software, you can modify it according to the terms
3+
// of the MIT License at the root of this project
4+
15
#include "behaviours/MagBehaviour.h"
26

3-
MagManualControl::MagManualControl(Mag *mag, frc::XboxController *codriver) : _mag(mag), _codriver(codriver) {
7+
MagManualControl::MagManualControl(Mag* mag, frc::XboxController* codriver) : _mag(mag), _codriver(codriver) {
48
Controls(mag);
59
}
610

711
void MagManualControl::OnTick(units::second_t dt) {
8-
912
if (_codriver->GetAButtonPressed()) {
1013
if (_rawControl == true) {
1114
_rawControl = false;
1215
} else {
1316
_rawControl = true;
1417
}
1518
}
16-
19+
1720
if (_rawControl) {
1821
// Manual control, right bumper for manual override.
1922
if (_codriver->GetLeftBumper()) {
@@ -26,24 +29,23 @@ void MagManualControl::OnTick(units::second_t dt) {
2629
} else {
2730
_mag->SetRaw(0_V);
2831
}
29-
32+
3033
} else {
3134
_mag->SetState(MagState::kIdle);
3235
if (_codriver->GetLeftBumper()) {
3336
_mag->SetState(MagState::kPass);
34-
3537
}
3638
}
3739
}
38-
39-
MagAutoPass::MagAutoPass(Mag *mag) {}
40-
41-
void MagAutoPass::OnTick(units::second_t dt) {
42-
_mag->SetState(MagState::kPass);
43-
}
4440

45-
MagAutoHold::MagAutoHold(Mag *mag) {}
46-
47-
void MagAutoHold::OnTick(units::second_t dt) {
48-
_mag->SetState(MagState::kHold);
49-
}
41+
MagAutoPass::MagAutoPass(Mag* mag) {}
42+
43+
void MagAutoPass::OnTick(units::second_t dt) {
44+
_mag->SetState(MagState::kPass);
45+
}
46+
47+
MagAutoHold::MagAutoHold(Mag* mag) {}
48+
49+
void MagAutoHold::OnTick(units::second_t dt) {
50+
_mag->SetState(MagState::kHold);
51+
}

src/main/include/Mag.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
// Copyright (c) 2023-2024 CurtinFRC
2+
// Open Source Software, you can modify it according to the terms
3+
// of the MIT License at the root of this project
4+
15
#pragma once
2-
#include "Wombat.h"
36
#include <frc/DigitalInput.h>
4-
#include <string>
7+
58
#include <memory>
9+
#include <string>
610

11+
#include "Wombat.h"
712

813
struct MagConfig {
914
wom::Gearbox magGearbox;
@@ -12,27 +17,22 @@ struct MagConfig {
1217
frc::DigitalInput* shooterSensor;
1318
};
1419

15-
enum class MagState {
16-
kIdle,
17-
kHold,
18-
kEject,
19-
kRaw,
20-
kPass
21-
};
20+
enum class MagState { kIdle, kHold, kEject, kRaw, kPass };
2221

2322
class Mag : public behaviour::HasBehaviour {
24-
public:
25-
explicit Mag(MagConfig config);
26-
27-
void OnUpdate(units::second_t dt);
28-
void SetState(MagState state);
29-
void SetRaw(units::volt_t voltage);
30-
MagState GetState();
31-
private:
32-
MagConfig _config;
33-
MagState _state;
34-
units::volt_t _rawVoltage = 0_V;
35-
std::string _stringStateName = "No State";
36-
units::volt_t _setVoltage = 0_V;
37-
std::shared_ptr<nt::NetworkTable> _table = nt::NetworkTableInstance::GetDefault().GetTable("Magazine");
38-
};
23+
public:
24+
explicit Mag(MagConfig config);
25+
26+
void OnUpdate(units::second_t dt);
27+
void SetState(MagState state);
28+
void SetRaw(units::volt_t voltage);
29+
MagState GetState();
30+
31+
private:
32+
MagConfig _config;
33+
MagState _state;
34+
units::volt_t _rawVoltage = 0_V;
35+
std::string _stringStateName = "No State";
36+
units::volt_t _setVoltage = 0_V;
37+
std::shared_ptr<nt::NetworkTable> _table = nt::NetworkTableInstance::GetDefault().GetTable("Magazine");
38+
};

src/main/include/Robot.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
#pragma once
66

7-
#include "behaviours/MagBehaviour.h"
8-
#include <frc/TimedRobot.h>
97
#include <frc/Encoder.h>
8+
#include <frc/TimedRobot.h>
109
#include <frc/Timer.h>
1110
#include <frc/event/EventLoop.h>
1211
#include <frc/simulation/DifferentialDrivetrainSim.h>
@@ -19,6 +18,7 @@
1918

2019
#include "RobotMap.h"
2120
#include "Wombat.h"
21+
#include "behaviours/MagBehaviour.h"
2222

2323
class Robot : public frc::TimedRobot {
2424
public:
@@ -37,7 +37,7 @@ class Robot : public frc::TimedRobot {
3737

3838
private:
3939
behaviour::BehaviourScheduler* sched;
40-
40+
4141
RobotMap robotmap;
4242

4343
frc::EventLoop loop;
@@ -47,5 +47,5 @@ class Robot : public frc::TimedRobot {
4747
frc::SendableChooser<std::string> m_path_chooser;
4848

4949
wom::SwerveDrive* _swerveDrive;
50-
Mag *mag;
50+
Mag* mag;
5151
};

src/main/include/RobotMap.h

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44

55
#pragma once
66

7-
#include "mag.h"
8-
#include "Wombat.h"
9-
10-
#include <frc/XboxController.h>
11-
#include <frc/DigitalInput.h>
12-
137
#include <frc/Compressor.h>
8+
#include <frc/DigitalInput.h>
149
#include <frc/DoubleSolenoid.h>
10+
#include <frc/XboxController.h>
1511
#include <frc/system/plant/DCMotor.h>
1612
#include <units/angle.h>
1713
#include <units/length.h>
@@ -22,14 +18,17 @@
2218
#include <ctre/phoenix6/Pigeon2.hpp>
2319
#include <ctre/phoenix6/TalonFX.hpp>
2420

21+
#include "Wombat.h"
22+
#include "mag.h"
23+
2524
struct RobotMap {
2625
struct Controllers {
2726
frc::XboxController driver = frc::XboxController(0);
2827
frc::XboxController coDriver = frc::XboxController(1);
2928
frc::XboxController testController = frc::XboxController(2);
3029
};
3130
Controllers controllers;
32-
31+
3332
struct SwerveBase {
3433
ctre::phoenix6::hardware::CANcoder frontLeftCancoder{19};
3534
ctre::phoenix6::hardware::CANcoder frontRightCancoder{17};
@@ -134,26 +133,21 @@ struct RobotMap {
134133
SwerveBase swerveBase;
135134

136135
struct Mag {
137-
rev::CANSparkMax *magMotor = new rev::CANSparkMax{99, rev::CANSparkMax::MotorType::kBrushless};
138-
//wom::VoltageController magMotorGroup = wom::VoltageController::Group(magMotor);
136+
rev::CANSparkMax* magMotor = new rev::CANSparkMax{99, rev::CANSparkMax::MotorType::kBrushless};
137+
// wom::VoltageController magMotorGroup = wom::VoltageController::Group(magMotor);
139138
wom::CANSparkMaxEncoder magEncoder{magMotor, 0.1_m};
140139
frc::DigitalInput intakeSensor{0};
141140
frc::DigitalInput magSensor{1};
142141
frc::DigitalInput shooterSensor{1};
143142

144-
wom::Gearbox magGearbox {
145-
magMotor,
146-
&magEncoder,
147-
frc::DCMotor::NEO(1)
148-
};
143+
wom::Gearbox magGearbox{magMotor, &magEncoder, frc::DCMotor::NEO(1)};
149144

150-
MagConfig config {
151-
magGearbox,
152-
&intakeSensor,
153-
&magSensor,
154-
&shooterSensor,
155-
};
156-
};
145+
MagConfig config{
146+
magGearbox,
147+
&intakeSensor,
148+
&magSensor,
149+
&shooterSensor,
150+
};
151+
};
157152
Mag magSystem;
158-
159153
};

0 commit comments

Comments
 (0)