Skip to content

Commit

Permalink
add wpiformat
Browse files Browse the repository at this point in the history
- adds github action for wpiformat checkign
- adds wpiformat required config

- Isaac
  • Loading branch information
spacey-sooty committed Dec 10, 2023
1 parent 6a7cf20 commit 3e74a6e
Show file tree
Hide file tree
Showing 72 changed files with 315 additions and 78 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ root = true
[*]
indent_style = space
indent_size = 2

1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.

1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ A clear and concise description of any alternative solutions or features you've

**Additional context**
Add any other context or screenshots about the feature request here.

5 changes: 2 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
**What this PR does**
**What this PR does**

**What does it fix/add?**
**What does it fix/add?**
_Reference issues with "Fixes #10" or "Closes #10", where #10 is the number assigned to the issue_

**What does this depend on?**
_References pull requests or branches/forks that this pull request depends on_

3 changes: 1 addition & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
- package-ecosystem: "gradle"
directory: "/"
schedule:
schedule:
interval: "daily"
- package-ecosystem: "gradle"
directory: "/wombat"
Expand All @@ -11,4 +11,3 @@ version: 2
directory: "/"
schedule:
interval: "daily"

1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ jobs:
# Runs a single command using the runners shell
- name: Compile and run tests on robot code
run: ./gradlew build

34 changes: 34 additions & 0 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint and Format

on:
pull_request:
push:

jobs:
wpiformat:
name: "wpiformat"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Fetch all history and metadata
run: |
git config --global --add safe.directory /__w/allwpilib/allwpilib
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install clang-format
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-format-14
- name: Install wpiformat
run: pip3 install wpiformat
- name: Run
run: wpiformat -clang 14
- name: Check output
run: git --no-pager diff --exit-code HEAD
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ jobs:
The latest release of our 2024 build season code!
draft: false
prerelease: false

14 changes: 14 additions & 0 deletions .styleguide
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cppHeaderFileInclude {
\.h$
\.hpp$
\.inc$
\.inl$
}

cppSrcFileInclude {
\.cpp$
}

modifiableFileExclude {
gradle/
}
3 changes: 3 additions & 0 deletions .styleguide-license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project
1 change: 0 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,3 @@ individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Contributing to our 2024 Codebase.
Our 2024 Codebase is split up into two main projects, our robot code and our library Wombat. This will only focus on our robot code but if you our on programming team it is recomended that you also read the contributing guide for Wombat. This guide assumes you have already read the README.md.
# Contributing to our 2024 Codebase.
Our 2024 Codebase is split up into two main projects, our robot code and our library Wombat. This will only focus on our robot code but if you our on programming team it is recomended that you also read the contributing guide for Wombat. This guide assumes you have already read the README.md.

## Git
Whenever you start on something new create a new branch from your master branch. The branch name should describe what it aims to achieve. When you are done you should open a pull request to CurtinFRC master.
Whenever you start on something new create a new branch from your master branch. The branch name should describe what it aims to achieve. When you are done you should open a pull request to CurtinFRC master.

## Git History
Try and keep git history clean. Commit messages should be *descriptive*.
Try and keep git history clean. Commit messages should be *descriptive*.
An example of good Git usage would be as follows :
```bash
git add .
Expand All @@ -14,10 +14,10 @@ git push _remotename_ _branchname_ eg origin intake-fix
```

## Creating Issues
Issues should be created to report bugs or request features. Use the appropriate template for your issue and make sure to apply the appropriate labels. If you are working on an issue assign yourself to the issue.
Issues should be created to report bugs or request features. Use the appropriate template for your issue and make sure to apply the appropriate labels. If you are working on an issue assign yourself to the issue.

## Creating Pull Requests
Pull requests should be created to resolve issues. Reference the issue you are resolving in your pull request. Pull requests are required to pass continuous integration checks that run automatically, follow formatting rules as per Wombat documentation. Request a review from programming captain.
Pull requests should be created to resolve issues. Reference the issue you are resolving in your pull request. Pull requests are required to pass continuous integration checks that run automatically, follow formatting rules as per Wombat documentation. Request a review from programming captain.

