refactor: enforce layered crates and Rust audit gates
This commit is contained in:
@@ -4,6 +4,21 @@
|
||||
[can]
|
||||
interface = "can0"
|
||||
|
||||
# DJI DT7 + DR16 遥控接收机。没有遥控时删除整个 [remote] 段,守护进程会保持静止。
|
||||
[remote]
|
||||
kind = "dr16"
|
||||
device = "/dev/ttyS2"
|
||||
# 合法 D-BUS 帧断流超时(毫秒);超时立即失能停车。
|
||||
timeout_ms = 100
|
||||
# 摇杆满量程死区(0..0.5),死区后使用平方响应曲线。
|
||||
deadband = 0.05
|
||||
# 从零到满量程的逐轴速度斜坡(毫秒);S1 失能、断流和超时立即归零。
|
||||
ramp_ms = 500
|
||||
# 实车方向相反时置 true,不需要改代码。
|
||||
invert_vx = false
|
||||
invert_vy = false
|
||||
invert_omega = false
|
||||
|
||||
[chassis]
|
||||
# 控制循环周期(毫秒)。C620 期望 1kHz 命令。
|
||||
control_period_ms = 1
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
# Machine-readable dependency and layer policy.
|
||||
policy_version = 1
|
||||
|
||||
[layers]
|
||||
"contract/can" = 0
|
||||
"contract/imu" = 0
|
||||
"protocol/imu" = 1
|
||||
"protocol/motor" = 1
|
||||
"protocol/remote" = 1
|
||||
"transport/can" = 2
|
||||
"transport/serial" = 2
|
||||
"device/imu" = 3
|
||||
"device/motor" = 3
|
||||
"device/remote" = 3
|
||||
"control/algorithm" = 4
|
||||
"control/chassis" = 4
|
||||
"device/esc" = 4
|
||||
"experiment/trace" = 5
|
||||
"control/motor" = 6
|
||||
"model/motor" = 7
|
||||
"simulation/motor" = 8
|
||||
"tooling/tuning" = 9
|
||||
"config/chassis" = 10
|
||||
"application/bench" = 11
|
||||
"application/daemon" = 12
|
||||
"application/tools" = 13
|
||||
"application/tuning" = 13
|
||||
"verification/integration" = 14
|
||||
|
||||
[forbidden.normal]
|
||||
esc_bus = ["motor-control", "pid"]
|
||||
bench = ["tuning"]
|
||||
sim_harness = ["tuning"]
|
||||
|
||||
[trait_boundaries]
|
||||
protocol_motor = ["MotorProtocol", "EffortScale", "FeedbackFields"]
|
||||
device_motor = ["MotorSpec", "MotorFeedback", "EffortDrive", "VelocityDrive", "PositionDrive", "Disable"]
|
||||
model_motor = ["MotorPlant", "DcModelSpec", "VoltageModelSpec"]
|
||||
esc_bus_forbidden_symbols = ["MotorKind", "EscModel"]
|
||||
|
||||
[packages."bench"]
|
||||
path = "crates/application/bench"
|
||||
layer = "application/bench"
|
||||
rank = 11
|
||||
normal = ["can", "esc-bus", "experiment", "motor", "motor-control", "slcan", "socketcan"]
|
||||
dev = []
|
||||
external = ["anyhow", "thiserror", "tokio", "tracing"]
|
||||
dev_external = ["tokio"]
|
||||
|
||||
[packages."can"]
|
||||
path = "crates/contract/can"
|
||||
layer = "contract/can"
|
||||
rank = 0
|
||||
normal = []
|
||||
dev = []
|
||||
external = ["tokio"]
|
||||
dev_external = ["tokio"]
|
||||
|
||||
[packages."chassis-config"]
|
||||
path = "crates/config/chassis"
|
||||
layer = "config/chassis"
|
||||
rank = 10
|
||||
normal = ["esc-bus", "mecanum", "motor", "motor-control", "motor-protocol"]
|
||||
dev = []
|
||||
external = ["serde", "thiserror", "toml"]
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."chassis-tune"]
|
||||
path = "crates/application/tuning"
|
||||
layer = "application/tuning"
|
||||
rank = 13
|
||||
normal = ["bench", "can", "chassis-config", "esc-bus", "experiment", "motor", "motor-control", "motor-model", "motor-protocol", "sim-harness", "slcan", "socketcan", "tuning"]
|
||||
dev = []
|
||||
external = ["anyhow", "argmin", "argmin-math", "clap", "csv", "indicatif", "plotters", "rand", "rayon", "serde", "serde_json", "thiserror", "tokio", "toml", "tracing", "tracing-subscriber"]
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."chassisd"]
|
||||
path = "crates/application/daemon"
|
||||
layer = "application/daemon"
|
||||
rank = 12
|
||||
normal = ["can", "chassis-config", "dr16", "dr16-protocol", "esc-bus", "mecanum", "motor", "motor-control", "sim-harness", "socketcan"]
|
||||
dev = []
|
||||
external = ["clap", "tokio", "tracing", "tracing-subscriber"]
|
||||
dev_external = ["approx", "tokio"]
|
||||
|
||||
[packages."delta10"]
|
||||
path = "crates/device/imu"
|
||||
layer = "device/imu"
|
||||
rank = 3
|
||||
normal = ["can", "delta10-protocol", "imu"]
|
||||
dev = []
|
||||
external = ["thiserror", "tokio"]
|
||||
dev_external = []
|
||||
|
||||
[packages."delta10-protocol"]
|
||||
path = "crates/protocol/imu"
|
||||
layer = "protocol/imu"
|
||||
rank = 1
|
||||
normal = ["can", "imu"]
|
||||
dev = []
|
||||
external = ["thiserror"]
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."dr16"]
|
||||
path = "crates/device/remote"
|
||||
layer = "device/remote"
|
||||
rank = 3
|
||||
normal = ["dr16-protocol"]
|
||||
dev = []
|
||||
external = ["serial", "tokio", "tracing"]
|
||||
dev_external = ["tokio"]
|
||||
|
||||
[packages."dr16-protocol"]
|
||||
path = "crates/protocol/remote"
|
||||
layer = "protocol/remote"
|
||||
rank = 1
|
||||
normal = []
|
||||
dev = []
|
||||
external = ["thiserror"]
|
||||
dev_external = ["proptest"]
|
||||
|
||||
[packages."esc-bus"]
|
||||
path = "crates/device/esc"
|
||||
layer = "device/esc"
|
||||
rank = 4
|
||||
normal = ["can", "motor", "motor-protocol"]
|
||||
dev = []
|
||||
external = ["thiserror", "tokio", "tracing"]
|
||||
dev_external = ["approx", "tokio"]
|
||||
|
||||
[packages."experiment"]
|
||||
path = "crates/experiment/trace"
|
||||
layer = "experiment/trace"
|
||||
rank = 5
|
||||
normal = []
|
||||
dev = []
|
||||
external = []
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."imu"]
|
||||
path = "crates/contract/imu"
|
||||
layer = "contract/imu"
|
||||
rank = 0
|
||||
normal = []
|
||||
dev = []
|
||||
external = []
|
||||
dev_external = []
|
||||
|
||||
[packages."integration-tests"]
|
||||
path = "crates/verification/integration"
|
||||
layer = "verification/integration"
|
||||
rank = 14
|
||||
normal = ["can", "esc-bus", "experiment", "motor", "motor-control", "motor-model", "motor-protocol", "sim-harness", "socketcan"]
|
||||
dev = []
|
||||
external = ["tokio"]
|
||||
dev_external = ["tokio"]
|
||||
|
||||
[packages."mecanum"]
|
||||
path = "crates/control/chassis"
|
||||
layer = "control/chassis"
|
||||
rank = 4
|
||||
normal = []
|
||||
dev = []
|
||||
external = []
|
||||
dev_external = ["approx", "proptest"]
|
||||
|
||||
[packages."motor"]
|
||||
path = "crates/device/motor"
|
||||
layer = "device/motor"
|
||||
rank = 3
|
||||
normal = ["can", "motor-protocol"]
|
||||
dev = []
|
||||
external = ["thiserror"]
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."motor-control"]
|
||||
path = "crates/control/motor"
|
||||
layer = "control/motor"
|
||||
rank = 6
|
||||
normal = ["motor", "pid"]
|
||||
dev = []
|
||||
external = []
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."motor-model"]
|
||||
path = "crates/model/motor"
|
||||
layer = "model/motor"
|
||||
rank = 7
|
||||
normal = ["motor-protocol"]
|
||||
dev = []
|
||||
external = []
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."motor-protocol"]
|
||||
path = "crates/protocol/motor"
|
||||
layer = "protocol/motor"
|
||||
rank = 1
|
||||
normal = ["can"]
|
||||
dev = []
|
||||
external = ["thiserror"]
|
||||
dev_external = ["approx", "proptest"]
|
||||
|
||||
[packages."pid"]
|
||||
path = "crates/control/algorithm"
|
||||
layer = "control/algorithm"
|
||||
rank = 4
|
||||
normal = []
|
||||
dev = []
|
||||
external = []
|
||||
dev_external = ["approx"]
|
||||
|
||||
[packages."sim-harness"]
|
||||
path = "crates/simulation/motor"
|
||||
layer = "simulation/motor"
|
||||
rank = 8
|
||||
normal = ["can", "experiment", "motor", "motor-control", "motor-model", "motor-protocol"]
|
||||
dev = []
|
||||
external = ["rand", "thiserror", "tokio", "tracing"]
|
||||
dev_external = ["approx", "tokio"]
|
||||
|
||||
[packages."slcan"]
|
||||
path = "crates/transport/serial"
|
||||
layer = "transport/serial"
|
||||
rank = 2
|
||||
normal = ["can"]
|
||||
dev = []
|
||||
external = ["serial", "slcan", "thiserror", "tokio", "tracing"]
|
||||
dev_external = ["tokio"]
|
||||
|
||||
[packages."socketcan"]
|
||||
path = "crates/transport/can"
|
||||
layer = "transport/can"
|
||||
rank = 2
|
||||
normal = ["can"]
|
||||
dev = []
|
||||
external = ["socketcan", "thiserror", "tokio", "tracing"]
|
||||
dev_external = ["tokio"]
|
||||
|
||||
[packages."spin"]
|
||||
path = "crates/application/tools"
|
||||
layer = "application/tools"
|
||||
rank = 13
|
||||
normal = ["bench", "dr16", "dr16-protocol", "esc-bus", "experiment", "mecanum", "motor", "motor-control", "slcan", "socketcan"]
|
||||
dev = []
|
||||
external = ["clap", "tokio", "tracing", "tracing-subscriber"]
|
||||
dev_external = ["tokio"]
|
||||
|
||||
[packages."tuning"]
|
||||
path = "crates/tooling/tuning"
|
||||
layer = "tooling/tuning"
|
||||
rank = 9
|
||||
normal = ["experiment", "motor-control", "motor-model", "motor-protocol", "pid", "sim-harness"]
|
||||
dev = []
|
||||
external = ["argmin", "argmin-math", "indicatif", "rand", "rayon", "serde", "thiserror", "toml", "tracing"]
|
||||
dev_external = ["approx", "proptest"]
|
||||
|
||||
[external_roles]
|
||||
tokio = ["contract", "transport", "device", "simulation", "tooling", "application", "verification"]
|
||||
socketcan = ["transport", "device", "application", "verification"]
|
||||
slcan = ["transport", "device", "application", "verification"]
|
||||
serial = ["transport", "device", "application", "verification"]
|
||||
thiserror = ["protocol", "transport", "device", "control", "model", "experiment", "simulation", "tooling", "config", "application", "verification"]
|
||||
tracing = ["transport", "device", "simulation", "tooling", "application", "verification"]
|
||||
tracing-subscriber = ["application", "verification"]
|
||||
serde = ["config", "tooling", "application", "verification"]
|
||||
toml = ["config", "tooling", "application", "verification"]
|
||||
clap = ["application", "verification"]
|
||||
argmin = ["tooling", "application", "verification"]
|
||||
argmin-math = ["tooling", "application", "verification"]
|
||||
rand = ["simulation", "tooling", "application", "verification"]
|
||||
rayon = ["tooling", "application", "verification"]
|
||||
csv = ["tooling", "application", "verification"]
|
||||
serde_json = ["tooling", "application", "verification"]
|
||||
indicatif = ["tooling", "application", "verification"]
|
||||
plotters = ["tooling", "application", "verification"]
|
||||
anyhow = ["tooling", "application", "verification"]
|
||||
approx = ["protocol", "transport", "device", "control", "model", "experiment", "simulation", "tooling", "config", "application", "verification"]
|
||||
proptest = ["protocol", "transport", "device", "control", "model", "experiment", "simulation", "tooling", "config", "application", "verification"]
|
||||
+6
-6
@@ -19,7 +19,7 @@
|
||||
# 不属于超参数,本文件**不接受**这些键(写了会直接报错)。它们只来自
|
||||
# chassis.toml 或显式 CLI——否则预设文件就成了绕过限流的口子。
|
||||
#
|
||||
# schema:见 crates/chassis-tune/src/preset.rs(version = 1,未知键报错)。
|
||||
# schema:见 crates/application/tuning/src/main.rs(version = 1,未知键报错)。
|
||||
|
||||
version = 1
|
||||
default_preset = "sim_bench_model"
|
||||
@@ -68,7 +68,7 @@ max_evals = 4000
|
||||
threads = 0
|
||||
|
||||
[preset.sim_bench_model.sim]
|
||||
plant = "gm3508-bench"
|
||||
plant = "bench"
|
||||
# 域随机化:单点模型调出来的增益对增益/时间常数/延迟高度敏感,
|
||||
# 因此默认在 8 个成员的集成上做鲁棒优化,而不是对着一条理想曲线最优化。
|
||||
ensemble = 8
|
||||
@@ -128,7 +128,7 @@ max_evals = 1000
|
||||
threads = 0
|
||||
|
||||
[preset.sim_ideal.sim]
|
||||
plant = "gm3508"
|
||||
plant = "ideal"
|
||||
# 理想模型本身就是确定的,单成员即可。
|
||||
ensemble = 1
|
||||
robust_weight = 0.0
|
||||
@@ -193,7 +193,7 @@ threads = 1
|
||||
|
||||
[preset.bench_noload.sim]
|
||||
# 真机后端不用这些,但保留"最接近台架的模型",方便先离线预演再上车。
|
||||
plant = "gm3508-bench"
|
||||
plant = "bench"
|
||||
ensemble = 8
|
||||
robust_weight = 0.5
|
||||
gain_pct = 0.2
|
||||
@@ -254,7 +254,7 @@ max_evals = 80
|
||||
threads = 1
|
||||
|
||||
[preset.bench_loaded.sim]
|
||||
plant = "gm3508-bench"
|
||||
plant = "bench"
|
||||
ensemble = 8
|
||||
robust_weight = 0.5
|
||||
gain_pct = 0.2
|
||||
@@ -314,7 +314,7 @@ max_evals = 40
|
||||
threads = 1
|
||||
|
||||
[preset.field_updown.sim]
|
||||
plant = "gm3508-bench"
|
||||
plant = "bench"
|
||||
ensemble = 8
|
||||
robust_weight = 0.5
|
||||
gain_pct = 0.2
|
||||
|
||||
Reference in New Issue
Block a user