diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c6ded9..b795541 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -117,5 +117,6 @@ "queue": "cpp" }, "wpilib.useWindbgX": true, - "C_Cpp.errorSquiggles": "enabled" + "C_Cpp.errorSquiggles": "enabled", + "wpilib.skipTests": true } diff --git a/build.gradle b/build.gradle index b634b0e..c13ff5e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,11 +7,16 @@ plugins { // Define my targets (RoboRIO) and artifacts (deployable files) deploy { + println "Setting up deploy targets and artifacts..." targets { roborio(getTargetTypeClass('RoboRIO')) { team = project.frc.getTeamNumber() debug = project.frc.getDebugOrDefault(false) + println "Deploy team # set to ${team}." + println "Debug set to ${debug} (disabled by default).\n" + + artifacts { frcCpp(getArtifactTypeClass('FRCNativeArtifact')) { } @@ -28,22 +33,27 @@ deploy { def deployArtifact = deploy.targets.roborio.artifacts.frcCpp // Set this to true to enable desktop support. -def includeDesktopSupport = false +def includeDesktopSupport = true // Set to true to run simulation in debug mode -wpi.cpp.debugSimulation = true +wpi.cpp.debugSimulation = false // Default enable simgui -wpi.sim.addGui().defaultEnabled = true +wpi.sim.addGui().defaultEnabled = false // Enable DS but not by default wpi.sim.addDriverstation() model { components { frcUserProgram(NativeExecutableSpec) { + println "Configuring frcUserProgram..." targetPlatform wpi.platforms.roborio if (includeDesktopSupport) { targetPlatform wpi.platforms.desktop + binaries.all { + cppCompiler.args << '-DNOMINMAX' + println "Applied compiler argument NOMINMAX to allow for compilation on Windows platform." + } } sources.cpp { @@ -71,22 +81,28 @@ model { wpi.cpp.deps.wpilib(it) } } - // Uncomment and configure test suites if needed - // testSuites { - // frcUserProgramTest(GoogleTestTestSuiteSpec) { - // testing $.components.frcUserProgram - // sources.cpp { - // source { - // srcDir 'src/test/cpp' - // include '**/*.cpp' - // } - // } - // wpi.cpp.enableExternalTasks(it) - // wpi.cpp.vendor.cpp(it) - // wpi.cpp.deps.wpilib(it) - // wpi.cpp.deps.googleTest(it) - // } - // } + + testSuites { + frcUserProgramTest(GoogleTestTestSuiteSpec) { + testing $.components.frcUserProgram + + println "Configuring frcUserProgramTest..." + sources.cpp { + source { + srcDir 'src/test/cpp' + include '**/*.cpp' + } + } + binaries.all { + cppCompiler.args << '-DNOMINMAX' + println "Applied compiler argument NOMINMAX to allow for compilation on Windows platform." + } + wpi.cpp.enableExternalTasks(it) + wpi.cpp.vendor.cpp(it) + wpi.cpp.deps.wpilib(it) + wpi.cpp.deps.googleTest(it) + } + } } spotless { diff --git a/networktables.json b/networktables.json new file mode 100644 index 0000000..10bfd50 --- /dev/null +++ b/networktables.json @@ -0,0 +1,2570 @@ +[ + { + "name": "/Preferences//drive_auto_origin_pt_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/five_piece_auto/pre_point_amt (ft)", + "type": "double", + "value": 2.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_x (in)", + "type": "double", + "value": 217.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_y (in)", + "type": "double", + "value": 49.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_x (in)", + "type": "double", + "value": 217.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_y (in)", + "type": "double", + "value": 112.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_x (in)", + "type": "double", + "value": 160.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_y (in)", + "type": "double", + "value": 112.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_x (in)", + "type": "double", + "value": 274.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_y (in)", + "type": "double", + "value": 112.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_x (in)", + "type": "double", + "value": 274.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_y (in)", + "type": "double", + "value": 180.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_x (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_y (in)", + "type": "double", + "value": 120.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_v_y (fps)", + "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_intake", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_shooter", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_wrist", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_pivot", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_telescope", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_leds", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_bracers_", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_vision_", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/translation_deadband", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/steer_deadband", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/translation_exponent", + "type": "int", + "value": 1, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/steer_exponent", + "type": "int", + "value": 2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/trigger_threshold", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/rumble_strength", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/operator/trigger_threshold", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/operator/rumble_strength", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/max_speed (fps)", + "type": "double", + "value": 14.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/close_drive_amp_max_speed (fps)", + "type": "double", + "value": 3.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/current_limit (A)", + "type": "double", + "value": 90.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/motor_stall_current (A)", + "type": "double", + "value": 366.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/braking_constant", + "type": "double", + "value": 0.15, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/ramp_rate_vx (fps)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/ramp_rate_vy (fps)", + "type": "double", + "value": 100.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/auto_max_speed (fps)", + "type": "double", + "value": 11.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/driver_speed_multiplier", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/slow_mode_percent", + "type": "double", + "value": 0.04, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/slow_omega_percent", + "type": "double", + "value": 0.12, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/pov_control_speed_", + "type": "double", + "value": 10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/velocity_error (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/max_acceleration (fps_sq)", + "type": "double", + "value": 8.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/max_deceleration (fps_sq)", + "type": "double", + "value": 10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/extrapolation_distance (in)", + "type": "double", + "value": 8.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/angular_velocity_threshold (deg_per_s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/align_gains/p", + "type": "double", + "value": 3.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/align_gains/align_tolerance (in)", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/width (in)", + "type": "double", + "value": 21.75, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/height (in)", + "type": "double", + "value": 26.75, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/percent_max_omega", + "type": "double", + "value": 0.45, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/wheel_radius (in)", + "type": "double", + "value": 1.93, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/bearing_gains/p", + "type": "double", + "value": 8.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/bearing_gains/d", + "type": "double", + "value": -4.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/gear_ratio", + "type": "double", + "value": 0.14979852970587568, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Gains/kP", + "type": "double", + "value": 0.0002, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Gains/kF", + "type": "double", + "value": 0.0001769, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/gear_ratio", + "type": "double", + "value": 16.8, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/default_brake_mode", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Gains/kP", + "type": "double", + "value": 0.12, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/smart_current_braking/smart_current_limit (A)", + "type": "double", + "value": 170.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/smart_current_braking/braking_p", + "type": "double", + "value": 0.45, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/cancoder_offset (deg)", + "type": "double", + "value": 3.23, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/cancoder_offset (deg)", + "type": "double", + "value": 140.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/cancoder_offset (deg)", + "type": "double", + "value": 297.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/cancoder_offset (deg)", + "type": "double", + "value": 157.89, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/base_intake_speed_ (fps)", + "type": "double", + "value": 2.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/intake_feed_speed_ (fps)", + "type": "double", + "value": 2.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/release_speed", + "type": "double", + "value": -0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/retract_speed", + "type": "double", + "value": -0.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/gear_ratio", + "type": "double", + "value": 0.11780972437500001, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Gains/kP", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Gains/kF", + "type": "double", + "value": 0.15, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooter_speed (fps)", + "type": "double", + "value": 65.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooter_spin", + "type": "double", + "value": 0.33, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooting_exit_velocity", + "type": "double", + "value": 47.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooter_speed_tolerance", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/gear_ratio", + "type": "double", + "value": 1.2435470906250001, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/default_brake_mode", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Gains/kP", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Gains/kF", + "type": "double", + "value": 0.15, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/vFPID/smart_current_limit (A)", + "type": "double", + "value": 35.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/vFPID/braking_p", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/wrist_tolerance (deg)", + "type": "double", + "value": 1.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/home_offset_wrist (deg)", + "type": "double", + "value": -49.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/cg_offset_wrist (deg)", + "type": "double", + "value": 60.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/max_adjustment_rate (deg_per_s)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_velocity_tolerance (deg_per_s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/num_loops_homed", + "type": "int", + "value": 7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_speed", + "type": "double", + "value": -0.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/gains/k", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/gains/p", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/gains/d", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/gear_ratio", + "type": "double", + "value": 4.32, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Gains/kP", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 150.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 0.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/smart_current_limit (A)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/braking_p", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/pivot_tolerance (deg)", + "type": "double", + "value": 0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/pivot_home_offset (deg)", + "type": "double", + "value": -17.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/max_adjustment_rate (deg_per_s)", + "type": "double", + "value": 60.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/gear_ratio", + "type": "double", + "value": 2.084558823529412, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 60.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Gains/kP", + "type": "double", + "value": 0.047, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 110.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 0.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/DynamicFPID/smart_current_limit (A)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/DynamicFPID/braking_p", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/max_adjustment_rate (fps)", + "type": "double", + "value": 0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/telescope_tolerance (in)", + "type": "double", + "value": 0.25, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/gear_ratio", + "type": "double", + "value": 0.25, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Gains/kP", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/forward (in)", + "type": "double", + "value": 6.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/reverse (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -0.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/wrist_trim_increment (deg)", + "type": "double", + "value": 0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/manual_control_deadband", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/auto/post_shoot_wait (s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/auto/pre_shoot_wait (s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/teleop_shooter_height (in)", + "type": "double", + "value": 39.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/teleop_shooter_x (in)", + "type": "double", + "value": 4.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/auto_shooter_height (in)", + "type": "double", + "value": 21.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/auto_shooter_x (in)", + "type": "double", + "value": 13.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/trap/pivot_pull_target (deg)", + "type": "double", + "value": -10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/amp_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/amp_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/amp_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/intake_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/intake_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/intake_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/source_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/source_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/source_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/stow_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/stow_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/stow_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/shoot_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/auto_shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/auto_shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/auto_shoot_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/preclimb_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/preclimb_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/preclimb_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/prescore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/prescore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/prescore_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/trapscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/trapscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/trapscore_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/postscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/postscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/postscore_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/pass_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/pass_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/pass_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/using_vision_autos", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/default_is_red_side", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/can_bus_latency (ms)", + "type": "double", + "value": 20.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_height (in)", + "type": "double", + "value": 14.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_angle (deg)", + "type": "double", + "value": 37.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_y_offset (in)", + "type": "double", + "value": -10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_x_offset (in)", + "type": "double", + "value": -7.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot/start_coast_counter", + "type": "int", + "value": 500, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_max_speed (deg_per_s)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_dc_cut", + "type": "double", + "value": 1.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/Gains/kP", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Robot/start_coast_counter", + "type": "int", + "value": 500, + "properties": { + "persistent": true + } + } +] diff --git a/networktables.json.bck b/networktables.json.bck new file mode 100644 index 0000000..10bfd50 --- /dev/null +++ b/networktables.json.bck @@ -0,0 +1,2570 @@ +[ + { + "name": "/Preferences//drive_auto_origin_pt_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_origin_pt_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_travel_pt_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/five_piece_auto/pre_point_amt (ft)", + "type": "double", + "value": 2.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_x (in)", + "type": "double", + "value": 217.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_y (in)", + "type": "double", + "value": 49.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_origin_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_x (in)", + "type": "double", + "value": 217.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_y (in)", + "type": "double", + "value": 112.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_one_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_x (in)", + "type": "double", + "value": 160.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_y (in)", + "type": "double", + "value": 112.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_two_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_x (in)", + "type": "double", + "value": 274.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_y (in)", + "type": "double", + "value": 112.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_intake_three_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_x (in)", + "type": "double", + "value": 274.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_y (in)", + "type": "double", + "value": 180.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//five_piece_finish_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_origin_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_x (in)", + "type": "double", + "value": 214.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_y (in)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//drive_auto_pt_2_v_y (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_x (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_y (in)", + "type": "double", + "value": 120.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_deg (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_v_x (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences//testing_point_v_y (fps)", + "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_intake", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_shooter", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_wrist", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_pivot", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_telescope", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_leds", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_bracers_", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot_container/init_vision_", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/translation_deadband", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/steer_deadband", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/translation_exponent", + "type": "int", + "value": 1, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/steer_exponent", + "type": "int", + "value": 2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/trigger_threshold", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/driver/rumble_strength", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/operator/trigger_threshold", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/operator/rumble_strength", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/max_speed (fps)", + "type": "double", + "value": 14.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/close_drive_amp_max_speed (fps)", + "type": "double", + "value": 3.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/current_limit (A)", + "type": "double", + "value": 90.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/motor_stall_current (A)", + "type": "double", + "value": 366.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/braking_constant", + "type": "double", + "value": 0.15, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/ramp_rate_vx (fps)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/ramp_rate_vy (fps)", + "type": "double", + "value": 100.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/auto_max_speed (fps)", + "type": "double", + "value": 11.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/driver_speed_multiplier", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/slow_mode_percent", + "type": "double", + "value": 0.04, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/slow_omega_percent", + "type": "double", + "value": 0.12, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/pov_control_speed_", + "type": "double", + "value": 10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/velocity_error (fps)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/max_acceleration (fps_sq)", + "type": "double", + "value": 8.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/max_deceleration (fps_sq)", + "type": "double", + "value": 10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/extrapolation_distance (in)", + "type": "double", + "value": 8.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/angular_velocity_threshold (deg_per_s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/align_gains/p", + "type": "double", + "value": 3.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/align_gains/align_tolerance (in)", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/width (in)", + "type": "double", + "value": 21.75, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/height (in)", + "type": "double", + "value": 26.75, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/percent_max_omega", + "type": "double", + "value": 0.45, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/wheel_radius (in)", + "type": "double", + "value": 1.93, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/bearing_gains/p", + "type": "double", + "value": 8.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/bearing_gains/d", + "type": "double", + "value": -4.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/gear_ratio", + "type": "double", + "value": 0.14979852970587568, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Gains/kP", + "type": "double", + "value": 0.0002, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/drive_esc/Gains/kF", + "type": "double", + "value": 0.0001769, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/gear_ratio", + "type": "double", + "value": 16.8, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/default_brake_mode", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Gains/kP", + "type": "double", + "value": 0.12, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/steer_esc/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/smart_current_braking/smart_current_limit (A)", + "type": "double", + "value": 170.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/smart_current_braking/braking_p", + "type": "double", + "value": 0.45, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/cancoder_offset (deg)", + "type": "double", + "value": 3.23, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FL/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/cancoder_offset (deg)", + "type": "double", + "value": 140.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_FR/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/cancoder_offset (deg)", + "type": "double", + "value": 297.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BL/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/cancoder_offset (deg)", + "type": "double", + "value": 157.89, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/drivetrain/module_BR/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/base_intake_speed_ (fps)", + "type": "double", + "value": 2.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/intake_feed_speed_ (fps)", + "type": "double", + "value": 2.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/release_speed", + "type": "double", + "value": -0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/retract_speed", + "type": "double", + "value": -0.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/gear_ratio", + "type": "double", + "value": 0.11780972437500001, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Gains/kP", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Gains/kF", + "type": "double", + "value": 0.15, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/intake/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooter_speed (fps)", + "type": "double", + "value": 65.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooter_spin", + "type": "double", + "value": 0.33, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooting_exit_velocity", + "type": "double", + "value": 47.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/shooter_speed_tolerance", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/gear_ratio", + "type": "double", + "value": 1.2435470906250001, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/default_brake_mode", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Gains/kP", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Gains/kF", + "type": "double", + "value": 0.15, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/forward (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/reverse (ft)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/vFPID/smart_current_limit (A)", + "type": "double", + "value": 35.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/shooter/vFPID/braking_p", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/wrist_tolerance (deg)", + "type": "double", + "value": 1.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/home_offset_wrist (deg)", + "type": "double", + "value": -49.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/cg_offset_wrist (deg)", + "type": "double", + "value": 60.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/max_adjustment_rate (deg_per_s)", + "type": "double", + "value": 80.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_velocity_tolerance (deg_per_s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/num_loops_homed", + "type": "int", + "value": 7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_speed", + "type": "double", + "value": -0.2, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/gains/k", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/gains/p", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/gains/d", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/gear_ratio", + "type": "double", + "value": 4.32, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Gains/kP", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 150.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 0.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/smart_current_limit (A)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/braking_p", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/pivot_tolerance (deg)", + "type": "double", + "value": 0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/pivot_home_offset (deg)", + "type": "double", + "value": -17.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/max_adjustment_rate (deg_per_s)", + "type": "double", + "value": 60.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/gear_ratio", + "type": "double", + "value": 2.084558823529412, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 60.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Gains/kP", + "type": "double", + "value": 0.047, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/forward (deg)", + "type": "double", + "value": 110.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/reverse (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 0.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/DynamicFPID/smart_current_limit (A)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/pivot/DynamicFPID/braking_p", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/max_adjustment_rate (fps)", + "type": "double", + "value": 0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/telescope_tolerance (in)", + "type": "double", + "value": 0.25, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/invert", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/gear_ratio", + "type": "double", + "value": 0.25, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/default_brake_mode", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/CurrentLimiting/target_threshold (A)", + "type": "double", + "value": 40.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/CurrentLimiting/peak_time_threshold (ms)", + "type": "double", + "value": 200.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/ramp_time (s)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/use_ramp_rate", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/voltage_compensation (V)", + "type": "double", + "value": 16.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/auton_voltage_compensation (V)", + "type": "double", + "value": 12.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Gains/kP", + "type": "double", + "value": 0.3, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/forward (in)", + "type": "double", + "value": 6.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/reverse (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/use_position_limits", + "type": "boolean", + "value": true, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/peak_output_forward", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/telescope/Configs/HardLimits/peak_output_reverse", + "type": "double", + "value": -0.7, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/wrist_trim_increment (deg)", + "type": "double", + "value": 0.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/manual_control_deadband", + "type": "double", + "value": 0.05, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/auto/post_shoot_wait (s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/auto/pre_shoot_wait (s)", + "type": "double", + "value": 1.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/teleop_shooter_height (in)", + "type": "double", + "value": 39.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/teleop_shooter_x (in)", + "type": "double", + "value": 4.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/auto_shooter_height (in)", + "type": "double", + "value": 21.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/shooting/auto_shooter_x (in)", + "type": "double", + "value": 13.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/SuperStructure/trap/pivot_pull_target (deg)", + "type": "double", + "value": -10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/amp_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/amp_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/amp_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/intake_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/intake_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/intake_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/source_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/source_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/source_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/stow_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/stow_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/stow_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/shoot_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/auto_shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/auto_shoot_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/auto_shoot_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/preclimb_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/preclimb_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/preclimb_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/prescore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/prescore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/prescore_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/trapscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/trapscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/trapscore_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/postscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/postscore_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/postscore_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Pivot/pass_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Wrist/pass_position (deg)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Preferences/MotionTargets/Telescope/pass_position (in)", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/using_vision_autos", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/default_is_red_side", + "type": "boolean", + "value": false, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/can_bus_latency (ms)", + "type": "double", + "value": 20.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_height (in)", + "type": "double", + "value": 14.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_angle (deg)", + "type": "double", + "value": 37.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_y_offset (in)", + "type": "double", + "value": -10.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/vision/camera_x_offset (in)", + "type": "double", + "value": -7.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/robot/start_coast_counter", + "type": "int", + "value": 500, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_max_speed (deg_per_s)", + "type": "double", + "value": 30.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/homing_dc_cut", + "type": "double", + "value": 1.5, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/Gains/kP", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/Gains/kD", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/wrist/DynamicFPID/Gains/kF", + "type": "double", + "value": 0.0, + "properties": { + "persistent": true + } + }, + { + "name": "/Preferences/Robot/start_coast_counter", + "type": "int", + "value": 500, + "properties": { + "persistent": true + } + } +] diff --git a/simgui.json b/simgui.json index 8ad6101..43060a7 100644 --- a/simgui.json +++ b/simgui.json @@ -6,11 +6,6 @@ "open": true } }, - " Talon FX (v6)[4]": { - "header": { - "open": true - } - }, " Talon FX (v6)[5]": { "header": { "open": true diff --git a/src/deploy/autos/paths/drive_auto b/src/deploy/autos/paths/drive_auto new file mode 100644 index 0000000..0d07b52 --- /dev/null +++ b/src/deploy/autos/paths/drive_auto @@ -0,0 +1,2 @@ +P,217.5,80,0,0 +P,217.5,180,0,0 \ No newline at end of file diff --git a/src/deploy/autos/paths/fp_center_run b/src/deploy/autos/paths/fp_center_run new file mode 100644 index 0000000..4fa6c1b --- /dev/null +++ b/src/deploy/autos/paths/fp_center_run @@ -0,0 +1 @@ +P,217.5,112.0,0,0 \ No newline at end of file diff --git a/src/deploy/autos/paths/fp_home b/src/deploy/autos/paths/fp_home new file mode 100644 index 0000000..500982f --- /dev/null +++ b/src/deploy/autos/paths/fp_home @@ -0,0 +1 @@ +F,kPointBlank \ No newline at end of file diff --git a/src/deploy/autos/paths/fp_piece_one b/src/deploy/autos/paths/fp_piece_one new file mode 100644 index 0000000..b66b275 --- /dev/null +++ b/src/deploy/autos/paths/fp_piece_one @@ -0,0 +1 @@ +P,217.5,112,0,0 \ No newline at end of file diff --git a/src/deploy/autos/paths/fp_piece_three b/src/deploy/autos/paths/fp_piece_three new file mode 100644 index 0000000..b66b275 --- /dev/null +++ b/src/deploy/autos/paths/fp_piece_three @@ -0,0 +1 @@ +P,217.5,112,0,0 \ No newline at end of file diff --git a/src/deploy/autos/paths/fp_piece_two b/src/deploy/autos/paths/fp_piece_two new file mode 100644 index 0000000..b66b275 --- /dev/null +++ b/src/deploy/autos/paths/fp_piece_two @@ -0,0 +1 @@ +P,217.5,112,0,0 \ No newline at end of file diff --git a/src/deploy/autos/points.lst b/src/deploy/autos/points.lst new file mode 100644 index 0000000..b4c5a0b --- /dev/null +++ b/src/deploy/autos/points.lst @@ -0,0 +1,4 @@ +N,kOrigin,0,0,0,0 +N,kSpeaker,217.5,-4,0,0 +N,kAmp,0,0,90,0 +N,kPointBlank,217.5,49,0,0 \ No newline at end of file diff --git a/src/deploy/autos/scripts/drive_auto b/src/deploy/autos/scripts/drive_auto new file mode 100644 index 0000000..6f87d38 --- /dev/null +++ b/src/deploy/autos/scripts/drive_auto @@ -0,0 +1,3 @@ +0,0 +F,kPointBlank +PATH,drive_auto \ No newline at end of file diff --git a/src/deploy/autos/scripts/four_piece_auto b/src/deploy/autos/scripts/four_piece_auto new file mode 100644 index 0000000..e45a6d2 --- /dev/null +++ b/src/deploy/autos/scripts/four_piece_auto @@ -0,0 +1,21 @@ +0,2 +F,kPointBlank +ACT,auto_home +ACT,prep_shoot +ACT,shoot +ACT,deploy_intake +PATH,fp_piece_one +ACT,prep_shoot +PATH,fp_home +ACT,shoot +ACT,deploy_intake +PATH,fp_piece_two +ACT,prep_shoot +PATH,fp_home +ACT,shoot +ACT,deploy_intake +PATH,fp_piece_three +ACT,prep_shoot +PATH,fp_home +ACT,shoot +PATH,fp_center_run \ No newline at end of file diff --git a/src/deploy/info.txt b/src/deploy/info.txt deleted file mode 100644 index 6839539..0000000 --- a/src/deploy/info.txt +++ /dev/null @@ -1,4 +0,0 @@ -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. \ No newline at end of file diff --git a/src/frc846/cpp/frc846/ntinf/fstore.cc b/src/frc846/cpp/frc846/ntinf/fstore.cc index e16bf42..6b3d812 100644 --- a/src/frc846/cpp/frc846/ntinf/fstore.cc +++ b/src/frc846/cpp/frc846/ntinf/fstore.cc @@ -19,6 +19,9 @@ frc846::base::Loggable FunkyStore::fstore_loggable{"FunkyStore"}; bool FunkyStore::hasChanged = false; +std::map> + FunkyStore::prefs = {{"Default.int", 0.0}}; + std::string FunkyStore::variantToString( std::variant& variant) { return std::visit( @@ -75,11 +78,17 @@ std::string trim(const std::string& str) { return (start < end.base()) ? std::string(start, end.base()) : std::string(); } -std::map> - FunkyStore::prefs = {{"Default.int", 0.0}}; - bool FunkyStore::ContainsKey(std::string key) { - return (prefs.find(key) != prefs.end()); + if (!hasReadPrefs) { + return false; + } + try { + if (prefs.empty()) return false; + return (prefs.find(key) != prefs.end()); + } catch (const std::exception& exc) { + (void)exc; + } + return false; } void FunkyStore::SetDouble(std::string key, double val) { diff --git a/src/frc846/cpp/frc846/robot/GenericRobot.cc b/src/frc846/cpp/frc846/robot/GenericRobot.cc index eaa203f..00150a3 100644 --- a/src/frc846/cpp/frc846/robot/GenericRobot.cc +++ b/src/frc846/cpp/frc846/robot/GenericRobot.cc @@ -22,7 +22,7 @@ namespace frc846::robot { GenericRobot::GenericRobot(GenericRobotContainer* container) - : frc846::base::Loggable{"robot"}, generic_robot_container_{container} { + : frc846::base::Loggable{"Robot"}, generic_robot_container_{container} { next_loop_time_ = frc846::wpilib::CurrentFPGATime(); int32_t status = 0x00; @@ -119,10 +119,12 @@ void GenericRobot::StartCompetition() { loop.Clear(); } else if (mode == Mode::kAutonomous) { // Get and run selected auto command - auto_command_ = auto_chooser_.GetSelected(); + std::string option_name = auto_chooser_.GetSelected(); + auto_command_ = autos_[option_name]; if (auto_command_ != nullptr) { - Log("Running auto: {}", auto_command_->GetName()); + Log("Running auto: {}", option_name); + auto_command_->Schedule(); } else { Error("Auto command null!"); @@ -152,6 +154,8 @@ void GenericRobot::StartCompetition() { last_mode_ = mode; } + OnPeriodic(); + // Update subsystem readings generic_robot_container_->UpdateReadings(); @@ -195,12 +199,9 @@ void GenericRobot::VerifyHardware() { generic_robot_container_->VerifyHardware(); } -void GenericRobot::AddAutos(frc2::Command* defaultOption, - std::vector otherOptions) { - auto_chooser_.SetDefaultOption(defaultOption->GetName(), defaultOption); - for (auto option : otherOptions) { - auto_chooser_.AddOption(option->GetName(), option); - } +void GenericRobot::AddAuto(std::string name, frc2::Command* command) { + auto_chooser_.AddOption(name, name); + autos_[name] = command; frc::SmartDashboard::PutData(&auto_chooser_); frc::SmartDashboard::UpdateValues(); } diff --git a/src/frc846/cpp/frc846/swerve/follow_trajectory_command.cc b/src/frc846/cpp/frc846/swerve/follow_trajectory_command.cc index 2a5830f..0ab5325 100644 --- a/src/frc846/cpp/frc846/swerve/follow_trajectory_command.cc +++ b/src/frc846/cpp/frc846/swerve/follow_trajectory_command.cc @@ -3,39 +3,58 @@ namespace frc846::swerve { FollowTrajectoryCommand::FollowTrajectoryCommand( - RobotContainer& container, std::vector input_points) + RobotContainer& container, std::vector input_points, + int mirror) : frc846::robot::GenericCommand< RobotContainer, FollowTrajectoryCommand>{container, "follow_trajectory_command"}, - input_points_(input_points) { + input_points_(input_points), + mirror_(mirror) { AddRequirements({&container_.drivetrain_}); - - wtcalculator.setConstants({container_.drivetrain_.max_speed_.value(), - container_.drivetrain_.max_acceleration_.value(), - 2_in, 20_ms}); } void FollowTrajectoryCommand::OnInit() { + wtcalculator.setConstants({container_.drivetrain_.auto_max_speed_.value(), + container_.drivetrain_.max_acceleration_.value(), + container_.drivetrain_.max_deceleration_.value(), + container_.drivetrain_.max_speed_.value(), + 80_fps_sq, 80_fps_sq, 3_in, 20_ms}); + Log("Starting Trajectory"); - for (frc846::Waypoint i : input_points_) { - Log("points x{} y{} bearing {}", i.point[0], i.point[1], i.bearing); - } - Log("initial pose x{}, y{}, bearing {}", + Log("Initial pose x{}, y{}, Bearing {}", container_.drivetrain_.GetReadings().pose.point[0], container_.drivetrain_.GetReadings().pose.point[1], container_.drivetrain_.GetReadings().pose.bearing); - is_done_ = false; start_time_ = frc846::wpilib::CurrentFPGATime(); - input_points_.insert(input_points_.begin(), 1, - {container_.drivetrain_.GetReadings().pose}); + auto vision_readings = container_.vision_.GetReadings(); + auto dtpose = container_.drivetrain_.GetReadings().pose; + auto pose = + (container_.vision_.using_vision_autos_.value() + + ? frc846::math::FieldPoint{{vision_readings.x_pos, + vision_readings.y_pos}, + dtpose.bearing, + {dtpose.velocity[0], dtpose.velocity[1]}} + : dtpose); + + path_points_.clear(); + path_points_.push_back(pose); + for (auto x : input_points_) { + path_points_.push_back( + mirror_ == 0 ? x : (mirror_ == 1 ? x.mirror() : x.mirrorOnlyY())); + } + for (frc846::Waypoint i : path_points_) { + Log("Points x{} y{} Bearing {}", i.point[0], i.point[1], i.bearing); + } + + is_done_ = false; target_idx_ = 1; - if (input_points_.size() < 2) { - Error("trajectory size ({}) is less than 2 - ending!", - input_points_.size()); + if (path_points_.size() < 2) { + Error("Trajectory size ({}) is less than 2 - ending!", path_points_.size()); is_done_ = true; } } @@ -46,22 +65,38 @@ void FollowTrajectoryCommand::Periodic() { return; } + auto vision_readings = container_.vision_.GetReadings(); + auto dtpose = container_.drivetrain_.GetReadings().pose; + auto pose = + (container_.vision_.using_vision_autos_.value() + + ? frc846::math::FieldPoint{{vision_readings.x_pos, + vision_readings.y_pos}, + dtpose.bearing, + {dtpose.velocity[0], dtpose.velocity[1]}} + : dtpose); + frc846::swerve::WTCInput lpcinput{ - input_points_[target_idx_ - 1].point, - input_points_[target_idx_].point, - container_.drivetrain_.GetReadings().pose.point, - container_.drivetrain_.GetReadings().pose.bearing, - input_points_[target_idx_].bearing, - container_.drivetrain_.GetReadings().pose.velocity.magnitude(), - input_points_[target_idx_].velocity.magnitude()}; + path_points_[target_idx_ - 1].point, + path_points_[target_idx_].point, + pose.point, + pose.bearing, + path_points_[target_idx_].bearing, + pose.velocity.magnitude(), + path_points_[target_idx_].velocity.magnitude()}; frc846::swerve::WTCOutput lpcoutput = wtcalculator.calculate(lpcinput); if (lpcoutput.crossed_waypt) { + Log("Initial x{} y{}.", path_points_[target_idx_ - 1].point[0], + path_points_[target_idx_ - 1].point[1]); + Log("Target x{} y{}.", path_points_[target_idx_].point[0], + path_points_[target_idx_].point[1]); target_idx_++; - Log("Cross waypoint - now on {}/{}", target_idx_ + 1, input_points_.size()); + Log("Cross waypoint - now on {}/{}", target_idx_ + 1, path_points_.size()); + Log("Position x{} y{}", pose.point[0], pose.point[1]); - if (target_idx_ == input_points_.size()) { + if (target_idx_ == path_points_.size()) { Log("Done!"); is_done_ = true; return; @@ -72,8 +107,8 @@ void FollowTrajectoryCommand::Periodic() { target.v_x = lpcoutput.target_vel[0]; target.v_y = lpcoutput.target_vel[1]; target.translation_reference = DrivetrainTranslationReference::kField; - target.rotation = DrivetrainRotationPosition(lpcoutput.bearing); - target.control = kClosedLoop; + target.rotation = DrivetrainRotationVelocity(lpcoutput.rotational_vel); + target.control = kOpenLoop; container_.drivetrain_.SetTarget(target); } diff --git a/src/frc846/cpp/frc846/swerve/waypt_traversal_calculator.cc b/src/frc846/cpp/frc846/swerve/waypt_traversal_calculator.cc index d4d6f9b..917f56a 100644 --- a/src/frc846/cpp/frc846/swerve/waypt_traversal_calculator.cc +++ b/src/frc846/cpp/frc846/swerve/waypt_traversal_calculator.cc @@ -3,22 +3,22 @@ namespace frc846::swerve { bool WayptTraversalCalculator::HasCrossedWaypt(WTCInput input) { - auto disp_vec = (input.current_pos - input.start_pos); + auto full_disp_vec = (input.target_pos - input.start_pos); - auto target_vec = (input.target_pos - input.start_pos); + auto current_disp_vec = (input.current_pos - input.start_pos); - if (target_vec.magnitude() <= constants_.loc_tolerance) { + if (full_disp_vec.magnitude() <= constants_.loc_tolerance) { return true; } - return disp_vec.projectOntoAnother(target_vec).magnitude() >= - target_vec.magnitude(); + return current_disp_vec.magnitude() >= full_disp_vec.magnitude(); }; WTCOutput WayptTraversalCalculator::calculate(WTCInput input) { WTCOutput result{}; result.target_vel = {0.0_fps, 0.0_fps}; - result.bearing = 0_deg; + result.rotational_vel = units::degrees_per_second_t{0.0}; + result.crossed_waypt = false; auto delta_vec = (input.target_pos - input.current_pos); @@ -33,32 +33,52 @@ WTCOutput WayptTraversalCalculator::calculate(WTCInput input) { auto dir_vec = delta_vec.unit(); - units::second_t stopping_time = - units::math::abs(input.current_vel - input.target_vel) / - constants_.max_acceleration; - units::foot_t stopping_distance = - (input.current_vel + input.target_vel) / 2 * stopping_time; + if (delta_vec.magnitude() < 4 * constants_.loc_tolerance) { + dir_vec = prev_dir_vec; + } + + prev_dir_vec = dir_vec; - result.bearing = (input.target_bearing - input.current_bearing) * - constants_.loop_time / stopping_time; + units::second_t reach_time_min = + delta_vec.magnitude() / + units::math::abs(input.current_vel - input.target_vel); + units::feet_per_second_squared_t required_deceleration = + units::math::abs(input.current_vel - input.target_vel) / reach_time_min; - auto target_vel_mag = constants_.max_speed; + result.rotational_vel = + (input.target_bearing - input.current_bearing) / reach_time_min; - if (stopping_distance > delta_vec.magnitude() - constants_.loc_tolerance) { - target_vel_mag = - input.current_vel + (input.target_vel - input.current_vel) * - constants_.loop_time / stopping_time; + units::feet_per_second_squared_t target_acc{0.0}; + if (required_deceleration >= constants_.max_deceleration) { + target_acc = -required_deceleration; } else if (input.current_vel < constants_.max_speed) { - target_vel_mag = - input.current_vel + constants_.max_acceleration * constants_.loop_time; + target_acc = constants_.max_acceleration; } - target_vel_mag = units::math::min(target_vel_mag, constants_.max_speed); - result.target_vel = {dir_vec[0].to() * target_vel_mag, - dir_vec[1].to() * target_vel_mag}; + units::feet_per_second_t target_dc = + acceleration_to_dc(target_acc, input.current_vel); + + result.target_vel = {dir_vec[0].to() * target_dc, + dir_vec[1].to() * target_dc}; return result; } +units::feet_per_second_t WayptTraversalCalculator::acceleration_to_dc( + units::feet_per_second_squared_t acc, units::feet_per_second_t vel) { + double current_vel_pct = vel / constants_.true_max_spd; + + double acc_pct = acc / ((acc >= units::feet_per_second_squared_t(0.0)) + ? constants_.true_max_acc + : constants_.true_max_dec); + + double dc = current_vel_pct + acc_pct; + + if (dc <= 0.0) dc = 0.0; + + return units::math::min(constants_.true_max_spd, + dc * constants_.true_max_spd); +} + }; // namespace frc846::swerve \ No newline at end of file diff --git a/src/frc846/include/frc846/control/motion.h b/src/frc846/include/frc846/control/motion.h index e997d79..8454ca0 100644 --- a/src/frc846/include/frc846/control/motion.h +++ b/src/frc846/include/frc846/control/motion.h @@ -5,6 +5,8 @@ #include #include +#include + #include "config.h" #include "frc846/ntinf/pref.h" #include "frc846/util/share_tables.h" @@ -118,8 +120,8 @@ class BrakingPositionDyFPID { double error = target_pos_capped - current_pos.template to(); - double target_output = g.kF * prop_ff_function_(current_pos) + - g.kP * error + g.kD * current_velocity_percentage; + double target_output = (g.kF * prop_ff_function_(current_pos) + + g.kP * error + g.kD * current_velocity_percentage); return current_control_.calculate(current_velocity_percentage, target_output); diff --git a/src/frc846/include/frc846/math/fieldpoints.h b/src/frc846/include/frc846/math/fieldpoints.h index b8efe08..db89644 100644 --- a/src/frc846/include/frc846/math/fieldpoints.h +++ b/src/frc846/include/frc846/math/fieldpoints.h @@ -46,12 +46,19 @@ struct FieldPoint { class FieldPointPreference { public: + std::string name_; + FieldPointPreference(std::string name, FieldPoint backup) - : x{table_name_, name + "_x", backup.point[0]}, - y{table_name_, name + "_y", backup.point[1]}, - bearing{table_name_, name + "_deg", backup.bearing}, - v_x{table_name_, name + "_v_x", backup.velocity[0]}, - v_y{table_name_, name + "_v_y", backup.velocity[1]} {} + : name_{name}, + x{table_loggable_, name + "_x", backup.point[0]}, + y{table_loggable_, name + "_y", backup.point[1]}, + bearing{table_loggable_, name + "_deg", backup.bearing}, + v_x{table_loggable_, name + "_v_x", backup.velocity[0]}, + v_y{table_loggable_, name + "_v_y", backup.velocity[1]} {} + + ~FieldPointPreference() { + table_loggable_.Warn("FieldPointPreference destructor was called."); + } FieldPoint get() { return { @@ -65,7 +72,7 @@ class FieldPointPreference { frc846::ntinf::Pref v_x; frc846::ntinf::Pref v_y; - const std::string table_name_ = "Preferences/field_points"; + frc846::base::Loggable table_loggable_{"field_points_2"}; }; } // namespace frc846::math \ No newline at end of file diff --git a/src/frc846/include/frc846/ntinf/pref.h b/src/frc846/include/frc846/ntinf/pref.h index 80255f4..c08cd3d 100644 --- a/src/frc846/include/frc846/ntinf/pref.h +++ b/src/frc846/include/frc846/ntinf/pref.h @@ -22,17 +22,21 @@ class Pref { // Construct a new pref for a unit type with a fallback value. // // The pref name will be post-fixed with the unit (e.g. `length (in)`). - Pref(const frc846::base::Loggable& parent, std::string name, T fallback); - Pref(const frc846::base::Loggable& parent, std::string name); + Pref(frc846::base::Loggable& parent, std::string name, T fallback); + Pref(frc846::base::Loggable& parent, std::string name); - ~Pref() { pref_table_->RemoveListener(entry_listener_); } + ~Pref() { + parent_.Warn("Preference {} destructor was called.", f_ptr_.key_); + pref_table_->RemoveListener(entry_listener_); + } private: - Pref(const frc846::base::Loggable& parent, std::string name, T fallback, + Pref(frc846::base::Loggable& parent, std::string name, T fallback, std::function init, std::function set, std::function get) - : f_ptr_{frc846::base::Loggable::Join(parent.name(), name)} { + : parent_{parent}, + f_ptr_{frc846::base::Loggable::Join(parent.name(), name)} { FunkyStore::FP_HardReadPrefs(); // Full networktables key (parent name + pref name) auto full_key = frc846::base::Loggable::Join(parent.name(), name); @@ -62,6 +66,8 @@ class Pref { T value() const { return value_; } private: + frc846::base::Loggable& parent_; + T value_; NT_Listener entry_listener_; @@ -73,8 +79,7 @@ class Pref { }; template -Pref::Pref(const frc846::base::Loggable& parent, std::string name, - U fallback) +Pref::Pref(frc846::base::Loggable& parent, std::string name, U fallback) : Pref{parent, fmt::format("{} ({})", name, units::abbreviation(units::make_unit(0))), @@ -94,11 +99,11 @@ Pref::Pref(const frc846::base::Loggable& parent, std::string name, } template -Pref::Pref(const frc846::base::Loggable& parent, std::string name) +Pref::Pref(frc846::base::Loggable& parent, std::string name) : Pref{parent, name, units::abbreviation(units::make_unit(0))} {} template <> -inline Pref::Pref(const frc846::base::Loggable& parent, std::string name, +inline Pref::Pref(frc846::base::Loggable& parent, std::string name, bool fallback) : Pref{ parent, @@ -114,12 +119,12 @@ inline Pref::Pref(const frc846::base::Loggable& parent, std::string name, } {} template <> -inline Pref::Pref(const frc846::base::Loggable& parent, std::string name) +inline Pref::Pref(frc846::base::Loggable& parent, std::string name) : Pref{parent, name, false} {} template <> -inline Pref::Pref(const frc846::base::Loggable& parent, - std::string name, double fallback) +inline Pref::Pref(frc846::base::Loggable& parent, std::string name, + double fallback) : Pref{ parent, name, @@ -134,12 +139,11 @@ inline Pref::Pref(const frc846::base::Loggable& parent, } {} template <> -inline Pref::Pref(const frc846::base::Loggable& parent, - std::string name) +inline Pref::Pref(frc846::base::Loggable& parent, std::string name) : Pref{parent, name, 0.0} {} template <> -inline Pref::Pref(const frc846::base::Loggable& parent, std::string name, +inline Pref::Pref(frc846::base::Loggable& parent, std::string name, int fallback) : Pref{ parent, @@ -155,12 +159,12 @@ inline Pref::Pref(const frc846::base::Loggable& parent, std::string name, } {} template <> -inline Pref::Pref(const frc846::base::Loggable& parent, std::string name) +inline Pref::Pref(frc846::base::Loggable& parent, std::string name) : Pref{parent, name, 0} {} template <> -inline Pref::Pref(const frc846::base::Loggable& parent, - std::string name, std::string fallback) +inline Pref::Pref(frc846::base::Loggable& parent, std::string name, + std::string fallback) : Pref{ parent, name, diff --git a/src/frc846/include/frc846/robot/GenericCommand.h b/src/frc846/include/frc846/robot/GenericCommand.h index 4bb7b66..1812a5a 100644 --- a/src/frc846/include/frc846/robot/GenericCommand.h +++ b/src/frc846/include/frc846/robot/GenericCommand.h @@ -91,19 +91,10 @@ class GenericCommandGroup : Loggable{name}, container_{container} { frc2::Command::SetName(name); - // auto start_command_added = frc2::InstantCommand([&] { - // Log("Command group {} starting.", name); - // command_start_time_ = frc846::wpilib::CurrentFPGATime(); - // }); - // auto end_command_added = frc2::InstantCommand([&] { - // units::millisecond_t elapsed_time = - // frc846::wpilib::CurrentFPGATime() - command_start_time_; - // Log("Command group {} ending. Took {} ms to complete.", name, - // elapsed_time.to()); - // }); - + frc2::SequentialCommandGroup::AddCommands(start_command_addition); frc2::SequentialCommandGroup::AddCommands( std::forward(commands)...); + frc2::SequentialCommandGroup::AddCommands(end_command_addition); Log("Constructing instance of command group {}.", name); } @@ -111,6 +102,17 @@ class GenericCommandGroup protected: RobotContainer& container_; units::millisecond_t command_start_time_ = 0.0_ms; + + private: + frc2::InstantCommand end_command_addition{[&] { + Log("Command group ending. Took {} ms to complete.", + (frc846::wpilib::CurrentFPGATime() - command_start_time_).to()); + }}; + + frc2::InstantCommand start_command_addition{[&] { + Log("Command group starting."); + command_start_time_ = frc846::wpilib::CurrentFPGATime(); + }}; }; }; // namespace frc846::robot diff --git a/src/frc846/include/frc846/robot/GenericRobot.h b/src/frc846/include/frc846/robot/GenericRobot.h index a8b09b3..6980a34 100644 --- a/src/frc846/include/frc846/robot/GenericRobot.h +++ b/src/frc846/include/frc846/robot/GenericRobot.h @@ -38,8 +38,7 @@ class GenericRobot : public frc::RobotBase, public frc846::base::Loggable { void VerifyHardware(); - void AddAutos(frc2::Command* defaultOption, - std::vector otherOptions); + void AddAuto(std::string name, frc2::Command* command); private: hal::Handle notifier_; @@ -60,7 +59,8 @@ class GenericRobot : public frc::RobotBase, public frc846::base::Loggable { "loop_time"}; frc2::Command* auto_command_ = nullptr; - frc::SendableChooser auto_chooser_; + frc::SendableChooser auto_chooser_; + std::unordered_map autos_; frc846::ntinf::FunkyStore robotStore{}; }; diff --git a/src/frc846/include/frc846/swerve/follow_trajectory_command.h b/src/frc846/include/frc846/swerve/follow_trajectory_command.h index 58f4215..86173a1 100644 --- a/src/frc846/include/frc846/swerve/follow_trajectory_command.h +++ b/src/frc846/include/frc846/swerve/follow_trajectory_command.h @@ -11,7 +11,8 @@ class FollowTrajectoryCommand FollowTrajectoryCommand> { public: FollowTrajectoryCommand(RobotContainer& container, - std::vector input_points); + std::vector input_points, + int mirror = 0); void OnInit() override; @@ -23,8 +24,11 @@ class FollowTrajectoryCommand private: std::vector input_points_; + std::vector path_points_{}; unsigned int target_idx_; + int mirror_; + bool is_done_ = false; units::second_t start_time_; diff --git a/src/frc846/include/frc846/swerve/waypt_traversal_calculator.h b/src/frc846/include/frc846/swerve/waypt_traversal_calculator.h index 4d84dc1..81d77b0 100644 --- a/src/frc846/include/frc846/swerve/waypt_traversal_calculator.h +++ b/src/frc846/include/frc846/swerve/waypt_traversal_calculator.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -30,13 +31,18 @@ struct WTCInput { struct WTCOutput { bool crossed_waypt; - units::degree_t bearing; + units::degrees_per_second_t rotational_vel; frc846::math::VectorND target_vel; }; struct WTCConstants { units::feet_per_second_t max_speed; units::feet_per_second_squared_t max_acceleration; + units::feet_per_second_squared_t max_deceleration; + + units::feet_per_second_t true_max_spd; + units::feet_per_second_squared_t true_max_acc; + units::feet_per_second_squared_t true_max_dec; units::inch_t loc_tolerance; @@ -49,6 +55,12 @@ class WayptTraversalCalculator bool HasCrossedWaypt(WTCInput input); WTCOutput calculate(WTCInput input) override; + + private: + units::feet_per_second_t acceleration_to_dc( + units::feet_per_second_squared_t acc, units::feet_per_second_t vel); + + frc846::math::VectorND prev_dir_vec; }; }; // namespace frc846::swerve \ No newline at end of file diff --git a/src/test/cpp/arch/swerve/waypt_traversal_calculator_test.cpp b/src/test/cpp/arch/swerve/waypt_traversal_calculator_test.cpp new file mode 100644 index 0000000..7aae025 --- /dev/null +++ b/src/test/cpp/arch/swerve/waypt_traversal_calculator_test.cpp @@ -0,0 +1,145 @@ +#include "frc846/swerve/waypt_traversal_calculator.h" + +#include "gtest/gtest.h" + +class WayptTraversalCalculatorTest : public ::testing::Test { + protected: + frc846::swerve::WTCConstants constants_; + WayptTraversalCalculatorTest() + : calculator_{}, + constants_{13.0_fps, 16.0_fps_sq, 16.0_fps_sq, 15.0_fps, + 100.0_fps_sq, 100.0_fps_sq, 3.0_in, 20_ms} { + calculator_.setConstants(constants_); + } + + frc846::swerve::WayptTraversalCalculator calculator_; +}; + +TEST_F(WayptTraversalCalculatorTest, HasCrossedWaypt) { + frc846::swerve::WTCInput input{{0.0_ft, 0.0_ft}, + {10.0_ft, 0.0_ft}, + {0.0_ft, 0.0_ft}, + 0_deg, + 0_deg, + 0.0_fps, + 0.0_fps}; + + EXPECT_FALSE(calculator_.HasCrossedWaypt(input)); + + input.current_pos = {5.0_ft, 0.0_ft}; + + EXPECT_FALSE(calculator_.HasCrossedWaypt(input)); + + input.current_pos = {10.0_ft, 0.0_ft}; + + EXPECT_TRUE(calculator_.HasCrossedWaypt(input)); + + input.current_pos = {14.0_ft, 0.0_ft}; + + EXPECT_TRUE(calculator_.HasCrossedWaypt(input)); +} + +TEST_F(WayptTraversalCalculatorTest, ReqsDecel) { + frc846::swerve::WTCInput input{{0.0_ft, 0.0_ft}, + {10.0_ft, 0.0_ft}, + {0.0_ft, 0.0_ft}, + 0_deg, + 0_deg, + 10.0_fps, + 0.0_fps}; + + frc846::swerve::WTCOutput output = calculator_.calculate(input); + + EXPECT_TRUE(output.target_vel.magnitude() > 10.0_fps); + + input.current_pos = {9.0_ft, 0.0_ft}; + + output = calculator_.calculate(input); + + EXPECT_TRUE(output.target_vel.magnitude() < 10.0_fps); +} + +TEST_F(WayptTraversalCalculatorTest, ReqsAccel) { + frc846::swerve::WTCInput input{{0.0_ft, 0.0_ft}, + {10.0_ft, 0.0_ft}, + {0.0_ft, 0.0_ft}, + 0_deg, + 0_deg, + 2.0_fps, + 0.0_fps}; + + frc846::swerve::WTCOutput output = calculator_.calculate(input); + + EXPECT_TRUE(output.target_vel.magnitude() > 2.0_fps); + + input.current_pos = {5.0_ft, 0.0_ft}; + + output = calculator_.calculate(input); + + EXPECT_TRUE(output.target_vel.magnitude() > 2.0_fps); + + input.current_vel = 4.0_fps; + input.current_pos = {9.5_ft, 0.0_ft}; + + output = calculator_.calculate(input); + + EXPECT_FALSE(output.target_vel.magnitude() > 2.0_fps); +} + +TEST_F(WayptTraversalCalculatorTest, FullPathFakeTest) { + frc846::swerve::WTCInput input{{0.0_ft, 0.0_ft}, + {10.0_ft, 0.0_ft}, + {0.0_ft, 0.0_ft}, + 0_deg, + 0_deg, + 0.0_fps, + 0.0_fps}; + + std::cout << "\n-----------------------------------" << std::endl; + std::cout << "Starting test [FullPathFakeTest]\n" << std::endl; + + auto loop_time = 0.02_s; + + auto total_time = 0.0_s; + + for (int i{0}; i <= 100; i++) { + auto output = calculator_.calculate(input); + + double current_dc = input.current_vel / constants_.true_max_spd; + double target_dc = output.target_vel.magnitude() / constants_.true_max_spd; + + double acc_dc = (target_dc - current_dc); + auto acc = acc_dc * + (acc_dc > 0 ? constants_.true_max_acc : constants_.true_max_dec); + + if (output.crossed_waypt) { + std::cout << "\nReached waypoint\n" << std::endl; + break; + } + + auto delta_vec_unit = (input.target_pos - input.current_pos).unit(); + auto est_vel = (input.current_vel + acc * loop_time); + + frc846::math::VectorND est_vel_vec{ + est_vel * delta_vec_unit[0].to(), + est_vel * delta_vec_unit[1].to()}; + + input.current_vel = est_vel_vec.magnitude(); + + input.current_pos += + {est_vel_vec[0] * loop_time, est_vel_vec[1] * loop_time}; + + total_time += loop_time; + + std::cout << "Time [" << total_time.to() << "] - Position [" + << input.current_pos[0].to() << ", " + << input.current_pos[1].to() << "]"; + std::cout << " - Velocity [" << est_vel_vec[0].to() << ", " + << est_vel_vec[1].to() << "]" << std::endl; + } + + std::cout << "End of test [FullPathFakeTest]" << std::endl; + std::cout << "-----------------------------------\n" << std::endl; + + EXPECT_TRUE(true); +} \ No newline at end of file diff --git a/src/test/cpp/main.cpp b/src/test/cpp/main.cpp new file mode 100644 index 0000000..0ec960c --- /dev/null +++ b/src/test/cpp/main.cpp @@ -0,0 +1,10 @@ +#include + +#include "gtest/gtest.h" + +int main(int argc, char** argv) { + HAL_Initialize(500, 0); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; +} \ No newline at end of file diff --git a/src/y2024/cpp/FunkyRobot.cc b/src/y2024/cpp/FunkyRobot.cc index dbbc297..223f6d9 100644 --- a/src/y2024/cpp/FunkyRobot.cc +++ b/src/y2024/cpp/FunkyRobot.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -22,12 +23,23 @@ #include "commands/teleop/operator_control.h" #include "commands/teleop/stow_command.h" #include "control_triggers.h" +#include "field.h" #include "frc846/ntinf/ntaction.h" #include "frc846/swerve/follow_trajectory_command.h" +#include "rsighandler.h" FunkyRobot::FunkyRobot() : GenericRobot{&container_} {} void FunkyRobot::OnInitialize() { + Field::Setup(); + + for (auto x : Field::getAllAutoData()) { + Log("Adding Auto: {}", x.name + "_red"); + AddAuto(x.name + "_red", new GenericAuto{container_, x, false}); + Log("Adding Auto: {}", x.name + "_blue"); + AddAuto(x.name + "_blue", new GenericAuto{container_, x, true}); + } + // Add dashboard buttons frc::SmartDashboard::PutData( "zero_modules", new frc846::ntinf::NTAction( @@ -59,11 +71,6 @@ void FunkyRobot::OnInitialize() { container_.telescope_.Brake(); container_.wrist_.Brake(); })); - - AddAutos(five_piece_auto_red.get(), - {five_piece_auto_blue.get(), one_piece_auto_0.get(), - one_piece_auto_1.get(), one_piece_auto_2.get(), - one_piece_auto_3.get(), drive_auto_.get()}); } void FunkyRobot::OnDisable() { @@ -80,8 +87,7 @@ void FunkyRobot::InitTeleop() { container_.drivetrain_.SetDefaultCommand(DriveCommand{container_}); container_.control_input_.SetDefaultCommand( OperatorControlCommand{container_}); - container_.super_structure_.SetDefaultCommand( - StowZeroActionCommand{container_}); + container_.super_structure_.SetDefaultCommand(StowCommand{container_}); container_.intake_.SetDefaultCommand(IdleIntakeCommand{container_}); container_.shooter_.SetDefaultCommand(IdleShooterCommand{container_}); container_.bracer_.SetDefaultCommand(BracerCommand{container_}); @@ -95,20 +101,36 @@ void FunkyRobot::OnPeriodic() { if (homing_switch_.Get()) { container_.super_structure_.ZeroSubsystem(); + Log("Zeroing subsystems..."); } - if (coast_counter_ >= 1) { - coast_counter_--; - } else if (coast_counter_ == 0) { + if (frc846::wpilib::CurrentFPGATime() > stop_coast_time_) { container_.pivot_.Brake(); container_.wrist_.Brake(); container_.telescope_.Brake(); + + stop_coast_time_ = + frc846::wpilib::CurrentFPGATime() + + coasting_time_ + .value(); // To prevent Brake from being called each periodic + } else if (coasting_switch_.Get()) { container_.pivot_.Coast(); container_.wrist_.Coast(); container_.telescope_.Coast(); - coast_counter_ = start_coast_counter_.value(); + + stop_coast_time_ = + frc846::wpilib::CurrentFPGATime() + coasting_time_.value(); + + Log("Coasting subsystems..."); } } void FunkyRobot::InitTest() {} + +#ifndef RUNNING_FRC_TESTS +int main() { + // configureSignalHandlers(); + return frc::StartRobot(); +} +#endif \ No newline at end of file diff --git a/src/y2024/cpp/autos/ActionMaker.cc b/src/y2024/cpp/autos/ActionMaker.cc new file mode 100644 index 0000000..2f17d13 --- /dev/null +++ b/src/y2024/cpp/autos/ActionMaker.cc @@ -0,0 +1,20 @@ +#include "autos/ActionMaker.h" + +#include "commands/basic/auto_deploy_intake_command.h" +#include "commands/basic/auto_shoot_command.h" +#include "commands/basic/prepare_auto_shoot_command.h" +#include "commands/complex/home_during_auto_command.h" + +std::unique_ptr ActionMaker::GetAction( + std::string name, RobotContainer& container) { + if (name == "shoot") { + return std::make_unique(container); + } else if (name == "prep_shoot") { + return std::make_unique(container); + } else if (name == "deploy_intake") { + return std::make_unique(container); + } else if (name == "auto_home" || true) { + return std::make_unique(container); + } + return nullptr; +} \ No newline at end of file diff --git a/src/y2024/cpp/autos/GenericAuto.cc b/src/y2024/cpp/autos/GenericAuto.cc new file mode 100644 index 0000000..465ea13 --- /dev/null +++ b/src/y2024/cpp/autos/GenericAuto.cc @@ -0,0 +1,41 @@ +#include "autos/GenericAuto.h" + +#include + +#include "autos/ActionMaker.h" + +GenericAuto::GenericAuto(RobotContainer& container, AutoData data, + bool is_blue_side) + : frc846::robot::GenericCommandGroup{ + container, data.name, + frc2::SequentialCommandGroup{ + std::move(buildActionsGroup(data, container, is_blue_side))}} {} + +std::vector> GenericAuto::buildActionsGroup( + AutoData data, RobotContainer& container, bool is_blue_side) { + std::vector> cmds{}; + cmds.push_back(std::make_unique([&, auto_data = data] { + Log("Starting Auto: {}.", auto_data.name); + + int mirror = is_blue_side ? (int)auto_data.blue : (int)auto_data.red; + + auto start = mirror == 0 ? auto_data.start + : (mirror == 1 ? auto_data.start.mirror() + : auto_data.start.mirrorOnlyY()); + + container.drivetrain_.SetPoint(start.point); + container.drivetrain_.SetBearing(start.bearing); + })); + for (auto& action : data.actions) { + if (auto* action_name = std::get_if(&action)) { + cmds.push_back(ActionMaker::GetAction(*action_name, container)); + } else if (auto* fp = std::get_if>( + &action)) { + cmds.push_back(std::make_unique( + container, *fp, is_blue_side ? (int)data.blue : (int)data.red)); + } + } + + return cmds; +} \ No newline at end of file diff --git a/src/y2024/cpp/autos/drive_auto.cc b/src/y2024/cpp/autos/drive_auto.cc deleted file mode 100644 index 500365e..0000000 --- a/src/y2024/cpp/autos/drive_auto.cc +++ /dev/null @@ -1,27 +0,0 @@ -#include "autos/drive_auto.h" - -#include -#include -#include -#include - -#include "field.h" -#include "frc2/command/WaitCommand.h" -#include "frc2/command/WaitUntilCommand.h" -#include "frc846/swerve/follow_trajectory_command.h" - -DriveAuto::DriveAuto(RobotContainer& container) - : frc846::robot::GenericCommandGroup{ - container, "drive_auto", - frc2::SequentialCommandGroup{ - - frc2::InstantCommand{[&] { - auto pose_ = field::points.kTestingOrigin(); - container.drivetrain_.SetPoint(pose_.point); - container.drivetrain_.SetBearing(pose_.bearing); - }}, - frc846::swerve::FollowTrajectoryCommand{ - container, {field::points.kTestingPoint()}} - - }} {} \ No newline at end of file diff --git a/src/y2024/cpp/autos/five_piece_auto.cc b/src/y2024/cpp/autos/five_piece_auto.cc deleted file mode 100644 index d4ed87f..0000000 --- a/src/y2024/cpp/autos/five_piece_auto.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include "autos/five_piece_auto.h" - -#include -#include -#include -#include -#include -#include - -#include "commands/auto_intake_and_shoot_command.h" -#include "commands/basic/auto_shoot_command.h" -#include "commands/basic/prepare_auto_shoot_command.h" -#include "commands/basic/spin_up_command.h" -#include "commands/basic/wrist_zero_command.h" -#include "commands/teleop/stow_command.h" -#include "field.h" -#include "frc846/swerve/follow_trajectory_command.h" - -FivePieceAuto::FivePieceAuto(RobotContainer& container, bool should_flip) - : frc846::robot::GenericCommandGroup{ - container, should_flip ? "5p_auto_blue" : "5p_auto_red", - frc2::SequentialCommandGroup{ - - frc2::InstantCommand{[&, flip = should_flip] { - auto pose_ = field::points.kFivePieceOrigin(flip); - container.drivetrain_.SetPoint(pose_.point); - container.drivetrain_.SetBearing(flip ? 180_deg : 0_deg); - }}, - frc2::ParallelDeadlineGroup{ - frc2::ParallelDeadlineGroup{ - frc2::WaitUntilCommand{[&] { - return container_.pivot_.WithinTolerance( - container_.super_structure_.getStowSetpoint() - .pivot); /* homing wrist at start of auto */ - }}, - StowCommand{container}}, - SpinUpCommand{ - container}}, /* start to spin up shooter to save time */ - WristZeroCommand{container}, /* homing the wrist */ - PrepareAutoShootCommand{container}, AutoShootCommand{container}, - frc2::WaitCommand{ - container.super_structure_.post_shoot_wait_.value()}, - - AutoIntakeAndShootCommand( - container, field::points.intake_one_path(should_flip), - {field::points.kFivePieceOrigin(should_flip)}), - - AutoIntakeAndShootCommand( - container, field::points.intake_two_path(should_flip), - {field::points.kFivePieceOrigin(should_flip)}), - - AutoIntakeAndShootCommand( - container, field::points.intake_three_path(should_flip), - {field::points.kFivePieceOrigin(should_flip)}), - - frc846::swerve::FollowTrajectoryCommand( - container, {field::points.kFivePieceFinish(should_flip)})}} {} diff --git a/src/y2024/cpp/autos/one_piece.cc b/src/y2024/cpp/autos/one_piece.cc deleted file mode 100644 index e168ac3..0000000 --- a/src/y2024/cpp/autos/one_piece.cc +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - -#include "autos/one_piece_auto.h" -#include "commands/basic/auto_shoot_command.h" -#include "commands/basic/prepare_auto_shoot_command.h" -#include "frc2/command/WaitCommand.h" - -OnePieceAuto::OnePieceAuto(RobotContainer& container, - units::degree_t start_angle, std::string num) - : frc846::robot::GenericCommandGroup{ - container, "1p_auto_" + num, - frc2::SequentialCommandGroup{ - - // frc2::InstantCommand{[&, s = start_angle] { - // container.drivetrain_.SetBearing(s); - // Log("OP: Zeroing to {}", s.to()); - // }}, - // PrepareAutoShootCommand{container}, - // AutoShootCommand{container}, - // frc2::WaitCommand{ - // container.super_structure_.post_shoot_wait_.value()} - - }} {} diff --git a/src/y2024/cpp/commands/auto_intake_and_shoot_command.cc b/src/y2024/cpp/commands/auto_intake_and_shoot_command.cc index bd6a4f4..0e3794d 100644 --- a/src/y2024/cpp/commands/auto_intake_and_shoot_command.cc +++ b/src/y2024/cpp/commands/auto_intake_and_shoot_command.cc @@ -1,37 +1,37 @@ -#include "commands/auto_intake_and_shoot_command.h" +// #include "commands/auto_intake_and_shoot_command.h" -#include -#include -#include -#include +// #include +// #include +// #include +// #include -#include "commands/basic/auto_deploy_intake_command.h" -#include "commands/basic/auto_shoot_command.h" -#include "commands/basic/prepare_auto_shoot_command.h" -#include "field.h" -#include "frc2/command/WaitCommand.h" -#include "frc846/swerve/follow_trajectory_command.h" +// #include "commands/basic/auto_deploy_intake_command.h" +// #include "commands/basic/auto_shoot_command.h" +// #include "commands/basic/prepare_auto_shoot_command.h" +// #include "field.h" +// #include "frc2/command/WaitCommand.h" +// #include "frc846/swerve/follow_trajectory_command.h" -AutoIntakeAndShootCommand::AutoIntakeAndShootCommand( - RobotContainer& container, std::vector intake_path, - std::vector shoot_path) - : frc846::robot::GenericCommandGroup{ - container, "auto_intake_shoot_command", - frc2::SequentialCommandGroup{ +// AutoIntakeAndShootCommand::AutoIntakeAndShootCommand( +// RobotContainer& container, std::vector intake_path, +// std::vector shoot_path) +// : frc846::robot::GenericCommandGroup{ +// container, "auto_intake_shoot_command", +// frc2::SequentialCommandGroup{ - AutoDeployIntakeCommand{container}, - frc846::swerve::FollowTrajectoryCommand{container, intake_path}, - frc2::ParallelDeadlineGroup{ - frc2::SequentialCommandGroup{ - frc846::swerve::FollowTrajectoryCommand{container, - shoot_path}, - frc2::WaitCommand( - container.super_structure_.pre_shoot_wait_.value())}, - PrepareAutoShootCommand{container}}, - AutoShootCommand{container}, - frc2::WaitCommand( - container.super_structure_.post_shoot_wait_.value()) +// AutoDeployIntakeCommand{container}, +// frc846::swerve::FollowTrajectoryCommand{container, +// intake_path}, frc2::ParallelDeadlineGroup{ +// frc2::SequentialCommandGroup{ +// frc846::swerve::FollowTrajectoryCommand{container, +// shoot_path}, +// frc2::WaitCommand( +// container.super_structure_.pre_shoot_wait_.value())}, +// PrepareAutoShootCommand{container}}, +// AutoShootCommand{container}, +// frc2::WaitCommand( +// container.super_structure_.post_shoot_wait_.value()) - }} {} \ No newline at end of file +// }} {} \ No newline at end of file diff --git a/src/y2024/cpp/commands/complex/close_drive_amp_command.cc b/src/y2024/cpp/commands/complex/close_drive_amp_command.cc index e6bf87f..5aee7d8 100644 --- a/src/y2024/cpp/commands/complex/close_drive_amp_command.cc +++ b/src/y2024/cpp/commands/complex/close_drive_amp_command.cc @@ -1,47 +1,49 @@ -#include "commands/complex/close_drive_amp_command.h" +// #include "commands/complex/close_drive_amp_command.h" -#include "field.h" +// #include "field.h" -CloseDriveAmpCommand::CloseDriveAmpCommand(RobotContainer& container) - : frc846::robot::GenericCommand{ - container, "close_drive_amp_command"} { - AddRequirements({&container_.drivetrain_}); -} +// CloseDriveAmpCommand::CloseDriveAmpCommand(RobotContainer& container) +// : frc846::robot::GenericCommand{ +// container, "close_drive_amp_command"} { +// AddRequirements({&container_.drivetrain_}); +// } -void CloseDriveAmpCommand::OnInit() {} +// void CloseDriveAmpCommand::OnInit() {} -void CloseDriveAmpCommand::Periodic() { - auto amp_point = field::points.kAmpNoFlip(); +// void CloseDriveAmpCommand::Periodic() { +// auto amp_point = field::points.kAmpNoFlip(); - DrivetrainTarget drivetrain_target; - drivetrain_target.rotation = DrivetrainRotationPosition(amp_point.bearing); - drivetrain_target.translation_reference = kField; - drivetrain_target.control = kClosedLoop; +// DrivetrainTarget drivetrain_target; +// drivetrain_target.rotation = DrivetrainRotationPosition(amp_point.bearing); +// drivetrain_target.translation_reference = kField; +// drivetrain_target.control = kClosedLoop; - auto amp_drive_dist = - (field::points.kPreAmpNoFlip().point - amp_point.point).magnitude(); +// auto amp_drive_dist = +// (field::points.kPreAmpNoFlip().point - amp_point.point).magnitude(); - auto max_speed = container_.drivetrain_.close_drive_amp_max_speed_.value(); +// auto max_speed = container_.drivetrain_.close_drive_amp_max_speed_.value(); - drivetrain_target.v_x = (amp_point.point[0] - - container_.drivetrain_.GetReadings().pose.point[0]) / - amp_drive_dist * max_speed; - drivetrain_target.v_y = (amp_point.point[1] - - container_.drivetrain_.GetReadings().pose.point[1]) / - amp_drive_dist * max_speed; +// drivetrain_target.v_x = (amp_point.point[0] - +// container_.drivetrain_.GetReadings().pose.point[0]) +// / +// amp_drive_dist * max_speed; +// drivetrain_target.v_y = (amp_point.point[1] - +// container_.drivetrain_.GetReadings().pose.point[1]) +// / +// amp_drive_dist * max_speed; - drivetrain_target.v_x = units::math::max( - -max_speed, units::math::min(max_speed, drivetrain_target.v_x)); - drivetrain_target.v_y = units::math::max( - -max_speed, units::math::min(max_speed, drivetrain_target.v_y)); +// drivetrain_target.v_x = units::math::max( +// -max_speed, units::math::min(max_speed, drivetrain_target.v_x)); +// drivetrain_target.v_y = units::math::max( +// -max_speed, units::math::min(max_speed, drivetrain_target.v_y)); - container_.drivetrain_.SetTarget(drivetrain_target); -} +// container_.drivetrain_.SetTarget(drivetrain_target); +// } -void CloseDriveAmpCommand::OnEnd(bool interrupted) {} +// void CloseDriveAmpCommand::OnEnd(bool interrupted) {} -bool CloseDriveAmpCommand::IsFinished() { - return (field::points.kAmpNoFlip().point - - container_.drivetrain_.GetReadings().pose.point) - .magnitude() <= 2_in; -} \ No newline at end of file +// bool CloseDriveAmpCommand::IsFinished() { +// return (field::points.kAmpNoFlip().point - +// container_.drivetrain_.GetReadings().pose.point) +// .magnitude() <= 2_in; +// } \ No newline at end of file diff --git a/src/y2024/cpp/commands/complex/home_during_auto_command.cc b/src/y2024/cpp/commands/complex/home_during_auto_command.cc new file mode 100644 index 0000000..1382317 --- /dev/null +++ b/src/y2024/cpp/commands/complex/home_during_auto_command.cc @@ -0,0 +1,25 @@ +#include "commands/complex/home_during_auto_command.h" + +#include +#include +#include +#include + +#include "commands/basic/wrist_zero_command.h" +#include "commands/teleop/stow_command.h" +#include "frc2/command/WaitCommand.h" +#include "frc2/command/WaitUntilCommand.h" + +HomeDuringAutoCommand::HomeDuringAutoCommand(RobotContainer& container) + : frc846::robot::GenericCommandGroup{ + container, "home_during_auto_command", + frc2::SequentialCommandGroup{ + frc2::ParallelDeadlineGroup{ + frc2::WaitUntilCommand{[&] { + return container.pivot_.WithinTolerance( + container.super_structure_.getStowSetpoint().pivot); + }}, + StowCommand{container}}, + WristZeroCommand{container}, + }} {} \ No newline at end of file diff --git a/src/y2024/cpp/commands/complex/stow_zero_action.cc b/src/y2024/cpp/commands/complex/stow_zero_action.cc index 621b182..dc86219 100644 --- a/src/y2024/cpp/commands/complex/stow_zero_action.cc +++ b/src/y2024/cpp/commands/complex/stow_zero_action.cc @@ -13,7 +13,7 @@ StowZeroActionCommand::StowZeroActionCommand(RobotContainer& container) : frc846::robot::GenericCommandGroup{ - container, "super_amp_command", + container, "stow_zero_action_command", frc2::SequentialCommandGroup{ frc2::ParallelDeadlineGroup{ frc2::WaitUntilCommand{[&] { diff --git a/src/y2024/cpp/commands/complex/super_amp_command.cc b/src/y2024/cpp/commands/complex/super_amp_command.cc index ef771bc..8a81961 100644 --- a/src/y2024/cpp/commands/complex/super_amp_command.cc +++ b/src/y2024/cpp/commands/complex/super_amp_command.cc @@ -1,40 +1,40 @@ -#include "commands/complex/super_amp_command.h" +// #include "commands/complex/super_amp_command.h" -#include -#include -#include -#include +// #include +// #include +// #include +// #include -#include "commands/basic/amp_command.h" -#include "commands/basic/await_piece_state_command.h" -#include "commands/basic/eject_command.h" -#include "commands/basic/pull_command.h" -#include "commands/complex/close_drive_amp_command.h" -#include "field.h" -#include "frc2/command/WaitCommand.h" -#include "frc2/command/WaitUntilCommand.h" -#include "frc846/swerve/follow_trajectory_command.h" +// #include "commands/basic/amp_command.h" +// #include "commands/basic/await_piece_state_command.h" +// #include "commands/basic/eject_command.h" +// #include "commands/basic/pull_command.h" +// #include "commands/complex/close_drive_amp_command.h" +// #include "field.h" +// #include "frc2/command/WaitCommand.h" +// #include "frc2/command/WaitUntilCommand.h" +// #include "frc846/swerve/follow_trajectory_command.h" -SuperAmpCommand::SuperAmpCommand(RobotContainer& container, bool is_red_side) - : frc846::robot::GenericCommandGroup{ - container, "super_amp_command", - frc2::SequentialCommandGroup{ +// SuperAmpCommand::SuperAmpCommand(RobotContainer& container, bool is_red_side) +// : frc846::robot::GenericCommandGroup{ +// container, "super_amp_command", +// frc2::SequentialCommandGroup{ - frc2::ParallelDeadlineGroup{frc2::WaitCommand{1_s}, - PullCommand{container}}, - frc2::ParallelDeadlineGroup{ - frc2::SequentialCommandGroup{ - frc846::swerve::FollowTrajectoryCommand{ - container, {{field::points.kPreAmpNoFlip()}}}, - CloseDriveAmpCommand{container}, - frc2::ParallelDeadlineGroup{ - frc2::SequentialCommandGroup{ - AwaitPieceStateCommand{container, false}, - frc2::WaitCommand{0.5_s}, - }, - EjectCommand{container}}, - }, - AmpCommand{container}}, - frc846::swerve::FollowTrajectoryCommand{ - container, {{field::points.kPreAmpNoFlip()}}}}} {} \ No newline at end of file +// frc2::ParallelDeadlineGroup{frc2::WaitCommand{1_s}, +// PullCommand{container}}, +// frc2::ParallelDeadlineGroup{ +// frc2::SequentialCommandGroup{ +// frc846::swerve::FollowTrajectoryCommand{ +// container, {{field::points.kPreAmpNoFlip()}}}, +// CloseDriveAmpCommand{container}, +// frc2::ParallelDeadlineGroup{ +// frc2::SequentialCommandGroup{ +// AwaitPieceStateCommand{container, false}, +// frc2::WaitCommand{0.5_s}, +// }, +// EjectCommand{container}}, +// }, +// AmpCommand{container}}, +// frc846::swerve::FollowTrajectoryCommand{ +// container, {{field::points.kPreAmpNoFlip()}}}}} {} \ No newline at end of file diff --git a/src/y2024/cpp/commands/teleop/drive_command.cc b/src/y2024/cpp/commands/teleop/drive_command.cc index 7077c3e..514cb3b 100644 --- a/src/y2024/cpp/commands/teleop/drive_command.cc +++ b/src/y2024/cpp/commands/teleop/drive_command.cc @@ -2,7 +2,6 @@ #include -#include "field.h" #include "frc846/base/loggable.h" #include "frc846/math/collection.h" #include "frc846/util/share_tables.h" diff --git a/src/y2024/cpp/control_triggers.cc b/src/y2024/cpp/control_triggers.cc index da24e6c..fec4c76 100644 --- a/src/y2024/cpp/control_triggers.cc +++ b/src/y2024/cpp/control_triggers.cc @@ -15,7 +15,6 @@ #include "commands/basic/spin_up_command.h" #include "commands/basic/trap_command.h" #include "commands/basic/wrist_zero_command.h" -#include "commands/complex/super_amp_command.h" void ControlTriggerInitializer::InitTeleopTriggers(RobotContainer& container) { frc2::Trigger drivetrain_zero_bearing_trigger{ @@ -60,17 +59,18 @@ void ControlTriggerInitializer::InitTeleopTriggers(RobotContainer& container) { amp_command_trigger.WhileTrue(AmpCommand{container}.ToPtr()); - frc2::Trigger super_amp_trigger_red{[&container] { - return container.control_input_.GetReadings().running_super_amp && - frc846::util::ShareTables::GetBoolean("is_red_side"); - }}; - frc2::Trigger super_amp_trigger_blue{[&container] { - return container.control_input_.GetReadings().running_super_amp && - !frc846::util::ShareTables::GetBoolean("is_red_side"); - }}; - - super_amp_trigger_red.WhileTrue(SuperAmpCommand{container, true}.ToPtr()); - super_amp_trigger_blue.WhileTrue(SuperAmpCommand{container, false}.ToPtr()); + // frc2::Trigger super_amp_trigger_red{[&container] { + // return container.control_input_.GetReadings().running_super_amp && + // frc846::util::ShareTables::GetBoolean("is_red_side"); + // }}; + // frc2::Trigger super_amp_trigger_blue{[&container] { + // return container.control_input_.GetReadings().running_super_amp && + // !frc846::util::ShareTables::GetBoolean("is_red_side"); + // }}; + + // super_amp_trigger_red.WhileTrue(SuperAmpCommand{container, true}.ToPtr()); + // super_amp_trigger_blue.WhileTrue(SuperAmpCommand{container, + // false}.ToPtr()); frc2::Trigger intake_command_trigger{[&container] { return container.control_input_.GetReadings().running_intake; diff --git a/src/y2024/cpp/field.cc b/src/y2024/cpp/field.cc index 9f40fed..c55b027 100644 --- a/src/y2024/cpp/field.cc +++ b/src/y2024/cpp/field.cc @@ -1,3 +1,242 @@ #include "field.h" -field::points_cls field::points{}; \ No newline at end of file +#include + +#include + +frc846::math::FieldPoint Field_nonstatic::getPoint(std::string name) { + if (!points.empty()) { + for (auto& point : points) { + if (point.first == name) { + return point.second; + } + } + } + Warn("Unable to access fieldpoint: {}.", name); + return frc846::math::FieldPoint{{0_in, 0_in}, 0_deg, {0_fps, 0_fps}}; +} + +std::vector Field_nonstatic::getPath( + std::string name) { + for (auto& path : paths) { + if (path.first == name) { + return path.second; + } + } + Warn("Unable to access path: {}.", name); + return {}; +} + +std::vector Field_nonstatic::split(const std::string& s, + char delimiter) { + std::vector tokens; + std::string token; + std::istringstream tokenStream(s); + while (std::getline(tokenStream, token, delimiter)) { + tokens.push_back(token); + } + return tokens; +} + +std::vector Field_nonstatic::readLines(std::string filename) { + std::ifstream file; + file.open(filename); + + std::vector lines{}; + + std::string content_string; + while (file.good()) { + file >> content_string; + lines.push_back(content_string); + } + + return lines; +} + +std::string Field_nonstatic::fixPath(std::string path) { +#ifdef _WIN32 + for (char& ch : path) { + if (ch == '/') { + ch = '\\'; + } + } + return path; +#else + for (char& ch : path) { + if (ch == '\\') { + ch = '/'; + } + } + return path; +#endif +} + +std::string Field_nonstatic::forceNormalPath(std::string path) { + for (char& ch : path) { + if (ch == '\\') { + ch = '/'; + } + } + return path; +} + +std::string Field_nonstatic::getFileDirectory() { +#ifdef _WIN32 + std::string deploy_dir = frc::filesystem::GetDeployDirectory(); + size_t start_pos = 0; + + std::vector tokens = split(deploy_dir, '\\'); + std::string rejoined{}; + for (size_t i = 0; i < tokens.size(); i++) { + if (tokens[i] != "main") { + rejoined += tokens[i]; + rejoined += "/"; + } + } + + return fixPath(rejoined + "autos/"); + +#else + + return "/home/lvuser/deploy/autos/"; +#endif +} + +frc846::math::FieldPoint Field_nonstatic::parsePoint(std::string line) { + frc846::math::FieldPoint pt{{0_in, 0_in}, 0_deg, {0_fps, 0_fps}}; + + auto tokens = split(line, ','); + if (tokens.size() != 0) { + if (tokens[0] == "N") { + auto v = 0_fps; + if (tokens.size() == 6) v = std::stod(tokens[5]) * 1_fps; + + pt = {{std::stod(tokens[2]) * 1_in, std::stod(tokens[3]) * 1_in}, + std::stod(tokens[4]) * 1_deg, + {v, 0_fps}}; + } else if (tokens[0] == "P") { + auto v = 0_fps; + if (tokens.size() == 5) v = std::stod(tokens[4]) * 1_fps; + + pt = {{std::stod(tokens[1]) * 1_in, std::stod(tokens[2]) * 1_in}, + std::stod(tokens[3]) * 1_deg, + {v, 0_fps}}; + } else if (tokens[0] == "F") { + if (tokens.size() == 2) { + pt = getPoint(tokens[1]); + } + } else { + Warn("Unable to parse point from raw: {}.", line); + } + } + return pt; +} + +void Field_nonstatic::readPointsFile() { + auto pts_us = readLines(Field_nonstatic::getFileDirectory() + "points.lst"); + + for (auto& pt : pts_us) { + auto tokens = split(pt, ','); + if (tokens.size() >= 2) { + addPoint(tokens[1], parsePoint(pt)); + Log("Added point: {}.", tokens[1]); + } else { + Warn("Invalid point: {}.", pt); + } + } +} + +void Field_nonstatic::readAllPaths() { + std::vector path_files; + try { + for (const auto& entry : std::filesystem::directory_iterator( + Field_nonstatic::getFileDirectory() + "paths")) { + if (entry.is_regular_file()) path_files.push_back(entry.path().string()); + Log("Found path file: {}.", entry.path().string()); + } + } catch (const std::exception& exc) { + (void)exc; + } + + for (const auto& filename : path_files) { + auto path_us = readLines(filename); + std::vector path; + for (auto& pt : path_us) { + path.push_back(parsePoint(pt)); + } + auto split_filename = split(forceNormalPath(filename), '/'); + + paths.push_back( + std::pair{split_filename.at(split_filename.size() - 1), path}); + Log("Added path: {}.", split_filename.at(split_filename.size() - 1)); + } +} + +Field_nonstatic::Field_nonstatic() : Loggable{"Field"}, points{}, paths{} {} + +void Field_nonstatic::Setup() { + readPointsFile(); + readAllPaths(); +}; + +std::vector Field_nonstatic::getAllAutoData() { + std::vector result; + + std::vector auto_files; + try { + for (const auto& entry : std::filesystem::directory_iterator( + Field_nonstatic::getFileDirectory() + "scripts")) { + if (entry.is_regular_file()) auto_files.push_back(entry.path().string()); + } + } catch (const std::exception& exc) { + (void)exc; + } + + for (const auto& filename : auto_files) { + auto auto_lines = readLines(filename); + + if (auto_lines.size() < 2) { + Warn("Invalid auto file: {}.", filename); + continue; + } + + auto flips = split(auto_lines[0], ','); + + AutoFlipType red = (AutoFlipType)std::stoi(flips[0]); + AutoFlipType blue = (AutoFlipType)std::stoi(flips[1]); + + auto start_point = parsePoint(auto_lines[1]); + + auto_lines.erase(auto_lines.begin(), auto_lines.begin() + 1); + + std::vector< + std::variant, std::string>> + actions; + + for (auto& line : auto_lines) { + auto split_line = split(line, ','); + if (split_line.size() != 2) { + Warn("Invalid auto action: {}.", line); + continue; + } + if (split_line[0] == "PATH") { + actions.push_back(getPath(split_line[1])); + } else if (split_line[0] == "ACT") { + actions.push_back(split_line[1]); + } + } + + Log("Added auto: {}.", filename); + + Log("Auto has {} actions.", actions.size()); + + auto split_filename = split(forceNormalPath(filename), '/'); + auto auto_name = split_filename.at(split_filename.size() - 1); + + result.push_back({auto_name, red, blue, start_point, actions}); + } + + return result; +} + +Field_nonstatic Field::instance{}; \ No newline at end of file diff --git a/src/y2024/cpp/main.cpp b/src/y2024/cpp/main.cpp deleted file mode 100644 index f92c0da..0000000 --- a/src/y2024/cpp/main.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include -#include -#include - -#include "FunkyRobot.h" - -// #include -// #include -// #include -// #include -// #include -// #include -// #include -#include -/* -inline void ltrim(std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { - return !std::isspace(ch); - })); -} - -inline void rtrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { - return !std::isspace(ch); - }).base(), s.end()); -} - -#define A 54059 -#define B 76963 -#define C 86969 -#define FIRSTH 37 -unsigned hash_str(const char* s) -{ - unsigned h = FIRSTH; - while (*s) { - h = (h * A) ^ (s[0] * B); - s++; - } - return h % C; -} - -void handler(int sig) { - std::map sigErrors; - - sigErrors[SIGFPE] = "FATAL ERROR >> Arithmetic Error, SIGFPE"; - sigErrors[SIGILL] = "FATAL ERROR >> Illegal Instruction, SIGILL"; - sigErrors[SIGSEGV] = "FATAL ERROR >> Illegal Memory Access, SIGSEGV"; - sigErrors[SIGBUS] = "FATAL ERROR >> Bus Error, SIGBUS"; - sigErrors[SIGABRT] = "FATAL ERROR >> Abort, SIGABRT"; - sigErrors[SIGSYS] = "FATAL ERROR >> Invalid system call, SIGSYS"; - sigErrors[SIGTRAP] = "FATAL ERROR >> Exception Occured, SIGTRAP"; - - void *callstack[24]; - - int frames = backtrace(callstack, 24); - - - std::cerr << "Backtrace:\n"; - char** symbols = backtrace_symbols(callstack, frames); - - if (symbols == nullptr) { - std::cerr << "Error obtaining backtrace symbols\n" << std::endl; - return; - } - - for (int i = 0; i < frames; ++i) { - std::cerr << symbols[i] << std::endl; - } - - if (sigErrors.contains(sig)) { - std::cerr << sigErrors[sig] << std::endl; - } else { - std::cerr << "? Unknown Exception Occured" << std::endl; - } - // exit(1); -}*/ - -int main() { - /*for (int i = 1; i < NSIG; ++i) { - signal(i, handler); - } - - unsigned int validDevIds[]{72214, 69948,}; - bool devIdFound = false; - - std::string file_path = frc::filesystem::GetDeployDirectory()+"/dev.id"; - try { - std::cout << "Trying to find dev.id" << std::endl; - std::ifstream ifs(file_path); - std::ostringstream oss; - oss << ifs.rdbuf(); - - std::string devId = oss.str(); - rtrim(devId); - ltrim(devId); - - auto devIdHash = hash_str(devId.c_str()); - - std::cout << "Dev.id hash key found: " << devIdHash << std::endl; - - for (auto id : validDevIds) { - if (id == devIdHash) { - devIdFound = true; - } - } - } catch (std::exception& exc) { - std::cout << "Error processing dev.id." << std::endl; - } - - if (!devIdFound) { - std::cerr << "Dev ID not set or did not match, exiting" << std::endl; - exit(0); - } else { - std::cout << "Valid dev ID found" << std::endl; - std::cout << "Last deploy: "; - - struct stat file_stat; - - if (stat(file_path.c_str(), &file_stat) == 0) { - char time_buffer[256]; - strftime(time_buffer, sizeof(time_buffer), "%F %T", - localtime(&file_stat.st_mtime)); std::cout << time_buffer << std::endl; auto - current_time = time(0); std::cout << "Current Time: " << - std::ctime(¤t_time) << std::endl; } else { std::cout << "Error getting - file status: " << std::endl; - } - }*/ - - std::cout << "Starting robot code [2024]..." << std::endl; - return frc::StartRobot(); -} \ No newline at end of file diff --git a/src/y2024/cpp/subsystems/abstract/vision.cc b/src/y2024/cpp/subsystems/abstract/vision.cc index 1994674..71a0b4f 100644 --- a/src/y2024/cpp/subsystems/abstract/vision.cc +++ b/src/y2024/cpp/subsystems/abstract/vision.cc @@ -119,13 +119,19 @@ VisionReadings VisionSubsystem::ReadFromHardware() { robot_x += can_bus_latency_.value() * velocity_x + x_correction; - newReadings.est_dist_from_speaker_x = - robot_x - field::points.kSpeaker( - !frc846::util::ShareTables::GetBoolean("is_red_side"))[0]; + newReadings.x_pos = robot_x; + newReadings.y_pos = robot_y; - newReadings.est_dist_from_speaker_y = - robot_y - field::points.kSpeaker( - !frc846::util::ShareTables::GetBoolean("is_red_side"))[1]; + robot_x_graph_.Graph(robot_x); + robot_y_graph_.Graph(robot_y); + + auto speaker_pt = + Field::getPoint("kSpeaker") + .mirrorOnlyY(!frc846::util::ShareTables::GetBoolean("is_red_side")); + + newReadings.est_dist_from_speaker_x = robot_x - speaker_pt.point[0]; + + newReadings.est_dist_from_speaker_y = robot_y - speaker_pt.point[1]; auto point_target = frc846::math::VectorND{ -newReadings.est_dist_from_speaker_x, diff --git a/src/y2024/cpp/subsystems/hardware/wrist.cc b/src/y2024/cpp/subsystems/hardware/wrist.cc index 6f04b67..e42c1e5 100644 --- a/src/y2024/cpp/subsystems/hardware/wrist.cc +++ b/src/y2024/cpp/subsystems/hardware/wrist.cc @@ -7,17 +7,14 @@ WristSubsystem::WristSubsystem(bool init) : frc846::robot::GenericSubsystem{"wrist", init} { - if (init) { - wrist_esc_.Init(frc846::control::REVSparkType::kSparkMAX); - } -} - -void WristSubsystem::Setup() { + wrist_esc_.Init(frc846::control::REVSparkType::kSparkMAX); wrist_esc_.Configure({frc846::control::DataTag::kPositionData, frc846::control::DataTag::kVelocityData}); wrist_esc_.ZeroEncoder(wrist_home_offset_.value()); } +void WristSubsystem::Setup() {} + WristTarget WristSubsystem::ZeroTarget() const { WristTarget target; target.wrist_output = wrist_home_offset_.value(); @@ -56,11 +53,15 @@ WristReadings WristSubsystem::ReadFromHardware() { } void WristSubsystem::WriteToHardware(WristTarget target) { + wrist_weight_pos_graph.Graph( + 1_deg * frc846::util::ShareTables::GetDouble("pivot_position") - + GetReadings().wrist_position + wrist_cg_offset_.value()); + hard_limits_.OverrideLimits(target.override_limits); if (auto pos = std::get_if(&target.wrist_output)) { double output = dyFPID.calculate(*pos, GetReadings().wrist_position, wrist_esc_.GetVelocityPercentage(), - config_helper_.updateAndGetGains()); + gains_prefs_dyFPID.get()); // if (units::math::abs(*pos - readings().wrist_position) < 5_deg) { // output = dyFPIDClose.calculate(*pos, readings().wrist_position, // wrist_esc_.GetVelocityPercentage(), @@ -72,6 +73,10 @@ void WristSubsystem::WriteToHardware(WristTarget target) { target_wrist_pos_graph.Graph(*pos); } else if (auto output = std::get_if(&target.wrist_output)) { + if (units::math::abs(wrist_esc_.GetVelocity()) > + homing_max_speed_.value()) { + *output = (*output) / homing_dc_cut_.value(); + } wrist_esc_.WriteDC(*output); target_wrist_duty_cycle_graph.Graph(*output); diff --git a/src/y2024/include/FunkyRobot.h b/src/y2024/include/FunkyRobot.h index 8ac8336..601d458 100644 --- a/src/y2024/include/FunkyRobot.h +++ b/src/y2024/include/FunkyRobot.h @@ -2,9 +2,7 @@ #include -#include "autos/drive_auto.h" -#include "autos/five_piece_auto.h" -#include "autos/one_piece_auto.h" +#include "autos/GenericAuto.h" #include "frc846/ntinf/fstore.h" #include "frc846/ntinf/pref.h" #include "frc846/robot/GenericRobot.h" @@ -26,29 +24,11 @@ class FunkyRobot : public frc846::robot::GenericRobot { private: RobotContainer container_; - // Autos - frc2::CommandPtr drive_auto_ = DriveAuto{container_}.ToPtr(); - - frc2::CommandPtr five_piece_auto_red = - FivePieceAuto{container_, false}.ToPtr(); - - frc2::CommandPtr five_piece_auto_blue = - FivePieceAuto{container_, true}.ToPtr(); - - frc2::CommandPtr one_piece_auto_0 = - OnePieceAuto{container_, -60_deg, "left red"}.ToPtr(); - frc2::CommandPtr one_piece_auto_1 = - OnePieceAuto{container_, 60_deg, "right red"}.ToPtr(); - frc2::CommandPtr one_piece_auto_2 = - OnePieceAuto{container_, -60_deg + 180_deg, "left blue"}.ToPtr(); - frc2::CommandPtr one_piece_auto_3 = - OnePieceAuto{container_, 60_deg + 180_deg, "right blue"}.ToPtr(); - frc::DigitalInput homing_switch_{0}; frc::DigitalInput coasting_switch_{1}; - frc846::ntinf::Pref start_coast_counter_{*this, "start_coast_counter", - 500}; + frc846::ntinf::Pref coasting_time_{*this, "coasting_time", + 7.5_s}; - int coast_counter_ = 0; + units::second_t stop_coast_time_; }; diff --git a/src/y2024/include/autos/ActionMaker.h b/src/y2024/include/autos/ActionMaker.h new file mode 100644 index 0000000..1430584 --- /dev/null +++ b/src/y2024/include/autos/ActionMaker.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include +#include + +#include "subsystems/robot_container.h" + +class ActionMaker { + public: + static std::unique_ptr GetAction(std::string name, + RobotContainer& container); +}; \ No newline at end of file diff --git a/src/y2024/include/autos/drive_auto.h b/src/y2024/include/autos/GenericAuto.h similarity index 53% rename from src/y2024/include/autos/drive_auto.h rename to src/y2024/include/autos/GenericAuto.h index 39999aa..ace32f9 100644 --- a/src/y2024/include/autos/drive_auto.h +++ b/src/y2024/include/autos/GenericAuto.h @@ -1,12 +1,17 @@ #pragma once +#include "field.h" #include "frc846/robot/GenericCommand.h" #include "frc846/swerve/follow_trajectory_command.h" #include "subsystems/robot_container.h" -class DriveAuto - : public frc846::robot::GenericCommandGroup { public: - DriveAuto(RobotContainer& container); + GenericAuto(RobotContainer& container, AutoData data, bool is_blue_side); + + private: + std::vector> buildActionsGroup( + AutoData data, RobotContainer& container, bool is_blue_side); }; diff --git a/src/y2024/include/autos/five_piece_auto.h b/src/y2024/include/autos/five_piece_auto.h deleted file mode 100644 index 055a624..0000000 --- a/src/y2024/include/autos/five_piece_auto.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "frc846/robot/GenericCommand.h" -#include "frc846/swerve/follow_trajectory_command.h" -#include "subsystems/robot_container.h" - -class FivePieceAuto - : public frc846::robot::GenericCommandGroup { - public: - FivePieceAuto(RobotContainer& container, bool should_flip); -}; diff --git a/src/y2024/include/autos/one_piece_auto.h b/src/y2024/include/autos/one_piece_auto.h deleted file mode 100644 index 3aafa57..0000000 --- a/src/y2024/include/autos/one_piece_auto.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "frc846/robot/GenericCommand.h" -#include "frc846/swerve/follow_trajectory_command.h" -#include "subsystems/robot_container.h" - -class OnePieceAuto - : public frc846::robot::GenericCommandGroup { - public: - OnePieceAuto(RobotContainer& container, units::degree_t start_angle, - std::string num); -}; diff --git a/src/y2024/include/commands/complex/close_drive_amp_command.h b/src/y2024/include/commands/complex/close_drive_amp_command.h index a63c247..219452f 100644 --- a/src/y2024/include/commands/complex/close_drive_amp_command.h +++ b/src/y2024/include/commands/complex/close_drive_amp_command.h @@ -1,19 +1,19 @@ -#pragma once +// #pragma once -#include "frc846/robot/GenericCommand.h" -#include "subsystems/robot_container.h" +// #include "frc846/robot/GenericCommand.h" +// #include "subsystems/robot_container.h" -class CloseDriveAmpCommand - : public frc846::robot::GenericCommand { - public: - CloseDriveAmpCommand(RobotContainer& container); +// class CloseDriveAmpCommand +// : public frc846::robot::GenericCommand { +// public: +// CloseDriveAmpCommand(RobotContainer& container); - void OnInit() override; +// void OnInit() override; - void Periodic() override; +// void Periodic() override; - void OnEnd(bool interrupted) override; +// void OnEnd(bool interrupted) override; - bool IsFinished() override; -}; +// bool IsFinished() override; +// }; diff --git a/src/y2024/include/commands/complex/home_during_auto_command.h b/src/y2024/include/commands/complex/home_during_auto_command.h new file mode 100644 index 0000000..f29e6d0 --- /dev/null +++ b/src/y2024/include/commands/complex/home_during_auto_command.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +#include "frc846/robot/GenericCommand.h" +#include "subsystems/robot_container.h" + +class HomeDuringAutoCommand + : public frc846::robot::GenericCommandGroup< + RobotContainer, HomeDuringAutoCommand, frc2::SequentialCommandGroup> { + public: + HomeDuringAutoCommand(RobotContainer& container); +}; diff --git a/src/y2024/include/commands/complex/super_amp_command.h b/src/y2024/include/commands/complex/super_amp_command.h index c266f71..fe3abe1 100644 --- a/src/y2024/include/commands/complex/super_amp_command.h +++ b/src/y2024/include/commands/complex/super_amp_command.h @@ -1,14 +1,16 @@ -#pragma once +// #pragma once -#include +// #include -#include "frc846/robot/GenericCommand.h" -#include "frc846/swerve/follow_trajectory_command.h" -#include "subsystems/robot_container.h" +// #include "frc846/robot/GenericCommand.h" +// #include "frc846/swerve/follow_trajectory_command.h" +// #include "subsystems/robot_container.h" -class SuperAmpCommand - : public frc846::robot::GenericCommandGroup { - public: - SuperAmpCommand(RobotContainer& container, bool is_red_side); -}; +// class SuperAmpCommand +// : public frc846::robot::GenericCommandGroup +// { +// public: +// SuperAmpCommand(RobotContainer& container, bool is_red_side); +// }; diff --git a/src/y2024/include/field.h b/src/y2024/include/field.h index f90213c..ef115eb 100644 --- a/src/y2024/include/field.h +++ b/src/y2024/include/field.h @@ -1,89 +1,77 @@ #pragma once -#include +#include + +#include #include "frc846/math/fieldpoints.h" -// Field has blue alliance far right corner as origin -struct field { - struct points_cls { - frc846::math::FieldPoint Origin() { - return {{0_in, 0_in}, 0_deg, {0_fps, 0_fps}}; - } - - frc846::math::VectorND kSpeaker(bool flip = false) { - if (!flip) { - return {217.5_in, -4_in}; - } else { - return {217.5_in, 655.8_in}; - } - } - - frc846::math::FieldPoint kAmpNoFlip() { - return {{0_in, 0_in}, 90_deg, {0_fps, 0_fps}}; - } - - frc846::math::FieldPoint kPreAmpNoFlip() { - return {{-2_ft, 0_in}, 90_deg, {0_fps, 0_fps}}; - } - - // DRIVE AUTO - TEST POINTS - - frc846::math::FieldPointPreference testing_origin{"testing_origin", - Origin()}; - frc846::math::FieldPoint kTestingOrigin() { return testing_origin.get(); }; - - frc846::math::FieldPointPreference testing_point{ - "testing_point", {{0_in, 120_in}, 0_deg, {0_fps, 0_fps}}}; - frc846::math::FieldPoint kTestingPoint() { return testing_point.get(); }; - - // FIVE PIECE AUTO - frc846::base::Loggable five_piece_loggable{"five_piece_auto"}; - - frc846::ntinf::Pref pre_point_amt{five_piece_loggable, - "pre_point_amt", 2_ft}; - frc846::math::FieldPoint pre_point(frc846::math::FieldPoint pnt) { - return {{pnt.point[0], pnt.point[1] - pre_point_amt.value()}, - pnt.bearing, - {0_fps, 15_fps}}; - } - - frc846::math::FieldPointPreference origin_point{ - "five_piece_origin", {{217.5_in, 49_in}, 0_deg, {0_fps, 0_fps}}}; - frc846::math::FieldPoint kFivePieceOrigin(bool should_flip) { - return origin_point.get().mirrorOnlyY(should_flip); - } - - frc846::math::FieldPointPreference intake_one{ - "five_piece_intake_one", {{217.5_in, 112_in}, 0_deg, {0_fps, 0_fps}}}; - std::vector intake_one_path(bool should_flip) { - auto base_point = intake_one.get(); - return {pre_point(base_point).mirrorOnlyY(should_flip), - base_point.mirrorOnlyY(should_flip)}; - } - - frc846::math::FieldPointPreference intake_two{ - "five_piece_intake_two", {{160.5_in, 112_in}, 0_deg, {0_fps, 0_fps}}}; - std::vector intake_two_path(bool should_flip) { - auto base_point = intake_two.get(); - return {pre_point(base_point).mirrorOnlyY(should_flip), - base_point.mirrorOnlyY(should_flip)}; - } - - frc846::math::FieldPointPreference intake_three{ - "five_piece_intake_three", {{274.5_in, 112_in}, 0_deg, {0_fps, 0_fps}}}; - std::vector intake_three_path(bool should_flip) { - auto base_point = intake_three.get(); - return {pre_point(base_point).mirrorOnlyY(should_flip), - base_point.mirrorOnlyY(should_flip)}; - } - - frc846::math::FieldPointPreference finish_pt{ - "five_piece_finish", {{274.5_in, 180_in}, 0_deg, {0_fps, 0_fps}}}; - frc846::math::FieldPoint kFivePieceFinish(bool should_flip) { - return finish_pt.get().mirrorOnlyY(should_flip); - } - }; - - static points_cls points; +enum AutoFlipType { kNone, kMirror, kMirrorOnlyY }; + +struct AutoData { + std::string name; + AutoFlipType red; + AutoFlipType blue; + frc846::math::FieldPoint start; + std::vector, std::string>> + actions; +}; + +class Field_nonstatic : public frc846::base::Loggable { + public: + std::vector> points; + + std::vector>> + paths; + + frc846::math::FieldPoint getPoint(std::string name); + + std::vector getPath(std::string name); + + Field_nonstatic(); + + void Setup(); + + std::vector getAllAutoData(); + + private: + void addPoint(std::string name, frc846::math::FieldPoint point) { + points.push_back(std::pair{name, point}); + } + + static std::vector split(const std::string& s, char delimiter); + + static std::vector readLines(std::string filename); + + static std::string fixPath(std::string path); + + static std::string forceNormalPath(std::string path); + + static std::string getFileDirectory(); + + frc846::math::FieldPoint parsePoint(std::string line); + + void readPointsFile(); + + void readAllPaths(); }; + +class Field { + public: + static frc846::math::FieldPoint getPoint(std::string name) { + return instance.getPoint(name); + } + + static std::vector getPath(std::string name) { + return instance.getPath(name); + } + + static void Setup() { instance.Setup(); } + + static std::vector getAllAutoData() { + return instance.getAllAutoData(); + } + + private: + static Field_nonstatic instance; +}; \ No newline at end of file diff --git a/src/y2024/include/rsighandler.h b/src/y2024/include/rsighandler.h new file mode 100644 index 0000000..77d82f1 --- /dev/null +++ b/src/y2024/include/rsighandler.h @@ -0,0 +1,60 @@ +#pragma once + +#ifndef _WIN32 +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +void handler(int sig) { + std::map sigErrors; + + sigErrors[SIGFPE] = "FATAL ERROR >> Arithmetic Error, SIGFPE"; + sigErrors[SIGILL] = "FATAL ERROR >> Illegal Instruction, SIGILL"; + sigErrors[SIGSEGV] = "FATAL ERROR >> Illegal Memory Access, SIGSEGV"; + sigErrors[SIGBUS] = "FATAL ERROR >> Bus Error, SIGBUS"; + sigErrors[SIGABRT] = "FATAL ERROR >> Abort, SIGABRT"; + sigErrors[SIGSYS] = "FATAL ERROR >> Invalid system call, SIGSYS"; + sigErrors[SIGTRAP] = "FATAL ERROR >> Exception Occured, SIGTRAP"; + + void* callstack[24]; + + int frames = backtrace(callstack, 24); + + std::cerr << "Backtrace:\n"; + char** symbols = backtrace_symbols(callstack, frames); + + if (symbols == nullptr) { + std::cerr << "Error obtaining backtrace symbols\n" << std::endl; + return; + } + + for (int i = 0; i < frames; ++i) { + std::cerr << symbols[i] << std::endl; + } + + if (sigErrors.contains(sig)) { + std::cerr << sigErrors[sig] << std::endl; + } else { + std::cerr << "? Unknown Exception Occured" << std::endl; + } + // exit(1); +} +#endif + +#ifndef _WIN32 +void configureSignalHandlers() { + for (int i = 1; i < NSIG; ++i) { + signal(i, handler); + } +} +#else +void configureSignalHandlers() {} +#endif \ No newline at end of file diff --git a/src/y2024/include/subsystems/abstract/vision.h b/src/y2024/include/subsystems/abstract/vision.h index 713b500..208828a 100644 --- a/src/y2024/include/subsystems/abstract/vision.h +++ b/src/y2024/include/subsystems/abstract/vision.h @@ -20,6 +20,9 @@ struct VisionReadings { units::inch_t tag_distance; units::degree_t tag_angle_difference; + units::foot_t x_pos; + units::foot_t y_pos; + double velocity_in_component; double velocity_orth_component; }; @@ -44,6 +47,9 @@ class VisionSubsystem bool VerifyHardware() override; + frc846::ntinf::Pref using_vision_autos_{*this, "using_vision_autos", + false}; + private: frc846::ntinf::Pref default_is_red_side_{*this, "default_is_red_side"}; @@ -53,6 +59,10 @@ class VisionSubsystem "ll_latency"}; frc846::base::Loggable readings_named{*this, "readings"}; + frc846::ntinf::Grapher robot_x_graph_{readings_named, + "robot_x"}; + frc846::ntinf::Grapher robot_y_graph_{readings_named, + "robot_y"}; frc846::ntinf::Grapher speaker_x_dist_graph_{readings_named, "speaker_dist_x"}; frc846::ntinf::Grapher speaker_y_dist_graph_{readings_named, diff --git a/src/y2024/include/subsystems/hardware/wrist.h b/src/y2024/include/subsystems/hardware/wrist.h index bbc1d24..43f70b6 100644 --- a/src/y2024/include/subsystems/hardware/wrist.h +++ b/src/y2024/include/subsystems/hardware/wrist.h @@ -24,6 +24,8 @@ struct WristTarget { class WristSubsystem : public frc846::robot::GenericSubsystem { public: + bool hasZeroed = false; + WristSubsystem(bool init); void Setup() override; @@ -78,12 +80,13 @@ class WristSubsystem frc846::ntinf::Pref homing_velocity_tolerance_{ *this, "homing_velocity_tolerance", 1.0_deg_per_s}; - frc846::ntinf::Pref num_loops_homed_{*this, "num_loops_homed", 7}; + frc846::ntinf::Pref num_loops_homed_{*this, "num_loops_homed", 20}; frc846::ntinf::Pref homing_speed_{*this, "homing_speed", -0.2}; + frc846::ntinf::Pref homing_max_speed_{ + *this, "homing_max_speed", 30.0_deg_per_s}; + frc846::ntinf::Pref homing_dc_cut_{*this, "homing_dc_cut", 1.5}; private: - bool hasZeroed = false; - frc846::base::Loggable gains_{*this, "gains"}; frc846::ntinf::Pref k_{gains_, "k", 0.0}; frc846::ntinf::Pref p_{gains_, "p", 0.0}; @@ -96,6 +99,9 @@ class WristSubsystem frc846::ntinf::Grapher wrist_error_graph{target_named_, "wrist_error"}; + frc846::ntinf::Grapher wrist_weight_pos_graph{ + target_named_, "wrist_weight_position"}; + frc846::base::Loggable target_named_{*this, "target"}; frc846::ntinf::Grapher target_wrist_duty_cycle_graph{ @@ -124,14 +130,17 @@ class WristSubsystem frc846::base::Loggable dyFPID_loggable{*this, "DynamicFPID"}; + frc846::control::GainsPrefs gains_prefs_dyFPID{dyFPID_loggable, + {0.0, 0.0, 0.0}}; + frc846::motion::BrakingPositionDyFPID dyFPID{ dyFPID_loggable, [&](units::degree_t pos) -> double { - return std::abs( - units::math::cos( - 1_deg * frc846::util::ShareTables::GetDouble("pivot_position") - - GetReadings().wrist_position + wrist_cg_offset_.value()) - .to()); + return units::math::sin( + 1_deg * + frc846::util::ShareTables::GetDouble("pivot_position") - + GetReadings().wrist_position + wrist_cg_offset_.value()) + .to(); }, {30_A, frc846::control::DefaultSpecifications::stall_current_neo, 0.3}, &hard_limits_}; diff --git a/src/y2024/resources/deploy_autos.bat b/src/y2024/resources/deploy_autos.bat new file mode 100644 index 0000000..f264a57 --- /dev/null +++ b/src/y2024/resources/deploy_autos.bat @@ -0,0 +1,3 @@ +scp ./src/deploy/autos/points.lst admin@10.8.46.2:/home/lvuser/deploy/autos +scp ./src/deploy/autos/paths/* admin@10.8.46.2:/home/lvuser/deploy/autos/paths +scp ./src/deploy/autos/scripts/* admin@10.8.46.2:/home/lvuser/deploy/autos/scripts \ No newline at end of file diff --git a/src/y2024/resources/jetson/readAprilTag.py b/src/y2024/resources/jetson/readAprilTag.py index da97730..1287a7b 100644 --- a/src/y2024/resources/jetson/readAprilTag.py +++ b/src/y2024/resources/jetson/readAprilTag.py @@ -1,308 +1,196 @@ from pupil_apriltags import Detector -from datetime import datetime import numpy as np -import math -import os -from cv2 import * +import time +import cv2 import threading from networktables import NetworkTables +import subprocess +from pref import NumericPref, BooleanPref, KillSwitch -NetworkTables.initialize(server='roborio-846-frc.local') +NetworkTables.initialize(server='10.8.46.2') table = NetworkTables.getTable("AprilTags") -validTagIds = [4, 7] +preferenceTable = NetworkTables.getTable("JetsonPreferences") -aprilTagX=[0-14/12.0]*20 -aprilTagY=[6-6/12.0]*20 -aprilAngle=[180]*20 -aprilHeights=[10]*20 +kill_switch = KillSwitch(preferenceTable) -aprilTagX[4]=-104.4/12 #RED -aprilTagY[4]=0.0/12.0 -aprilAngle[4]=0 -aprilHeights[4]=53.88 +exposure_pref = NumericPref(preferenceTable, "camera_exposure", 1) +horizontal_fov_pref = NumericPref(preferenceTable, "h_fov", 63.1) +vertical_fov_pref = NumericPref(preferenceTable, "v_fov", 50.0) -aprilTagX[3]=-126.65/12 #RED -aprilTagY[3]=0/12.0 -aprilAngle[3]=0 -aprilHeights[3]=53.88 +h_frame_size = NumericPref(preferenceTable, "h_frame", 640) +v_frame_size = NumericPref(preferenceTable, "v_frame", 480) -aprilTagX[7]=-104.4/12 #BLUE -aprilTagY[7]=651.25/12.0 -aprilAngle[7]=0 -aprilHeights[7]=53.88 +cam_latency = NumericPref(preferenceTable, "camera_latency", 0.01) -aprilTagX[8]=-127.08/12 #BLUE -aprilTagY[8]=651.25/12 -aprilAngle[8]=0 -aprilHeights[8]=53.88 +target_mean_brightness = NumericPref(preferenceTable, "target_mean_brightness", 120) +clip_limit = NumericPref(preferenceTable, "clip_limit", 2.0) +debug_mode = BooleanPref(preferenceTable, "debug_mode", False) -# aprilTagX[16]=0.3-14/12.0 -# aprilTagY[16]=9.0247+6/12.0 +at_detector = Detector(families='tag36h11', + nthreads=1, + quad_decimate=1.0, + quad_sigma=0.2, + refine_edges=1, + decode_sharpening=0.5, + debug=0) -locations=np.array([0.0, 0.0, 0.0]) +cameraMatrix = np.array([(336.7755634193813, 0.0, 333.3575643300718), (0.0, 336.02729840829176, 212.77376312080065), (0.0, 0.0, 1.0)]) -framesSeen=0 -confidence=0 +camera_params = ( cameraMatrix[0,0], cameraMatrix[1,1], cameraMatrix[0,2], cameraMatrix[1,2] ) -lower = np.array([0, 0, 0]) -upper = np.array([255, 255, 105]) +queue = [] -visualization = False -try: - import cv2 -except: - raise Exception('OpenCV not found') +def adjust_gamma(image, gamma=1.0): + invGamma = 1.0 / gamma + table = np.array([((i / 255.0) ** invGamma) * 255 + for i in np.arange(0, 256)]).astype("uint8") + return cv2.LUT(image, table) -try: - from cv2 import imshow -except: - print("The function imshow was not implemented in this installation. Rebuild OpenCV from source to use it") - print("Visualization will be disabled.") - visualization = False +def pre_process(frame): + global clip_limit + global target_mean_brightness + + clahe = cv2.createCLAHE(clipLimit=clip_limit.get(), tileGridSize=(8,8)) + tmean_b = target_mean_brightness.get() + result = clahe.apply(frame) -def getDistanceAssumingHeadOn(y, verticalPixelHeight): - heightOfObject =1 - verticalFOV = 1 * 3.14159/360 - return (heightOfObject*verticalPixelHeight)/(2*y*math.tan(verticalFOV/2)) + mean_brightness = np.mean(result) -# def getDist(xReal, yReal, verticalPixelHeight, horizontalPixelWidth, tagSize): -# x = xReal-horizontalPixelWidth/2 -# y=verticalPixelHeight/2-yReal - + if (mean_brightness != 0): result = adjust_gamma(result, tmean_b / mean_brightness) -def getDistance(xReal, yReal, verticalPixelHeight, horizontalPixelWidth, tagHeight): - x = xReal-horizontalPixelWidth/2 - y=verticalPixelHeight/2 -yReal + return result - diagonalFOV=(68.5)*(3.14159/180) - f = math.sqrt(horizontalPixelWidth*horizontalPixelWidth+verticalPixelHeight*verticalPixelHeight)/(2*(math.tan(diagonalFOV/2))) - # 587.4786864517579 - mountHeight=12 - mountAngle=(37)*(3.14159/180) +def process_frames(): + global table + global queue - VertAngle = mountAngle+math.atan(y/f) - yDist = (tagHeight-mountHeight)/math.tan(VertAngle) - xDist = ((tagHeight-mountHeight)/math.sin(VertAngle))*x/(math.sqrt(f*f+y*y)) + global cam_latency + global horizontal_fov_pref + global vertical_fov_pref + global h_frame_size + global v_frame_size + global debug_mode - return (xDist, yDist, tagHeight) + validTagIds = [4, 7] + CAM_FOV_H = horizontal_fov_pref.get() + CAM_FOV_V = vertical_fov_pref.get() -at_detector = Detector(families='tag36h11', - nthreads=1, - quad_decimate=1.0, - quad_sigma=0.0, - refine_edges=1, - decode_sharpening=0.25, - debug=0) + CAM_SZ_H = h_frame_size.get() + CAM_SZ_V = v_frame_size.get() -cameraMatrix = np.array([(336.7755634193813, 0.0, 333.3575643300718), (0.0, 336.02729840829176, 212.77376312080065), (0.0, 0.0, 1.0)]) - -camera_params = ( cameraMatrix[0,0], cameraMatrix[1,1], cameraMatrix[0,2], cameraMatrix[1,2] ) - -starttime = datetime.now() -RealStart = datetime.now() -framesPassed=0 -roboRioFrameRequests=0 -def run_april (frame): - global framesPassed - global starttime - global roboRioFrameRequests - global RealStart - global framesSeen - global confidence - global locations - data = table.getNumberArray("roboRioFrameRequest", [0, 0]) - currentRoboRioFrameRequest=data[0] - currentBearing=data[1] - # print(currentRoboRioFrameRequest) - frameRequested = (currentRoboRioFrameRequest != roboRioFrameRequests) and (currentRoboRioFrameRequest != roboRioFrameRequests -1) - # print(str(currentRoboRioFrameRequest) +" " + str(roboRioFrameRequests)) - - - if (frameRequested): - sizingFactor = 1/2 - img = frame - img = cv2.resize(img, ((int)(frame.shape[1]*sizingFactor), (int)(frame.shape[0]*sizingFactor))) - img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) - frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) - - #tags = at_detector.detect(img, True, camera_params, parameters['sample_test']['tag_size']) - tags = at_detector.detect(img, True, camera_params, 0.065) - bufferSize =4 - - if tags != []: - try: - print(tags.__getitem__(0).tag_id) - - (ptUpperL,ptUpperR,ptBottomR,ptBottomL) = tags.__getitem__(0).corners - - ptUpperL=((int)(ptUpperL[0]), (int)(ptUpperL[1])) - ptUpperR=((int)(ptUpperR[0]), (int)(ptUpperR[1])) - ptBottomL=((int)(ptBottomL[0]), (int)(ptBottomL[1])) - ptBottomR=((int)(ptBottomR[0]), (int)(ptBottomR[1])) - - upperRight = frame[int(ptUpperR[1]/sizingFactor-bufferSize):int(ptUpperR[1]/sizingFactor+bufferSize), int(ptUpperR[0]/sizingFactor-bufferSize):int(ptUpperR[0]/sizingFactor+bufferSize)] - - upperRightHsv = cv2.cvtColor(upperRight, cv2.COLOR_BGR2HSV) - upperRightMask = cv2.inRange(upperRightHsv, lower, upper) - upperRightResult =cv2.bitwise_and(upperRight, upperRight, mask=upperRightMask) - upperRight_np_result = np.array(upperRightResult) - upperRightResult = cv2.merge((upperRight_np_result, upperRight_np_result, upperRight_np_result)) - upperRightResult = cv2.Canny(upperRightResult, 60, 200) - upperRightContours, hierarchy = cv2.findContours(upperRightResult, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) - upperRightRect = cv2.boundingRect(upperRightContours[0]) - bottomRightBound =(int(ptUpperR[1]/sizingFactor-bufferSize)+upperRightRect[2], int(ptUpperR[0]/sizingFactor-bufferSize)+upperRightRect[3]) - - upperLeft = frame[int(ptUpperL[1]/sizingFactor-bufferSize):int(ptUpperL[1]/sizingFactor+bufferSize), int(ptUpperL[0]/sizingFactor-bufferSize):int(ptUpperL[0]/sizingFactor+bufferSize)] - upperLeftHsv = cv2.cvtColor(upperLeft, cv2.COLOR_BGR2HSV) - upperLeftMask = cv2.inRange(upperLeftHsv, lower, upper) - upperLeftResult = cv2.bitwise_and(upperLeft, upperLeft, mask=upperLeftMask) - upperLeft_np_result = np.array(upperLeftResult) - upperLeftResult = cv2.merge((upperLeft_np_result, upperLeft_np_result, upperLeft_np_result)) - upperLeftResult = cv2.Canny(upperLeftResult, 60, 200) - - upperLeftContours, hierarchy = cv2.findContours(upperLeftResult, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) - upperLeftRect = cv2.boundingRect(upperLeftContours[0]) - cv2.line(upperLeftResult,(upperLeftRect[0], upperLeftRect[1]),(upperLeftRect[0], upperLeftRect[1]+upperLeftRect[3]), color=(0, 255, 255), thickness=1) - cv2.line(upperLeftRect,(upperLeftRect[0], upperLeftRect[1]),(upperLeftRect[0]+upperLeftRect[2], upperLeftRect[1]), color=(0, 255, 255), thickness=1) - cv2.line(upperLeftResult,(upperLeftRect[0], upperLeftRect[1]+upperLeftRect[3]),(upperLeftRect[0]+upperLeftRect[2], upperLeftRect[1]+upperLeftRect[3]), color=(0, 255, 255), thickness=1) - cv2.line(upperLeftResult,(upperLeftRect[0]+upperLeftRect[2], upperLeftRect[1]+upperLeftRect[3]),(upperLeftRect[0]+upperLeftRect[2], upperLeftRect[1]), color=(0, 255, 255), thickness=1) - - bottomLeftBound=(int(ptUpperL[1]/sizingFactor-bufferSize)+upperLeftRect[0], int(ptUpperL[0]/sizingFactor-bufferSize)+upperLeftRect[3]) - - bottomLeft = frame[int(ptBottomL[1]/sizingFactor-bufferSize):int(ptBottomL[1]/sizingFactor+bufferSize), int(ptBottomL[0]/sizingFactor-bufferSize):int(ptBottomL[0]/sizingFactor+bufferSize)] - bottomLeftHsv =cv2.cvtColor(bottomLeft, cv2.COLOR_BGR2HSV) - bottomLeftMask=cv2.inRange(bottomLeftHsv, lower, upper) - bottomLeftResult =cv2.bitwise_and(bottomLeft, bottomLeft, mask=bottomLeftMask) - - bottomLeft_np_result = np.array(bottomLeftResult) - bottomLeftResult = cv2.merge((bottomLeft_np_result, bottomLeft_np_result, bottomLeft_np_result)) - bottomLeftResult = cv2.Canny(bottomLeftResult, 60, 200) - - bottomLeftContours, hierarchy = cv2.findContours(bottomLeftResult, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) - bottomLeftRect = cv2.boundingRect(bottomLeftContours[0]) - upperLeftBound=(int(ptBottomL[1]/sizingFactor-bufferSize)+bottomLeftRect[0], int(ptBottomL[0]/sizingFactor-bufferSize)+bottomLeftRect[1]) - - bottomRight = frame[int(ptBottomR[1]/sizingFactor-bufferSize):int(ptBottomR[1]/sizingFactor+bufferSize), int(ptBottomR[0]/sizingFactor-bufferSize):int(ptBottomR[0]/sizingFactor+bufferSize)] - bottomRightHsv =cv2.cvtColor(bottomRight, cv2.COLOR_BGR2HSV) - bottomRightMask=cv2.inRange(bottomRightHsv, lower, upper) - bottomRightResult =cv2.bitwise_and(bottomRight, bottomRight, mask=bottomRightMask) - - bottomRight_np_result = np.array(bottomRightResult) - bottomRightResult = cv2.merge((bottomRight_np_result, bottomRight_np_result, bottomRight_np_result)) - bottomRightResult = cv2.Canny(bottomRightResult, 60, 200) - - bottomRightContours, hierarchy = cv2.findContours(bottomRightResult, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) - bottomRightRect = cv2.boundingRect(bottomRightContours[0]) - print(bottomRightRect) - upperRightBound=(int(ptBottomR[1]/sizingFactor-bufferSize)+bottomRightRect[1], int(ptBottomR[0]/sizingFactor-bufferSize)+bottomRightRect[2]) - frame=cv2.circle(frame, (upperLeftBound[1], upperLeftBound[0]), radius=0, color=(0, 255, 255), thickness=-1) - frame=cv2.circle(frame, (upperRightBound[1], upperRightBound[0]), radius=0, color=(0, 255, 255), thickness=-1) - frame=cv2.circle(frame, (bottomLeftBound[1], bottomLeftBound[0]), radius=0, color=(0, 255, 255), thickness=-1) - frame=cv2.circle(frame, (bottomRightBound[1], bottomRightBound[0]), radius=0, color=(0, 255, 255), thickness=-1) - - location=(np.array(getDistance(upperRightBound[1], upperRightBound[0], frame.shape[0], frame.shape[1], 60.75)) - +np.array(getDistance(bottomLeftBound[1], bottomLeftBound[0], frame.shape[0], frame.shape[1], 54.5)+np.array(getDistance(bottomRightBound[1], bottomRightBound[0], frame.shape[0], frame.shape[1], 60.75))+np.array(getDistance(upperLeftBound[1], upperLeftBound[0], frame.shape[0], frame.shape[1], 54.5))))/4 - # ) - locations+=location - - print(location) - tagId=tags.__getitem__(0).tag_id - - table.putNumber("robotX", location[0]/12.0) - table.putNumber("robotY", location[1]/12.0) - table.putNumber("aprilTagID", tagId) - table.putNumber("aprilTagX", aprilTagX[tagId]) - table.putNumber("aprilTagAngle", aprilAngle[tagId]) - table.putNumber("aprilTagY", aprilTagY[tagId]) - - if (tagId in validTagIds): - table.putNumber("aprilTagConfidence", confidence) - else: - table.putNumber("aprilTagConfidence", 0.0) - - table.putNumber("processorFrameSent", currentRoboRioFrameRequest) - roboRioFrameRequests=currentRoboRioFrameRequest - - NetworkTables.flush() - - framesSeen+=1; - - except: - table.putNumber("aprilTagConfidence", 0.0) - table.putNumber("processorFrameSent", currentRoboRioFrameRequest) - roboRioFrameRequests=currentRoboRioFrameRequest - print("Uh oh! We encountered an error and did not send data this loop") - - else: - table.putNumber("aprilTagConfidence", 0.0) - table.putNumber("processorFrameSent", currentRoboRioFrameRequest) - roboRioFrameRequests=currentRoboRioFrameRequest - - time = datetime.now()-RealStart - - framesPassed+=1 - - - if (framesPassed >= 10): - endtime=datetime.now() - - locations=np.array([0.0, 0.0, 0.0]) - print('FPS: ' + (str)(framesPassed/(endtime-starttime).total_seconds())) - starttime=endtime - confidence =framesSeen/(1.0*framesPassed) - framesPassed=0 - framesSeen=0 + while True: + if len(queue) == 0: continue + frame = queue.pop(0) + + process_start_time = time.time() + + orig_img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + + img = pre_process(orig_img) + + tags = at_detector.detect(img, False, camera_params, 0.065) + + table.putNumber("tx", 0.0) + table.putNumber("ty", 0.0) + table.putNumber("tid", -1) + + try: + for tag in tags: + if not (tag.tag_id in validTagIds): continue + + cx, cy = tag.center + tx = (cx - CAM_SZ_H/2) * (CAM_FOV_H / CAM_SZ_H) + ty = -((cy - CAM_SZ_V/2) * (CAM_FOV_V / CAM_SZ_V)) -def RUN_APRIL_846(): - print("SCRIPT: ATTEMPTING CAM 1") + table.putNumber("tid", tag.tag_id) + table.putNumber("tx", tx) + + table.putNumber("ty", ty) + + except: + pass + + latency = cam_latency.get() + time.time() - process_start_time + + + if (debug_mode.get()): + cv2.putText(orig_img, f"Original Image: ({CAM_SZ_H}, {CAM_SZ_V}).", + (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 3, cv2.LINE_AA) + cv2.imwrite("/home/nvidia/apriltags/orig.png", img) + + img_copy = img.copy() + + cv2.putText(img_copy, f"Processed Image: ({CAM_SZ_H}, {CAM_SZ_V}).", + (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 3, cv2.LINE_AA) + cv2.imwrite("/home/nvidia/apriltags/proc.png", img_copy) + + for tag in tags: + for idx in range(len(tag.corners)): + cv2.line(img, tuple(tag.corners[idx-1, :].astype(int)), + tuple(tag.corners[idx, :].astype(int)), (0, 255, 0), thickness=4) + + cv2.putText(img, f"ID: {tag.tag_id}", + org=(tag.corners[0, 0].astype(int), tag.corners[0, 1].astype(int)), + fontFace=cv2.FONT_HERSHEY_SIMPLEX, + fontScale=0.8, color=(0, 255, 0), thickness=4) + + cv2.putText(img, f"Resultant Image. {len(tags)} Detections. Latency: {latency}.", + (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 3, cv2.LINE_AA) + + cv2.imwrite("/home/nvidia/apriltags/res.png", img) + + table.putNumber("latency", latency) + NetworkTables.flush() + +def getCamera() -> cv2.VideoCapture: + print("\n") cap = cv2.VideoCapture("/dev/video0") - if cap.isOpened()==False: - print("SCRIPT: ATTEMPTING CAM 2") + if cap.isOpened() == False: + print("CAM 1 FAILURE, ATTEMPTING CAM 2.") cap = cv2.VideoCapture("/dev/video1") - if cap.isOpened()==False: - print("SCRIPT: CAM CONN FAILURE") + if cap.isOpened() == False: + print("CAM CONN FAILURE.") else: - print("SCRIPT: CAM CONN") - cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640) - cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) - cap.set(cv2.CAP_PROP_BUFFERSIZE, 0) + print("CAM CONN SUCCESS.") + print("\n") - counter = 0 - otime = datetime.now() - if cap.isOpened(): - while(True): - counter+=1 + return cap - # frame = cv.imread('testing.jpg') - _, frame = cap.read() +if __name__ == "__main__": + cap = getCamera() - t1 = threading.Thread(target=run_april, args=(frame,)) - t1.start() - t1.join() + if cap is None: + print("Exiting, camera is None.") + exit(1) + subprocess.run(['v4l2-ctl', f'-c exposure_absolute={exposure_pref.get()}']) + - if counter % 10 == 0: - counter = 0 - print("FPS: " + str((datetime.now()-otime))) - otime = datetime.now() - - - #if cv.waitKey(1)== ord('q'): - # break + cap.set(cv2.CAP_PROP_FRAME_WIDTH, int(h_frame_size.get())) + cap.set(cv2.CAP_PROP_FRAME_HEIGHT, int(v_frame_size.get())) + cap.set(cv2.CAP_PROP_BUFFERSIZE, 0) + if cap.isOpened(): + t1 = threading.Thread(target=process_frames) + t1.start() - cap.release() - + while True: + _, frame = cap.read() + if frame is None: + continue + queue.append(frame) + if (len(queue) > 5): + queue.pop(0) -RUN_APRIL_846() \ No newline at end of file + cap.release() \ No newline at end of file diff --git a/src/y2024/resources/jetson/readAprilTag2.py b/src/y2024/resources/jetson/readAprilTag2.py deleted file mode 100644 index 12ea5d5..0000000 --- a/src/y2024/resources/jetson/readAprilTag2.py +++ /dev/null @@ -1,155 +0,0 @@ -from pupil_apriltags import Detector -import numpy as np -import time -import cv2 -import threading -from networktables import NetworkTables -import subprocess -from pref import NumericPref, BooleanPref, KillSwitch - -NetworkTables.initialize(server='10.8.46.2') -table = NetworkTables.getTable("AprilTags") - -preferenceTable = NetworkTables.getTable("JetsonPreferences") - -kill_switch = KillSwitch(preferenceTable) - -exposure_pref = NumericPref(preferenceTable, "camera_exposure", 1) -horizontal_fov_pref = NumericPref(preferenceTable, "h_fov", 63.1) -vertical_fov_pref = NumericPref(preferenceTable, "v_fov", 50.0) - -h_frame_size = NumericPref(preferenceTable, "h_frame", 640) -v_frame_size = NumericPref(preferenceTable, "v_frame", 480) - -cam_latency = NumericPref(preferenceTable, "camera_latency", 0.01) - -target_mean_brightness = NumericPref(preferenceTable, "target_mean_brightness", 120) - -clip_limit = NumericPref(preferenceTable, "clip_limit", 2.0) - -at_detector = Detector(families='tag36h11', - nthreads=1, - quad_decimate=1.0, - quad_sigma=0.2, - refine_edges=1, - decode_sharpening=0.5, - debug=0) - -cameraMatrix = np.array([(336.7755634193813, 0.0, 333.3575643300718), (0.0, 336.02729840829176, 212.77376312080065), (0.0, 0.0, 1.0)]) - -camera_params = ( cameraMatrix[0,0], cameraMatrix[1,1], cameraMatrix[0,2], cameraMatrix[1,2] ) - -queue = [] - -def adjust_gamma(image, gamma=1.0): - invGamma = 1.0 / gamma - table = np.array([((i / 255.0) ** invGamma) * 255 - for i in np.arange(0, 256)]).astype("uint8") - return cv2.LUT(image, table) - -def process_frames(): - global table - global queue - - global cam_latency - global horizontal_fov_pref - global vertical_fov_pref - global h_frame_size - global v_frame_size - - validTagIds = [4, 7] - - CAM_FOV_H = horizontal_fov_pref.get() - CAM_FOV_V = vertical_fov_pref.get() - - CAM_SZ_H = h_frame_size.get() - CAM_SZ_V = v_frame_size.get() - - clahe = cv2.createCLAHE(clipLimit=clip_limit.get(), tileGridSize=(8,8)) - - tmean_b = target_mean_brightness.get() - - while True: - if len(queue) == 0: continue - - frame = queue.pop(0) - - process_start_time = time.time() - - img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) - img = clahe.apply(img) - - mean_brightness = np.mean(img) - - if (mean_brightness != 0): img = adjust_gamma(img, tmean_b / mean_brightness) - - tags = at_detector.detect(img, False, camera_params, 0.065) - - table.putNumber("tx", 0.0) - table.putNumber("ty", 0.0) - table.putNumber("tid", -1) - - try: - for tag in tags: - if not (tag.tag_id in validTagIds): continue - - cx, cy = tag.center - - tx = (cx - CAM_SZ_H/2) * (CAM_FOV_H / CAM_SZ_H) - ty = -((cy - CAM_SZ_V/2) * (CAM_FOV_V / CAM_SZ_V)) - - table.putNumber("tid", tag.tag_id) - table.putNumber("tx", tx) - - table.putNumber("ty", ty) - - except: - pass - - table.putNumber("latency", cam_latency.get() + time.time() - process_start_time) - NetworkTables.flush() - -def getCamera() -> cv2.VideoCapture: - print("\n") - cap = cv2.VideoCapture("/dev/video0") - if cap.isOpened() == False: - print("CAM 1 FAILURE, ATTEMPTING CAM 2.") - cap = cv2.VideoCapture("/dev/video1") - if cap.isOpened() == False: - print("CAM CONN FAILURE.") - else: - print("CAM CONN SUCCESS.") - print("\n") - - return cap - -if __name__ == "__main__": - cap = getCamera() - - if cap is None: - print("Exiting, camera is None.") - exit(1) - - subprocess.run(['v4l2-ctl', f'-c exposure_absolute={exposure_pref.get()}']) - - - cap.set(cv2.CAP_PROP_FRAME_WIDTH, int(h_frame_size.get())) - cap.set(cv2.CAP_PROP_FRAME_HEIGHT, int(v_frame_size.get())) - cap.set(cv2.CAP_PROP_BUFFERSIZE, 0) - - if cap.isOpened(): - t1 = threading.Thread(target=process_frames) - t1.start() - - while True: - _, frame = cap.read() - - if frame is None: - continue - - queue.append(frame) - - if (len(queue) > 5): - queue.pop(0) - - cap.release() \ No newline at end of file