This commit is contained in:
trung09122002
2026-09-19 19:10:14 +07:00
parent 6c3d5bfdc1
commit 3c275cf0af
18 changed files with 2304 additions and 825 deletions

View File

@@ -575,6 +575,27 @@ void Runtime::Join() {
#endif
if (web_) web_->Stop();
// ⚠️ DONG THIET BI O DAY, truoc khi ham nay tra ve.
//
// Driver that chay luong RIENG va goi callback vao ekf_, safety_, web_...
// Nhung `source_` (chu so huu driver) duoc khai bao TRUOC cac stage trong
// runtime.h, ma C++ huy thanh vien theo thu tu NGUOC -- tuc stage chet
// truoc, driver chet sau. Trong khoang do luong driver van dang goi vao bo
// nho vua duoc giai phong.
//
// Da xay ra that tren robot: `malloc(): unsorted double linked list
// corrupted` moi lan Ctrl-C.
//
// Sim va replay khong lo dieu nay vi RequestStop() dung vong Run() cua
// chung truoc; driver that khong co vong Run() nao de dung.
if (camera_ != nullptr) camera_->Close();
if (mcu_ != nullptr) mcu_->Close();
if (lidar_ != nullptr) lidar_->Close();
// Base DONG CUOI: SetVelocity(0) o tren vua gui lenh dung, va Close() cua
// no con tat power stage. Dong no truoc cac driver kia khong sai, nhung de
// cuoi thi cua so "da dung nhung chua tat dien" ngan nhat.
if (base_ != nullptr) base_->Close();
}
void Runtime::SafetyLoop() {