## Wombat Contributions
Wombat contributions are expected to follow the guidelines set out in the contributing guide for Wombat. All Wombat changes during build season will be periodically reviewed and merged into a seperate branch of Wombat during build season. Outside of build season it will be less periodically merged in but will be directly merged to master. As Wombat is a 4788 published library there are stricter standards.
Wombat contributions are expected to follow the guidelines set out in the contributing guide for Wombat. All Wombat changes during build season will be periodically reviewed and merged into a seperate branch of Wombat during build season. Outside of build season it will be less periodically merged in but will be directly merged to master. As Wombat is a 4788 published library there are stricter standards.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Build
------
`./gradlew build`
Build will compile and get the code ready without deploying it.
It will also run all automated tests, which is great for testing your code before it ever gets run on a robot (which also means you can build whenever).
It will also run all automated tests, which is great for testing your code before it ever gets run on a robot (which also means you can build whenever).

`./gradlew :wombat:build`
Will compile and build the Wombat library.
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,3 @@ model {
subprojects {
project.buildDir = rootProject.buildDir
}

1 change: 0 additions & 1 deletion compile_flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
-I wombat/src/main/include/*
-L/usr/local/lib
-I/usr/local/include

1 change: 0 additions & 1 deletion format.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
find **\**\** -iname *.h -o -iname *.cpp | xargs clang-format -i

1 change: 0 additions & 1 deletion format.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
find **/**/** -iname *.h -o -iname *.cpp | xargs clang-format -i

1 change: 0 additions & 1 deletion init.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.\gradlew installRoborioToolchain
.\gradlew build

1 change: 0 additions & 1 deletion init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ sudo apt install -y openjdk-11-jre-headless
chmod +x gradlew
./gradlew installRoborioToolchain
./gradlew build

1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ pluginManagement {

include 'wombat'
rootProject.name = '2024-Crescendo'

4 changes: 4 additions & 0 deletions src/main/cpp/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

/*
Dont edit this file
Go to Robot.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "Robot.h"

void Robot::RobotInit() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/deploy/example.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Files placed in this directory will be deployed to the RoboRIO into the
'deploy' directory in the home folder. Use the 'frc::filesystem::GetDeployDirectory'
function from the 'frc/Filesystem.h' header to get a proper path relative to the deploy
directory.
directory.
4 changes: 4 additions & 0 deletions src/main/include/Robot.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 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 <frc/TimedRobot.h>
Expand Down
4 changes: 4 additions & 0 deletions src/main/include/RobotMap.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 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 <ctre/Phoenix.h>
Expand Down
4 changes: 4 additions & 0 deletions src/test/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include <hal/HAL.h>

#include "gtest/gtest.h"
Expand Down
1 change: 0 additions & 1 deletion wombat/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
.gradle
*.exe
*.out

4 changes: 2 additions & 2 deletions wombat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ model {
components {
Wombat(NativeLibrarySpec) {
targetPlatform NativePlatforms.desktop
targetPlatform NativePlatforms.roborio
targetPlatform NativePlatforms.roborio

sources {
sources.cpp {
Expand All @@ -20,7 +20,7 @@ model {
exportedHeaders {
srcDir 'src/main/include'
}
}
}
}

binaries.all {
Expand Down
6 changes: 5 additions & 1 deletion wombat/src/main/cpp/behaviour/Behaviour.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "behaviour/Behaviour.h"

using namespace behaviour;
Expand Down Expand Up @@ -266,4 +270,4 @@ Print::Print(std::string message) : _message(message) {}
void Print::OnTick(units::time::second_t dt) {
std::cout << _message << std::endl;
SetDone();
}
}
6 changes: 5 additions & 1 deletion wombat/src/main/cpp/behaviour/BehaviourScheduler.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "behaviour/BehaviourScheduler.h"

using namespace behaviour;
Expand Down Expand Up @@ -73,4 +77,4 @@ void BehaviourScheduler::InterruptAll() {
for (HasBehaviour *sys : _systems) {
if (sys->_active_behaviour) sys->_active_behaviour->Interrupt();
}
}
}
6 changes: 5 additions & 1 deletion wombat/src/main/cpp/behaviour/HasBehaviour.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "behaviour/HasBehaviour.h"

#include "behaviour/Behaviour.h"
Expand All @@ -10,4 +14,4 @@ void HasBehaviour::SetDefaultBehaviour(std::function<std::shared_ptr<Behaviour>(

std::shared_ptr<Behaviour> HasBehaviour::GetActiveBehaviour() {
return _active_behaviour;
}
}
4 changes: 4 additions & 0 deletions wombat/src/main/cpp/drivetrain/Drivetrain.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "drivetrain/Drivetrain.h"

using namespace frc;
Expand Down
23 changes: 22 additions & 1 deletion wombat/src/main/cpp/drivetrain/SwerveDrive.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "drivetrain/SwerveDrive.h"

wom::drivetrain::SwerveModule::SwerveModule(wom::drivetrain::SwerveModuleConfig config,
Expand Down Expand Up @@ -107,7 +111,9 @@ wom::drivetrain::Swerve::Swerve(wom::drivetrain::SwerveConfig config, wom::drive
wom::vision::Limelight *vision)
: _config(config), _state(state), _vision(vision) {}

wom::drivetrain::Swerve::Swerve(wom::drivetrain::SwerveConfig config, wom::drivetrain::SwerveState state, Pigeon2 *gyro) : _config(config), _state(state), _gyro(gyro) {}
wom::drivetrain::Swerve::Swerve(wom::drivetrain::SwerveConfig config, wom::drivetrain::SwerveState state,
Pigeon2 *gyro)
: _config(config), _state(state), _gyro(gyro) {}

wom::drivetrain::SwerveConfig wom::drivetrain::Swerve::GetConfig() {
return _config;
Expand Down Expand Up @@ -170,6 +176,21 @@ void wom::drivetrain::Swerve::OnUpdate(units::second_t dt, wom::vision::Limeligh
case wom::drivetrain::SwerveState::kFieldRelative:
FieldRelativeControl(desiredPose, dt);
break;
default:
std::cout << "Invalid State" << std::endl;
break;
}
}

void wom::drivetrain::Swerve::RobotRelativeControl(units::second_t dt, units::radian_t desiredDirection,
units::meter_t magnitude) {}

void wom::drivetrain::Swerve::OnUpdate(units::second_t dt, Pigeon2 *gyro) {
switch (_state) {
case wom::drivetrain::SwerveState::kIdle:
break;
case wom::drivetrain::SwerveState::kPose:
break;
case wom::drivetrain::SwerveState::kRobotRelative:
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "drivetrain/behaviours/DrivetrainBehaviours.h"

wom::drivetrain::behaviours::TankDrive::TankDrive(wom::drivetrain::Drivetrain *drivebase,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include <drivetrain/behaviours/SwerveBehaviours.h>
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "drivetrain/behaviours/SwerveBehaviours.h"

wom::drivetrain::behaviours::FieldRelativeSwerveDrive::FieldRelativeSwerveDrive(
wom::drivetrain::Swerve *swerve, frc::XboxController &driver)
Expand Down
6 changes: 5 additions & 1 deletion wombat/src/main/cpp/example/Example.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

// This should be the only include in your subsystem files
#include "example/Example.h"

Expand Down Expand Up @@ -48,7 +52,7 @@ void Example::OnUpdate(units::second_t dt) {
case ExampleState::kIdle:
break;
case ExampleState::kRunning:
double speed = (fabs(_driver.GetLeftY()) > 0.05) ? _driver.GetLeftY() : 0;
double speed = (std::fabs(_driver.GetLeftY()) > 0.05) ? _driver.GetLeftY() : 0;
_config->leftGearbox.transmission->SetVoltage(speed * 1_V);
break;
}
Expand Down
4 changes: 4 additions & 0 deletions wombat/src/main/cpp/example/behaviours/ExampleBehaviours.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2023 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

// this should be your only include in your behaviour cpp files
#include "example/behaviour/ExampleBehaviours.h"

Expand Down
Loading

0 comments on commit 3e74a6e

Please sign in to comment.