Skip to content

Commit

Permalink
Merge pull request #9 from Team846/drivetrain_impl
Browse files Browse the repository at this point in the history
Drivetrain impl
  • Loading branch information
VyaasBaskar authored Jan 2, 2025
2 parents e8fdc22 + 64a8efa commit b17d85c
Show file tree
Hide file tree
Showing 56 changed files with 1,695 additions and 125 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/compilation_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,8 @@ jobs:
- name: Install Roborio Toolchain
run: ./gradlew installRoborioToolchain

- name: Clear build directory
run: ./gradlew clean

- name: Compile code and run tests
run: ./gradlew build -PfromCI -PrunningSpotlessCpp
run: ./gradlew build -PfromCI --refresh-dependencies
2 changes: 1 addition & 1 deletion .github/workflows/formatting_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: ./gradlew installRoborioToolchain

- name: Spotless Check
run: ./gradlew spotlessCheck -PfromCI
run: ./gradlew spotlessCheck -PfromCI -PrunningSpotlessCpp
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ If unfamiliar with GitHub, go through tutorials in the [Using Git](#using-git) s

#### CppCheck

- Download [CppCheck](https://sourceforge.net/projects/cppcheck/files/1.86/cppcheck-1.86-x64-Setup.msi/download).
- Download [CppCheck](https://github.com/danmar/cppcheck/releases/download/2.16.0/cppcheck-2.16.0-x64-Setup.msi).
- If "Add CppCheck to Path" is an option during setup process, select YES.
- If not, add `C:\Program Files\Cppcheck` to PATH
- Read [this](https://stackoverflow.com/questions/44272416/how-to-add-a-folder-to-path-environment-variable-in-windows-10-with-screensho) for more information on adding files to PATH.
Expand Down Expand Up @@ -178,9 +178,9 @@ To undo the going back:


## CppCheck Warnings

```
src\frc846\cpp\frc846\math\collection.cc:11:0: warning: The function 'HorizontalDeadband' is never used. [unusedFunction]
src\frc846\cpp\frc846\robot\swerve\drivetrain.cc:152:64: warning: Variable 'accel_target' is assigned a value that is never used. [unreadVariable]
src\frc846\cpp\frc846\math\collection.cc:25:0: warning: The function 'VerticalDeadband' is never used. [unusedFunction]
src\frc846\cpp\frc846\math\collection.cc:39:0: warning: The function 'CoterminalDifference' is never used. [unusedFunction]
src\frc846\cpp\frc846\math\collection.cc:52:0: warning: The function 'CoterminalSum' is never used. [unusedFunction]
```
26 changes: 26 additions & 0 deletions __metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Outputs metrics such as [linecount] for this codebase

import os

INCL = ['*.py', '*.cc', '*.cpp', '.h', '.hpp', '.gradle', '.bat', '.sh', '.md', '.standard', '.json', '.lst']
FORCE_INCL_DIR = ["src\\deploy", "src/deploy"]

if __name__ == "__main__":

cwd = os.getcwd()

files = []
for root, dirs, filenames in os.walk(cwd):
for filename in filenames:
if any([root.__contains__(d) for d in FORCE_INCL_DIR]):
files.append(os.path.join(root, filename))
continue
for ext in INCL:
if filename.endswith(ext):
files.append(os.path.join(root, filename))

linecount = 0
for file in files:
linecount += sum(1 for line in open(file))

print(linecount)
14 changes: 10 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def deployArtifact = deploy.targets.roborio.artifacts.frcCpp
def includeDesktopSupport = false

// Set to true to run simulation in debug mode
wpi.cpp.debugSimulation = false
wpi.cpp.debugSimulation = true

// Default enable simgui
wpi.sim.addGui().defaultEnabled = false
Expand Down Expand Up @@ -182,15 +182,21 @@ task runCppcheck(type: Exec) {
}
}

def cppcheckSection = """## CppCheck Warnings\n```\n${reportContent.trim()}\n```\n"""
def cppcheckSection = """
## CppCheck Warnings
```
${reportContent.trim()}
```
"""
def readmeFile = file('README.md')
def readmeContent = readmeFile.text
def readmeContent = readmeFile.text.trim()

if (readmeContent.contains("## CppCheck Warnings")) {
readmeContent = readmeContent.substring(0, readmeContent.indexOf("## CppCheck Warnings"))
}

readmeContent += "\n" + cppcheckSection.trim()
readmeContent += cppcheckSection.trim()
readmeFile.text = readmeContent
}
}
Expand Down
186 changes: 186 additions & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
[
{
"name": "/Preferences/DrivetrainConstructor/DrivetrainConstructor/drive_motor_current_limit (A)",
"type": "double",
"value": 120.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/DrivetrainConstructor/DrivetrainConstructor/steer_motor_current_limit (A)",
"type": "double",
"value": 120.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/DrivetrainConstructor/DrivetrainConstructor/drive_motor_smart_current_limit (A)",
"type": "double",
"value": 80.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/DrivetrainConstructor/DrivetrainConstructor/steer_motor_smart_current_limit (A)",
"type": "double",
"value": 80.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/DrivetrainConstructor/DrivetrainConstructor/drive_motor_voltage_compensation (V)",
"type": "double",
"value": 16.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/DrivetrainConstructor/DrivetrainConstructor/steer_motor_voltage_compensation (V)",
"type": "double",
"value": 12.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/FR/SwerveDrivetrain/FR/cancoder_offset_ (deg)",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/FL/SwerveDrivetrain/FL/cancoder_offset_ (deg)",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/BR/SwerveDrivetrain/BR/cancoder_offset_ (deg)",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/BL/SwerveDrivetrain/BL/cancoder_offset_ (deg)",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/steer_gains/kP",
"type": "double",
"value": 0.3,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/steer_gains/kI",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/steer_gains/kD",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/steer_gains/kF",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/robot_container/init_drivetrain",
"type": "boolean",
"value": true,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/robot_container/init_leds",
"type": "boolean",
"value": true,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/control_input/trigger_threshold",
"type": "double",
"value": 0.3,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/SwerveDrivetrain/max_speed (fps)",
"type": "double",
"value": 15.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/SwerveDrivetrain/SwerveDrivetrain/max_omega (deg_per_s)",
"type": "double",
"value": 180.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/control_input/translation_deadband",
"type": "double",
"value": 0.07,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/control_input/translation_exponent",
"type": "int",
"value": 2,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/control_input/rotation_deadband",
"type": "double",
"value": 0.07,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/control_input/rotation_exponent",
"type": "int",
"value": 2,
"properties": {
"persistent": true
}
}
]
Loading

0 comments on commit b17d85c

Please sign in to comment.