Skip to content

Commit

Permalink
Fixed github build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
prawny-boy committed Jan 22, 2024
2 parents 1bbe21c + 4623dc8 commit 11f12f9
Show file tree
Hide file tree
Showing 32 changed files with 338 additions and 569 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
ColumnLimit: 110
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
python-version: 3.8
- name: Install wpiformat
run: pip3 install wpiformat==2023.36
run: pip3 install wpiformat==2024.31
- name: Run
run: wpiformat
- name: Check output
Expand Down
12 changes: 8 additions & 4 deletions src/main/cpp/Behaviours/ClimberBehaviour.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// Copyright (c) 2023-2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "Behaviours/ClimberBehaviour.h"

ClimberManualControl::ClimberManualControl(Climber *climber, frc::XboxController *codriver) : _climber(climber), _codriver(codriver) {
Controls(climber);
ClimberManualControl::ClimberManualControl(Climber* climber, frc::XboxController* codriver)
: _climber(climber), _codriver(codriver) {
Controls(climber);
}

void ClimberManualControl::OnTick(units::second_t dt) {

if (_codriver->GetXButtonPressed()) {
if (_rawControl == false) {
_rawControl = true;
Expand All @@ -21,4 +25,4 @@ void ClimberManualControl::OnTick(units::second_t dt) {
_climber->SetState(ClimberState::kClimb);
}
}
}
}
35 changes: 15 additions & 20 deletions src/main/cpp/Climber.cpp
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
// Copyright (c) 2023-2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "Climber.h"

Climber::Climber(ClimberConfig config) : _config(config) {}

void Climber::OnUpdate(units::second_t dt) {
switch (_state) {
case ClimberState::kIdle:
{
case ClimberState::kIdle: {
_stringStateName = "Idle";
_setVoltage = 0_V;
}
break;
} break;

case ClimberState::kClimb:
{
case ClimberState::kClimb: {
_stringStateName = "Climb";
_setVoltage = 8_V;
}
break;
} break;

case ClimberState::kHang:
{
case ClimberState::kHang: {
_stringStateName = "Hang";
_setVoltage = -8_V;
}
break;
} break;

case ClimberState::kRaw:
{
case ClimberState::kRaw: {
_stringStateName = "Raw";
_setVoltage = _rawVoltage;
}
break;
} break;
default:
std::cout << "Error magazine in invalid state" << std::endl;
break;
std::cout << "Error magazine in invalid state" << std::endl;
break;
}
_config.climberGearbox.motorController->SetVoltage(_setVoltage);

_table->GetEntry("State: ").SetString(_stringStateName);
_table->GetEntry("Motor Voltage: ").SetDouble(_setVoltage.value());

}

void Climber::SetState(ClimberState state) {
Expand All @@ -48,4 +43,4 @@ void Climber::SetState(ClimberState state) {

void Climber::SetRaw(units::volt_t voltage) {
_rawVoltage = voltage;
}
}
2 changes: 1 addition & 1 deletion src/main/cpp/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
#include "Robot.h"
#include "Wombat.h"

WOMBAT_ROBOT_MAIN(Robot);
WOMBAT_ROBOT_MAIN(Robot);
19 changes: 7 additions & 12 deletions src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,21 @@ void Robot::RobotInit() {

robotmap.swerveBase.gyro->Reset();

_swerveDrive =
new wom::SwerveDrive(robotmap.swerveBase.config, frc::Pose2d());
_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->SetDefaultBehaviour(
[this]() { return wom::make<wom::ManualDrivebase>(_swerveDrive, &robotmap.controllers.driver); });

lastPeriodic = wom::now();

climber = new Climber(robotmap.climberSystem.config);
wom::BehaviourScheduler::GetInstance()->Register(climber);
climber->SetDefaultBehaviour([this]() {
return wom::make<ClimberManualControl>(climber, &robotmap.controllers.coDriver);
});
climber->SetDefaultBehaviour(
[this]() { return wom::make<ClimberManualControl>(climber, &robotmap.controllers.coDriver); });
// m_driveSim = new wom::TempSimSwerveDrive(&simulation_timer, &m_field);
// m_driveSim = wom::TempSimSwerveDrive();
}


void Robot::RobotPeriodic() {
units::second_t dt = wom::now() - lastPeriodic;
lastPeriodic = wom::now();
Expand All @@ -81,7 +76,7 @@ void Robot::AutonomousPeriodic() {

void Robot::TeleopInit() {
loop.Clear();
wom::BehaviourScheduler *scheduler = wom::BehaviourScheduler::GetInstance();
wom::BehaviourScheduler* scheduler = wom::BehaviourScheduler::GetInstance();
scheduler->InterruptAll();
// _swerveDrive->OnStart();
// sched->InterruptAll();
Expand All @@ -97,4 +92,4 @@ void Robot::TestPeriodic() {}

void Robot::SimulationInit() {}

void Robot::SimulationPeriodic() {}
void Robot::SimulationPeriodic() {}
26 changes: 16 additions & 10 deletions src/main/include/Behaviours/ClimberBehaviour.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// Copyright (c) 2023-2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#pragma once

#include "Wombat.h"
#include "Climber.h"
#include <frc/XboxController.h>

#include "Climber.h"
#include "Wombat.h"

class ClimberManualControl : public behaviour::Behaviour {
public:
explicit ClimberManualControl(Climber *climber, frc::XboxController *codriver);
void OnTick(units::second_t dt) override;
private:
Climber *_climber;
frc::XboxController *_codriver;
bool _rawControl = false;
};
public:
explicit ClimberManualControl(Climber* climber, frc::XboxController* codriver);
void OnTick(units::second_t dt) override;

private:
Climber* _climber;
frc::XboxController* _codriver;
bool _rawControl = false;
};
45 changes: 23 additions & 22 deletions src/main/include/Climber.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
// Copyright (c) 2023-2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#pragma once

#include "Wombat.h"
#include <string>
#include <memory>
#include <string>

#include "Wombat.h"

struct ClimberConfig {
wom::Gearbox climberGearbox;
};

enum class ClimberState {
kIdle,
kRaw,
kClimb,
kHang
};
enum class ClimberState { kIdle, kRaw, kClimb, kHang };

class Climber : public behaviour::HasBehaviour {
public:
explicit Climber(ClimberConfig config);

void OnUpdate(units::second_t dt);
void SetState(ClimberState state);
void SetRaw(units::volt_t voltage);
private:
ClimberConfig _config;
ClimberState _state = ClimberState::kIdle;
units::volt_t _rawVoltage = 0_V;
std::string _stringStateName = "error";
units::volt_t _setVoltage;
std::shared_ptr<nt::NetworkTable> _table = nt::NetworkTableInstance::GetDefault().GetTable("Climber");
};
public:
explicit Climber(ClimberConfig config);

void OnUpdate(units::second_t dt);
void SetState(ClimberState state);
void SetRaw(units::volt_t voltage);

private:
ClimberConfig _config;
ClimberState _state = ClimberState::kIdle;
units::volt_t _rawVoltage = 0_V;
std::string _stringStateName = "error";
units::volt_t _setVoltage;
std::shared_ptr<nt::NetworkTable> _table = nt::NetworkTableInstance::GetDefault().GetTable("Climber");
};
10 changes: 1 addition & 9 deletions src/main/include/Robot.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@





// Copyright (c) 2023-2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project
Expand All @@ -18,16 +13,13 @@
#include <frc/smartdashboard/Field2d.h>
#include <frc/smartdashboard/SendableChooser.h>
#include <frc/smartdashboard/SmartDashboard.h>

#include <frc/TimedRobot.h>
#include <networktables/DoubleTopic.h>
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableInstance.h>

#include <string>

#include "Behaviours/ClimberBehaviour.h"

#include "RobotMap.h"
#include "Wombat.h"

Expand Down Expand Up @@ -61,4 +53,4 @@ class Robot : public frc::TimedRobot {

wom::SwerveDrive* _swerveDrive;
Climber* climber;
};
};
Loading

0 comments on commit 11f12f9

Please sign in to comment.