diff --git a/include/wrp_sdk/platforms/common/mobile_base.hpp b/include/wrp_sdk/platforms/common/mobile_base.hpp index 01f48bb..6e12a6a 100644 --- a/include/wrp_sdk/platforms/common/mobile_base.hpp +++ b/include/wrp_sdk/platforms/common/mobile_base.hpp @@ -31,6 +31,8 @@ class MobileBase { MobileBase(const MobileBase &hunter) = delete; MobileBase &operator=(const MobileBase &hunter) = delete; + void SetCmdTimeout(bool enable, uint32_t timeout_ms = 100); + // connect to roboot from CAN or serial void Connect(std::string dev_name, int32_t baud_rate = 0); @@ -50,6 +52,12 @@ class MobileBase { std::shared_ptr can_if_; std::shared_ptr serial_if_; + // timeout to be implemented in each vehicle + bool enable_timeout_ = true; + uint32_t timeout_ms_ = 100; + uint32_t watchdog_counter_ = 0; + virtual void CheckCmdTimeout(); + // command thread std::thread cmd_thread_; int32_t cmd_thread_period_ms_ = 10; diff --git a/src/platforms/mobile_base.cpp b/src/platforms/mobile_base.cpp index 639b970..4088020 100644 --- a/src/platforms/mobile_base.cpp +++ b/src/platforms/mobile_base.cpp @@ -67,7 +67,6 @@ void MobileBase::StartCmdThread() { void MobileBase::ControlLoop(int32_t period_ms) { StopWatch ctrl_sw; bool print_loop_freq = false; - static uint32_t iter_cnt = 0; while (true) { ctrl_sw.tic(); SendRobotCmd();