Skip to content

Commit

Permalink
Merge pull request #8 from Team846/simulate_drivetrain_impl
Browse files Browse the repository at this point in the history
Simulate drivetrain impl
  • Loading branch information
VyaasBaskar authored Jan 2, 2025
2 parents 275fcd8 + 464066c commit f8d62f9
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 37 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,5 @@ src\frc846\cpp\frc846\robot\swerve\drivetrain.cc:94:44: warning: Variable 'ol_ta
src\frc846\cpp\frc846\robot\swerve\drivetrain.cc:108:64: warning: Variable 'accel_target' is assigned a value that is never used. [unreadVariable]
src\frc846\cpp\frc846\math\collection.cc:11:0: warning: The function 'HorizontalDeadband' is never used. [unusedFunction]
src\frc846\cpp\frc846\math\collection.cc:25:0: warning: The function 'VerticalDeadband' is never used. [unusedFunction]
src\frc846\cpp\frc846\math\collection.cc:52:0: warning: The function 'CoterminalSum' is never used. [unusedFunction]
```
2 changes: 1 addition & 1 deletion 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
138 changes: 138 additions & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
[
{
"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
}
}
]
58 changes: 58 additions & 0 deletions networktables.json.bck
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"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
}
}
]
92 changes: 92 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
]
}
13 changes: 13 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/SmartDashboard/get_prune_list": "Command",
"/SmartDashboard/prune_prefs": "Command",
"/SmartDashboard/verify_hardware": "Command"
}
},
"NetworkTables Info": {
"visible": true
}
}
5 changes: 0 additions & 5 deletions src/frc846/cpp/frc846/control/HigherMotorController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ HigherMotorController::HigherMotorController(
: mmtype_(mmtype), constr_params_(params) {}

void HigherMotorController::Setup() {
if (!called_enable_status_frames_) {
throw std::runtime_error(
"HigherMotorController: Call EnableStatusFrames before Setup");
}
slot_id_ = frc846::control::MotorMonkey::ConstructController(
mmtype_, constr_params_);
}
Expand Down Expand Up @@ -113,7 +109,6 @@ void HigherMotorController::SetSoftLimits(
void HigherMotorController::EnableStatusFrames(
std::vector<frc846::control::config::StatusFrame> frames) {
frc846::control::MotorMonkey::EnableStatusFrames(slot_id_, frames);
called_enable_status_frames_ = true;
}

} // namespace frc846::control
Loading

0 comments on commit f8d62f9

Please sign in to comment.