Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drivetrain impl #9

Merged
merged 23 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1efb47e
Partial implementation of swerve_module
VyaasBaskar Dec 27, 2024
7f0a094
Ensure formatting check occurs in formatting_check action
VyaasBaskar Dec 27, 2024
bc96c5b
SwerveModuleSubsystem: Added zeroing with cancoder, cosine compensati…
VyaasBaskar Dec 27, 2024
67bf07c
Fixed missing includes in motor control
VyaasBaskar Dec 27, 2024
d3887ad
Added graphs to SwerveModuleSubsystem
VyaasBaskar Dec 28, 2024
cd68f92
Outline implementation of DrivetrainSubsystem
VyaasBaskar Dec 29, 2024
796fab3
Merge branch 'drivetrain_impl' of https://github.com/Team846/monkey_m…
VyaasBaskar Dec 29, 2024
d438116
Fixed compilation errors arising from merge
VyaasBaskar Dec 29, 2024
935014c
Implemented specific functions of DrivetrainSubsystem, added SwerveOd…
VyaasBaskar Dec 29, 2024
d94f6e8
Merge branch 'master' into drivetrain_impl
VyaasBaskar Dec 29, 2024
52f1f5c
Fixed compilation errors arising from merge
VyaasBaskar Dec 29, 2024
7e45e5a
unfinished drivetrain.cc
DhananjayKhulbe Dec 31, 2024
e6a71a2
Temporary commit
VyaasBaskar Dec 31, 2024
adaa055
Merge branch 'drivetrain_impl' of https://github.com/Team846/monkey_m…
VyaasBaskar Dec 31, 2024
da6b702
Added DrivetrainConstructor, fixed build errors
VyaasBaskar Jan 1, 2025
7c6d8c5
Merge branch 'drivetrain_impl' into sim_to_drivetrain_merge_temporary
VyaasBaskar Jan 2, 2025
220a0f6
Merge pull request #7 from Team846/sim_to_drivetrain_merge_temporary
VyaasBaskar Jan 2, 2025
832fd3e
Finished DrivetrainConstructor, added preferences
VyaasBaskar Jan 2, 2025
275fcd8
Merge branch 'drivetrain_impl' of https://github.com/Team846/monkey_m…
VyaasBaskar Jan 2, 2025
08da28d
Fixed on-bootup crashes using motor hardware simulation
VyaasBaskar Jan 2, 2025
464066c
Tested code with motor physics simulation
VyaasBaskar Jan 2, 2025
f8d62f9
Merge pull request #8 from Team846/simulate_drivetrain_impl
VyaasBaskar Jan 2, 2025
64a8efa
Finished drivetrain control, drive_command; Tested with motor physics…
VyaasBaskar Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading