feat: 完成四轮子独立pid调试
This commit is contained in:
@@ -786,8 +786,10 @@ pub mod hil {
|
||||
|
||||
let mut policy = MotorPolicy::new();
|
||||
policy.configure(config.esc.esc_id, config.esc.current_limit, VelocityGains::ZERO);
|
||||
let runtime_guard = runtime.enter();
|
||||
let bus = EscBus::spawn(link, vec![config.esc.clone()], config.bus.clone(), policy)
|
||||
.map_err(|e| BenchError::Bus(e.to_string()))?;
|
||||
drop(runtime_guard);
|
||||
let motor = bus
|
||||
.motor(esc_id)
|
||||
.ok_or_else(|| BenchError::Bus(format!("esc {esc_id} missing from the bus")))?
|
||||
@@ -938,6 +940,22 @@ pub mod hil {
|
||||
open_link("ignored", 2_000_000, crate::CanSpeed::M1, Some("can-not-real"));
|
||||
assert!(missing_interface.is_err(), "不存在的 CAN 接口必须报错");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn evaluator_spawns_bus_without_an_outer_tokio_runtime() {
|
||||
let (link, peer) = can::CanLink::pair(8);
|
||||
// 测试只关心 runtime 启动;立刻关闭对端,避免假链路堵住 1kHz 命令发送。
|
||||
drop(peer);
|
||||
let mut config = config();
|
||||
config.startup_timeout = Duration::from_millis(1);
|
||||
|
||||
let result = BenchEvaluator::open(link, config);
|
||||
|
||||
assert!(
|
||||
matches!(result, Err(BenchError::NoFeedback { esc_id: 1, .. })),
|
||||
"应当在自有 runtime 中启动总线并因无反馈返回错误"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user