blob: ccba681f57c68d47ac5059b27ebab627eeb5ab09 [file] [log] [blame]
Nikolai Sohmers8412fe52024-06-09 18:01:18 -07001load("//aos:config.bzl", "aos_config")
James Kuszmauld938d332024-05-15 20:47:19 -07002load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
3
Nikolai Sohmers69ecb912024-06-08 14:06:22 -07004package(default_visibility = ["//visibility:public"])
5
6static_flatbuffer(
7 name = "swerve_drivetrain_goal_fbs",
8 srcs = ["swerve_drivetrain_goal.fbs"],
9)
10
11static_flatbuffer(
12 name = "swerve_drivetrain_status_fbs",
13 srcs = ["swerve_drivetrain_status.fbs"],
14 deps = ["//frc971/control_loops:profiled_subsystem_fbs"],
15)
16
James Kuszmauld938d332024-05-15 20:47:19 -070017static_flatbuffer(
18 name = "swerve_drivetrain_output_fbs",
19 srcs = ["swerve_drivetrain_output.fbs"],
James Kuszmauld938d332024-05-15 20:47:19 -070020 deps = ["//frc971/control_loops:can_talonfx_fbs"],
21)
22
23static_flatbuffer(
Nikolai Sohmers3f2a5072024-06-08 14:05:59 -070024 name = "swerve_drivetrain_can_position_fbs",
25 srcs = ["swerve_drivetrain_can_position.fbs"],
Nikolai Sohmers3f2a5072024-06-08 14:05:59 -070026 deps = ["//frc971/control_loops:can_talonfx_fbs"],
27)
28
29static_flatbuffer(
James Kuszmauld938d332024-05-15 20:47:19 -070030 name = "swerve_drivetrain_position_fbs",
31 srcs = ["swerve_drivetrain_position.fbs"],
James Kuszmauld938d332024-05-15 20:47:19 -070032 deps = ["//frc971/control_loops:control_loops_fbs"],
33)
34
Austin Schuh999a19e2024-05-04 14:52:39 -070035py_binary(
36 name = "simulation",
37 srcs = [
38 "simulation.py",
39 ],
40 deps = [
41 "//frc971/control_loops/python:controls",
42 "@pip//matplotlib",
43 "@pip//numpy",
44 "@pip//pygobject",
45 "@pip//sympy",
46 ],
47)
Nikolai Sohmers8412fe52024-06-09 18:01:18 -070048
49cc_library(
50 name = "swerve_control_loops",
51 srcs = ["swerve_control_loops.cc"],
52 hdrs = ["swerve_control_loops.h"],
53 target_compatible_with = ["@platforms//os:linux"],
54 deps = [
55 ":swerve_drivetrain_can_position_fbs",
56 ":swerve_drivetrain_goal_fbs",
57 ":swerve_drivetrain_output_fbs",
58 ":swerve_drivetrain_position_fbs",
59 ":swerve_drivetrain_status_fbs",
60 "//frc971/control_loops:control_loop",
61 ],
62)
63
64cc_test(
65 name = "swerve_control_test",
66 srcs = ["swerve_control_test.cc"],
67 data = [
68 ":aos_config",
69 ],
70 target_compatible_with = ["@platforms//os:linux"],
71 deps = [
72 ":swerve_control_loops",
73 ":swerve_drivetrain_can_position_fbs",
74 ":swerve_drivetrain_goal_fbs",
75 ":swerve_drivetrain_output_fbs",
76 ":swerve_drivetrain_position_fbs",
77 ":swerve_drivetrain_status_fbs",
78 "//aos/events:shm_event_loop",
79 "//aos/testing:googletest",
80 "//frc971/control_loops:control_loop_test",
81 "//frc971/control_loops:state_feedback_loop",
82 "//frc971/control_loops:team_number_test_environment",
83 ],
84)
85
86aos_config(
87 name = "aos_config",
88 src = "swerve.json",
89 flatbuffers = [
90 ":swerve_drivetrain_goal_fbs",
91 ":swerve_drivetrain_output_fbs",
92 ":swerve_drivetrain_position_fbs",
93 ":swerve_drivetrain_can_position_fbs",
94 ":swerve_drivetrain_status_fbs",
95 ],
96 target_compatible_with = ["@platforms//os:linux"],
97 deps = ["//frc971/input:aos_config"],
98)