blob: 845575f6e8da6a9793b0356f3f6274403d0dda3a [file] [log] [blame]
Austin Schuh378483c2019-01-20 16:36:40 -08001load("//aos/build:queues.bzl", "queue_library")
James Kuszmaul1057ce82019-02-09 17:58:24 -08002load("//tools/build_rules:select.bzl", "cpu_select", "compiler_select")
Austin Schuh378483c2019-01-20 16:36:40 -08003
4genrule(
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 //y2019/control_loops/python:drivetrain) $(OUTS)",
13 tools = [
14 "//y2019/control_loops/python:drivetrain",
15 ],
16)
17
18genrule(
19 name = "genrule_polydrivetrain",
20 outs = [
21 "polydrivetrain_dog_motor_plant.h",
22 "polydrivetrain_dog_motor_plant.cc",
23 "polydrivetrain_cim_plant.h",
24 "polydrivetrain_cim_plant.cc",
25 "hybrid_velocity_drivetrain.h",
26 "hybrid_velocity_drivetrain.cc",
27 ],
28 cmd = "$(location //y2019/control_loops/python:polydrivetrain) $(OUTS)",
29 tools = [
30 "//y2019/control_loops/python:polydrivetrain",
31 ],
32)
33
34cc_library(
35 name = "polydrivetrain_plants",
36 srcs = [
37 "drivetrain_dog_motor_plant.cc",
38 "hybrid_velocity_drivetrain.cc",
39 "kalman_drivetrain_motor_plant.cc",
40 "polydrivetrain_dog_motor_plant.cc",
41 ],
42 hdrs = [
43 "drivetrain_dog_motor_plant.h",
44 "hybrid_velocity_drivetrain.h",
45 "kalman_drivetrain_motor_plant.h",
46 "polydrivetrain_dog_motor_plant.h",
47 ],
48 visibility = ["//visibility:public"],
49 deps = [
50 "//frc971/control_loops:hybrid_state_feedback_loop",
51 "//frc971/control_loops:state_feedback_loop",
52 ],
53)
54
55cc_library(
56 name = "drivetrain_base",
57 srcs = [
58 "drivetrain_base.cc",
59 ],
60 hdrs = [
61 "drivetrain_base.h",
62 ],
63 visibility = ["//visibility:public"],
64 deps = [
65 ":polydrivetrain_plants",
66 "//frc971:shifter_hall_effect",
67 "//frc971/control_loops/drivetrain:drivetrain_config",
68 ],
69)
70
71cc_binary(
72 name = "drivetrain",
73 srcs = [
74 "drivetrain_main.cc",
75 ],
76 visibility = ["//visibility:public"],
77 deps = [
78 ":drivetrain_base",
James Kuszmaul09f564a2019-02-18 17:37:09 -080079 ":event_loop_localizer",
Austin Schuh378483c2019-01-20 16:36:40 -080080 "//aos:init",
Austin Schuh55a13dc2019-01-27 22:39:03 -080081 "//aos/events:shm-event-loop",
Austin Schuh378483c2019-01-20 16:36:40 -080082 "//frc971/control_loops/drivetrain:drivetrain_lib",
83 ],
84)
James Kuszmaul57c7c9b2019-01-27 16:16:01 -080085
James Kuszmaul09f564a2019-02-18 17:37:09 -080086queue_library(
James Kuszmaul7d1ef442019-03-23 20:20:50 -070087 name = "target_selector_queue",
88 srcs = [
89 "target_selector.q",
90 ],
91 visibility = ["//visibility:public"],
92)
93
94queue_library(
James Kuszmaul09f564a2019-02-18 17:37:09 -080095 name = "camera_queue",
96 srcs = [
97 "camera.q",
98 ],
Brian Silvermanc41fb862019-03-02 21:14:46 -080099 visibility = ["//visibility:public"],
James Kuszmaul09f564a2019-02-18 17:37:09 -0800100)
101
James Kuszmaul57c7c9b2019-01-27 16:16:01 -0800102cc_library(
103 name = "camera",
104 srcs = ["camera.h"],
James Kuszmaul22c5ab32019-02-09 14:45:58 -0800105 visibility = ["//y2019:__pkg__"],
James Kuszmaul57c7c9b2019-01-27 16:16:01 -0800106 deps = [
107 "//aos/containers:sized_array",
108 "//frc971/control_loops:pose",
109 ],
110)
111
112cc_test(
113 name = "camera_test",
114 srcs = ["camera_test.cc"],
115 deps = [
116 ":camera",
117 "//aos/testing:googletest",
118 ],
119)
James Kuszmaul1057ce82019-02-09 17:58:24 -0800120
121cc_library(
122 name = "localizer",
123 hdrs = ["localizer.h"],
124 deps = [
125 ":camera",
126 "//frc971/control_loops:pose",
127 "//frc971/control_loops/drivetrain:hybrid_ekf",
128 ],
129)
130
James Kuszmaul09f564a2019-02-18 17:37:09 -0800131cc_library(
James Kuszmauld73d0252019-03-02 14:57:09 -0800132 name = "target_selector",
133 srcs = ["target_selector.cc"],
134 hdrs = ["target_selector.h"],
135 deps = [
136 ":camera",
James Kuszmaul7d1ef442019-03-23 20:20:50 -0700137 ":target_selector_queue",
James Kuszmauld73d0252019-03-02 14:57:09 -0800138 "//frc971/control_loops:pose",
139 "//frc971/control_loops/drivetrain:localizer",
140 "//y2019:constants",
James Kuszmaul7d1ef442019-03-23 20:20:50 -0700141 "//y2019/control_loops/superstructure:superstructure_queue",
James Kuszmauld73d0252019-03-02 14:57:09 -0800142 ],
143)
144
145cc_test(
146 name = "target_selector_test",
147 srcs = ["target_selector_test.cc"],
148 deps = [
149 ":target_selector",
Austin Schuhc087b102019-05-12 15:33:12 -0700150 "//aos/events:shm-event-loop",
James Kuszmauld73d0252019-03-02 14:57:09 -0800151 "//aos/testing:googletest",
James Kuszmaul7d1ef442019-03-23 20:20:50 -0700152 "//aos/testing:test_shm",
James Kuszmauld73d0252019-03-02 14:57:09 -0800153 ],
154)
155
156cc_library(
James Kuszmaul09f564a2019-02-18 17:37:09 -0800157 name = "event_loop_localizer",
158 srcs = ["event_loop_localizer.cc"],
159 hdrs = ["event_loop_localizer.h"],
160 deps = [
161 ":camera_queue",
162 ":localizer",
James Kuszmauld73d0252019-03-02 14:57:09 -0800163 ":target_selector",
James Kuszmaul09f564a2019-02-18 17:37:09 -0800164 "//frc971/control_loops/drivetrain:localizer",
165 "//y2019:constants",
166 ],
167)
168
James Kuszmaul1057ce82019-02-09 17:58:24 -0800169cc_test(
170 name = "localizer_test",
171 srcs = ["localizer_test.cc"],
172 defines =
173 cpu_select({
174 "amd64": [
175 "SUPPORT_PLOT=1",
176 ],
177 "arm": [],
178 }),
179 linkstatic = True,
180 deps = [
181 ":localizer",
182 ":drivetrain_base",
183 "//aos/testing:googletest",
184 "//aos/testing:random_seed",
185 "//aos/testing:test_shm",
186 "//frc971/control_loops/drivetrain:trajectory",
187 "//y2019:constants",
188 "//frc971/control_loops/drivetrain:splinedrivetrain",
189 "@com_github_gflags_gflags//:gflags",
190 ] + cpu_select({
191 "amd64": [
192 "//third_party/matplotlib-cpp",
193 ],
194 "arm": [],
195 }),
196)
James Kuszmaul09f564a2019-02-18 17:37:09 -0800197
198cc_test(
199 name = "localized_drivetrain_test",
200 srcs = ["localized_drivetrain_test.cc"],
201 deps = [
202 ":camera_queue",
203 ":drivetrain_base",
204 ":event_loop_localizer",
205 ":localizer",
206 "//aos/controls:control_loop_test",
Austin Schuh8a633d52019-05-12 15:04:01 -0700207 "//aos/events:shm-event-loop",
James Kuszmaul09f564a2019-02-18 17:37:09 -0800208 "//aos/network:team_number",
209 "//frc971/control_loops:team_number_test_environment",
210 "//frc971/control_loops/drivetrain:drivetrain_lib",
211 "//frc971/control_loops/drivetrain:drivetrain_test_lib",
212 ],
213)