Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 1 | load("//aos:config.bzl", "aos_config") |
Ravago Jones | 2060ee6 | 2023-02-03 18:12:24 -0800 | [diff] [blame] | 2 | load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library") |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 3 | |
| 4 | genrule( |
| 5 | name = "genrule_drivetrain", |
| 6 | outs = [ |
| 7 | "drivetrain_dog_motor_plant.h", |
| 8 | "drivetrain_dog_motor_plant.cc", |
| 9 | "kalman_drivetrain_motor_plant.h", |
| 10 | "kalman_drivetrain_motor_plant.cc", |
| 11 | ], |
| 12 | cmd = "$(location //y2023/control_loops/python:drivetrain) $(OUTS)", |
| 13 | target_compatible_with = ["@platforms//os:linux"], |
| 14 | tools = [ |
| 15 | "//y2023/control_loops/python:drivetrain", |
| 16 | ], |
| 17 | ) |
| 18 | |
| 19 | genrule( |
| 20 | name = "genrule_polydrivetrain", |
| 21 | outs = [ |
| 22 | "polydrivetrain_dog_motor_plant.h", |
| 23 | "polydrivetrain_dog_motor_plant.cc", |
| 24 | "polydrivetrain_cim_plant.h", |
| 25 | "polydrivetrain_cim_plant.cc", |
| 26 | "hybrid_velocity_drivetrain.h", |
| 27 | "hybrid_velocity_drivetrain.cc", |
| 28 | ], |
| 29 | cmd = "$(location //y2023/control_loops/python:polydrivetrain) $(OUTS)", |
| 30 | target_compatible_with = ["@platforms//os:linux"], |
| 31 | tools = [ |
| 32 | "//y2023/control_loops/python:polydrivetrain", |
| 33 | ], |
| 34 | ) |
| 35 | |
| 36 | cc_library( |
| 37 | name = "polydrivetrain_plants", |
| 38 | srcs = [ |
| 39 | "drivetrain_dog_motor_plant.cc", |
| 40 | "hybrid_velocity_drivetrain.cc", |
| 41 | "kalman_drivetrain_motor_plant.cc", |
| 42 | "polydrivetrain_dog_motor_plant.cc", |
| 43 | ], |
| 44 | hdrs = [ |
| 45 | "drivetrain_dog_motor_plant.h", |
| 46 | "hybrid_velocity_drivetrain.h", |
| 47 | "kalman_drivetrain_motor_plant.h", |
| 48 | "polydrivetrain_dog_motor_plant.h", |
| 49 | ], |
| 50 | target_compatible_with = ["@platforms//os:linux"], |
| 51 | visibility = ["//visibility:public"], |
| 52 | deps = [ |
| 53 | "//frc971/control_loops:hybrid_state_feedback_loop", |
| 54 | "//frc971/control_loops:state_feedback_loop", |
| 55 | ], |
| 56 | ) |
| 57 | |
| 58 | cc_library( |
| 59 | name = "drivetrain_base", |
| 60 | srcs = [ |
| 61 | "drivetrain_base.cc", |
| 62 | ], |
| 63 | hdrs = [ |
| 64 | "drivetrain_base.h", |
| 65 | ], |
| 66 | target_compatible_with = ["@platforms//os:linux"], |
| 67 | visibility = ["//visibility:public"], |
| 68 | deps = [ |
| 69 | ":polydrivetrain_plants", |
| 70 | "//frc971:shifter_hall_effect", |
| 71 | "//frc971/control_loops/drivetrain:drivetrain_config", |
| 72 | ], |
| 73 | ) |
| 74 | |
| 75 | cc_binary( |
| 76 | name = "drivetrain", |
| 77 | srcs = [ |
| 78 | "drivetrain_main.cc", |
| 79 | ], |
| 80 | target_compatible_with = ["@platforms//os:linux"], |
| 81 | visibility = ["//visibility:public"], |
| 82 | deps = [ |
| 83 | ":drivetrain_base", |
James Kuszmaul | c29f457 | 2023-02-25 17:02:33 -0800 | [diff] [blame] | 84 | ":target_selector", |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 85 | "//aos:init", |
| 86 | "//aos/events:shm_event_loop", |
| 87 | "//frc971/control_loops/drivetrain:drivetrain_lib", |
James Kuszmaul | 04a343c | 2023-02-20 16:38:22 -0800 | [diff] [blame] | 88 | "//frc971/control_loops/drivetrain/localization:puppet_localizer", |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 89 | ], |
| 90 | ) |
| 91 | |
| 92 | aos_config( |
| 93 | name = "simulation_config", |
| 94 | src = "drivetrain_simulation_config.json", |
| 95 | target_compatible_with = ["@platforms//os:linux"], |
| 96 | visibility = ["//visibility:public"], |
| 97 | deps = [ |
| 98 | "//frc971/control_loops/drivetrain:simulation_channels", |
| 99 | "//y2023:aos_config", |
| 100 | ], |
| 101 | ) |
| 102 | |
| 103 | cc_binary( |
| 104 | name = "trajectory_generator", |
| 105 | srcs = [ |
| 106 | "trajectory_generator_main.cc", |
| 107 | ], |
| 108 | target_compatible_with = ["@platforms//os:linux"], |
| 109 | visibility = ["//visibility:public"], |
| 110 | deps = [ |
| 111 | ":drivetrain_base", |
| 112 | "//aos:init", |
| 113 | "//aos/events:shm_event_loop", |
| 114 | "//frc971/control_loops/drivetrain:trajectory_generator", |
| 115 | ], |
| 116 | ) |
Ravago Jones | 2060ee6 | 2023-02-03 18:12:24 -0800 | [diff] [blame] | 117 | |
| 118 | flatbuffer_cc_library( |
| 119 | name = "drivetrain_can_position_fbs", |
| 120 | srcs = [ |
| 121 | "drivetrain_can_position.fbs", |
| 122 | ], |
| 123 | gen_reflections = 1, |
| 124 | visibility = ["//visibility:public"], |
| 125 | ) |
James Kuszmaul | db730d7 | 2023-02-25 16:01:27 -0800 | [diff] [blame] | 126 | |
| 127 | flatbuffer_cc_library( |
| 128 | name = "target_selector_hint_fbs", |
| 129 | srcs = [ |
| 130 | ":target_selector_hint.fbs", |
| 131 | ], |
| 132 | gen_reflections = 1, |
| 133 | visibility = ["//visibility:public"], |
| 134 | ) |
James Kuszmaul | c29f457 | 2023-02-25 17:02:33 -0800 | [diff] [blame] | 135 | |
| 136 | cc_library( |
| 137 | name = "target_selector", |
| 138 | srcs = ["target_selector.cc"], |
| 139 | hdrs = ["target_selector.h"], |
| 140 | deps = [ |
| 141 | ":target_selector_hint_fbs", |
| 142 | "//aos/containers:sized_array", |
| 143 | "//aos/events:event_loop", |
| 144 | "//frc971/constants:constants_sender_lib", |
| 145 | "//frc971/control_loops:pose", |
| 146 | "//frc971/control_loops/drivetrain:localizer", |
| 147 | "//frc971/input:joystick_state_fbs", |
| 148 | "//y2023/constants:constants_fbs", |
| 149 | ], |
| 150 | ) |
| 151 | |
| 152 | cc_test( |
| 153 | name = "target_selector_test", |
| 154 | srcs = ["target_selector_test.cc"], |
| 155 | data = ["//y2023:aos_config"], |
| 156 | deps = [ |
| 157 | ":target_selector", |
| 158 | "//aos/events:simulated_event_loop", |
| 159 | "//aos/testing:googletest", |
| 160 | "//frc971/input:joystick_state_fbs", |
| 161 | "//y2023/constants:simulated_constants_sender", |
| 162 | ], |
| 163 | ) |