Skip to content

Commit

Permalink
Update from 2024 robot
Browse files Browse the repository at this point in the history
  • Loading branch information
legoguy1000 committed Nov 2, 2024
1 parent 4a5d4d4 commit f0a9d10
Show file tree
Hide file tree
Showing 53 changed files with 3,968 additions and 2,259 deletions.
1 change: 0 additions & 1 deletion .codespellignore

This file was deleted.

6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ trim_trailing_whitespace = true
# 4 space indentation
[*.java]
indent_style = space
indent_size = 4
indent_size = 4

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Auto detect text files and perform LF normalization
* text=auto
src/main/deploy/photon-configs/front-right.zip filter=lfs diff=lfs merge=lfs -text
src/main/deploy/photon-configs/back-left.zip filter=lfs diff=lfs merge=lfs -text
src/main/deploy/photon-configs/front-left.zip filter=lfs diff=lfs merge=lfs -text
customAssets/Robot_Pumbaa/model_0.glb filter=lfs diff=lfs merge=lfs -text
customAssets/Robot_Pumbaa/model_1.glb filter=lfs diff=lfs merge=lfs -text
customAssets/Robot_Pumbaa/model_2.glb filter=lfs diff=lfs merge=lfs -text
customAssets/Robot_Pumbaa/model_3.glb filter=lfs diff=lfs merge=lfs -text
customAssets/Robot_Pumbaa/model.glb filter=lfs diff=lfs merge=lfs -text
23 changes: 18 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v3 # v2 minimum required
- name: Run check style
uses: nikitasavinov/checkstyle-action@master
uses: dbelyaev/action-checkstyle@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: 'github-check'
tool_name: 'testtool'
fail_on_error: true
filter_mode: nofilter
level: error
checkstyle_config: checks.xml
checkstyle_version: '9.2.1'
spell_check:
name: Spell Check
runs-on: ubuntu-latest
Expand All @@ -38,8 +36,7 @@ jobs:
uses: codespell-project/actions-codespell@master
with:
check_filenames: true
ignore_words_file: .codespellignore
merge_conflict:
merge_conflict_job:
runs-on: ubuntu-latest
name: Find merge conflicts
steps:
Expand All @@ -48,6 +45,22 @@ jobs:
# Run the actual merge conflict finder
- name: Merge Conflict finder
uses: olivernybroe/[email protected]
javadoc:
name: Test Javadocs Generation
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# This grabs the WPILib docker container
container: wpilib/roborio-cross-ubuntu:2024-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Runs a single command using the runners shell
- name: Create Javadocs
run: ./gradlew javadoc
build:
name: Build
# The type of runner that the job will run on
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is a basic workflow to help you get started with Actions

name: Javadoc

# Controls when the action will run.
on:
# Triggers the workflow on push
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
javadoc:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
name: Generate Javadocs
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# This grabs the WPILib docker container
container: wpilib/roborio-cross-ubuntu:2023-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Runs a single command using the runners shell
- name: Create Javadocs
run: ./gradlew javadoc
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: './build/docs/javadoc'
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v1
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,13 @@ logs/

# Folder that has CTRE Phoenix Sim device config storage
ctre_sim/

BuildConstants.java
networktables.json
simgui-ds.json
simgui.json

!src/main/deploy/photon-configs/*.zip

/*.wpilog
/*-profile.json
18 changes: 18 additions & 0 deletions .pathplanner/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"robotWidth": 0.876,
"robotLength": 0.876,
"holonomicMode": true,
"pathFolders": [
"P321",
"P123",
"Resnick 3",
"Resnick 4",
"Resnick 5"
],
"autoFolders": [],
"defaultMaxVel": 5.0,
"defaultMaxAccel": 4.0,
"defaultMaxAngVel": 540.0,
"defaultMaxAngAccel": 720.0,
"maxModuleSpeed": 4.5
}
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recommendations": [
"vscjava.vscode-java-debug",
"editorconfig.editorconfig",
"vscjava.vscode-java-pack",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"redhat.java",
"wpilibsuite.vscode-wpilib"
]
}
12 changes: 9 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "java",
"name": "Main",
"request": "launch",
"mainClass": "frc.robot.Main",
"projectName": "FRC2024"
},
{
"type": "wpilib",
"name": "WPILib Desktop Debug",
"request": "launch",
"desktop": true,
"desktop": true
},
{
"type": "wpilib",
"name": "WPILib roboRIO Debug",
"request": "launch",
"desktop": false,
"desktop": false
}
]
}
6 changes: 2 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
{
"name": "WPIlibUnitTests",
"workingDirectory": "${workspaceFolder}/build/jni/release",
"vmargs": [
"-Djava.library.path=${workspaceFolder}/build/jni/release"
],
"vmargs": [ "-Djava.library.path=${workspaceFolder}/build/jni/release" ],
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release",
"LD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release" ,
"DYLD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release"
}
},
Expand Down
59 changes: 25 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
# BaseFalconSwerve </br>
**Basic Swerve Code for a Swerve Module using Falcon Motors, a CTRE CANCoder, and a CTRE Pigeon Gyro** </br>
This code was designed with SDS MK3 style modules in mind, but should be easily adaptable to other styles of modules.</br>

**Setting Constants**
----
The following things must be adjusted to your robot and module's specific constants in the Constants.java file (all distance units must be in meters, and rotation units in radians):</br>
1. Gyro Settings: ```pigeonID``` and ```invertGyro``` (ensure that the gyro rotation is CCW+ (Counter Clockwise Positive)
2. ```trackWidth``` (Center to Center distance of left and right modules)
3. ```wheelBase``` (Center to Center distance of front and rear module wheels)
4. ```wheelDiameter```
5. ```driveGearRatio``` (for SDS MK3 either: (8.16 / 1) or (6.86 / 1))
6. ```angleGearRatio``` (for SDS MK3: (12.8 / 1))
7. Angle Motor PID Values:
* To tune start with a low P value (0.01).
* Multiply by 10 until the module starts oscillating around the set point
* Scale back by searching for the value (for example, if it starts oscillating at a P of 10, then try (10 -> 5 -> 7.5 -> etc)) until the module overshoots the setpoint but corrects with no oscillation.
* Repeat the process for D. The D value will basically help prevent the overshoot. Ignore I.
8. Get the drive characterization values (KS, KV, KA) by using the WPILib characterization tool, found [here](https://docs.wpilib.org/en/stable/docs/software/wpilib-tools/robot-characterization/introduction.html). You will need to lock your modules straight forward, and complete the characterization as if it was a standard tank drive.
9. Tune drive kP until it doesn't overshoot and doesn't oscillate around a target velocity.
10. For ```maxSpeed``` and ```maxAngularVelocity``` you can use the theoretical values, but it is better to physically drive the robot and find the actual max values.
11. Set ```canCoderInvert``` and ```angleMotorInvert``` such that both are CCW+.
12. In the module specific constants, set the can ID's of the motors and CANCoders for the respective modules.
13. Setting Offsets
* For finding the offsets, use a piece of 1x1 metal that is straight against the forks of the front and back modules (on the left and right side) to ensure that the modules are straight.
* You need to point the bevel gears of all the wheels in the same direction (either facing left or right). And preferably you should have the wheels facing in the direction where a positive input to the drive motor drives forward. If for some reason you set the offsets with the wheels backwards, you can change the ```driveMotorInvert``` to fix.
* Open smartdashboard (or shuffleboard and go to the smartdashboard tab), you will see 4 printouts called "Mod 0 Cancoder", "Mod 1 Cancoder", etc. If you have already straightened the modules, copy those 4 numbers exactly (to 2 decimal places) to their respective ```angleOffset``` variable in constants.


**Controller Mappings**
----
This code is natively setup to use a xbox controller to control the swerve driver. </br>
The Left Stick controls translation (forwards and sideways movement), and the Right Stick controls rotation. </br>
The Y button is mapped to zero the gyro, useful if the gyro drifts mid match, just rotate the robot forwards, and press Y to rezero.
# Jetsi Offseason

[![CI](https://github.com/Frc5572/Jetsi-Offseason/actions/workflows/main.yml/badge.svg)](https://github.com/Frc5572/Jetsi-Offseason/actions/workflows/main.yml) [![Java Docs](https://img.shields.io/badge/docs-2024-blue)](https://frc5572.github.io/FRC2024/)

Code for our 2024 robot

## CAN IDs

### Swerve

Front Left Drive Motor -
Front Left Angle Motor -
Front Left canCoder -

Front Right Drive Motor -
Front Right Angle Motor -
Front Right canCoder -

Back Left Drive Motor -
Back Left Angle Motor -
Back Left canCoder -

Back Right Drive Motor -
Back Right Angle Motor -
Back Right canCoder -
57 changes: 49 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.2.1"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "com.peterabeles.gversion" version "1.10"
}

java {
Expand Down Expand Up @@ -49,7 +50,32 @@ def includeDesktopSupport = false

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 5.

repositories {
maven {
url = uri("https://maven.pkg.github.com/Mechanical-Advantage/AdvantageKit")
credentials {
username = "Mechanical-Advantage-Bot"
password = "\u0067\u0068\u0070\u005f\u006e\u0056\u0051\u006a\u0055\u004f\u004c\u0061\u0079\u0066\u006e\u0078\u006e\u0037\u0051\u0049\u0054\u0042\u0032\u004c\u004a\u006d\u0055\u0070\u0073\u0031\u006d\u0037\u004c\u005a\u0030\u0076\u0062\u0070\u0063\u0051"
}
}
mavenLocal()
maven { url 'https://jitpack.io' }
}

configurations.all {
exclude group: "edu.wpi.first.wpilibj"
}

task(checkAkitInstall, dependsOn: "classes", type: JavaExec) {
mainClass = "org.littletonrobotics.junction.CheckInstall"
classpath = sourceSets.main.runtimeClasspath
}
compileJava.finalizedBy checkAkitInstall

dependencies {
def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text)
annotationProcessor "org.littletonrobotics.akit.junction:junction-autolog:$akitJson.version"
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()

Expand All @@ -67,13 +93,7 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
// testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
annotationProcessor 'com.github.Frc5572:RobotTools:v1.1.1'
}

// Simulation configuration (e.g. environment variables).
Expand All @@ -99,3 +119,24 @@ wpi.java.configureTestTasks(test)
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

javadoc {
configure(options) {
options.addBooleanOption("-allow-script-in-comments",true)
options.addStringOption("link", "https://github.wpilib.org/allwpilib/docs/release/java/")
options.header = "<script type=\"text/javascript\" async" +
" src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML\">" +
"</script>"
}
}

// Create version file
project.compileJava.dependsOn(createVersionFile)
gversion {
srcDir = "src/main/java/"
classPackage = "frc.robot"
className = "BuildConstants"
dateFormat = "yyyy-MM-dd HH:mm:ss z"
timeZone = "America/New_York"
indent = " "
}
12 changes: 11 additions & 1 deletion checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[_a-z]([_a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LambdaParameterName">
<property name="format" value="^[_a-z]([_a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
Expand Down Expand Up @@ -314,7 +319,7 @@
value="^@return the *|^This method returns |^A [{]@code [_a-zA-Z0-9]+[}]( is a )"/>
</module> -->
<module name="JavadocParagraph">
<property name="allowNewlineParagraph" value="false"/>
<property name="allowNewlineParagraph" value="true"/>
</module>
<module name="JavadocStyle">
<property name="checkFirstSentence" value="false"/>
Expand Down Expand Up @@ -346,6 +351,11 @@
RECORD_DEF, ANNOTATION_DEF"/>
<property name="excludeScope" value="nothing"/>
</module>
<module name="MethodName">
<property name="format" value="^[_a-z][_a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc"/>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/>
Expand Down
Loading

0 comments on commit f0a9d10

Please sign in to comment.