mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
tested timeout
This commit is contained in:
@@ -17,7 +17,6 @@ namespace westonrobot {
|
||||
void HunterBase::SendRobotCmd() {
|
||||
static uint8_t cmd_count = 0;
|
||||
SendMotionCmd(cmd_count++);
|
||||
FeedCmdTimeoutWatchdog();
|
||||
}
|
||||
|
||||
void HunterBase::SendMotionCmd(uint8_t count) {
|
||||
@@ -81,6 +80,8 @@ void HunterBase::SetMotionCommand(
|
||||
current_motion_cmd_.angular_velocity = static_cast<int8_t>(
|
||||
steering_angle / HunterMotionCmd::max_steering_angle * 100.0);
|
||||
current_motion_cmd_.fault_clear_flag = fault_clr_flag;
|
||||
|
||||
FeedCmdTimeoutWatchdog();
|
||||
}
|
||||
|
||||
void HunterBase::ParseCANFrame(can_frame *rx_frame) {
|
||||
|
||||
@@ -74,14 +74,16 @@ void MobileBase::ControlLoop(int32_t period_ms) {
|
||||
timeout_iter_num = static_cast<uint32_t>(timeout_ms_ / period_ms);
|
||||
std::cout << "Timeout iteration number: " << timeout_iter_num << std::endl;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
ctrl_sw.tic();
|
||||
if (enable_timeout_) {
|
||||
++watchdog_counter_;
|
||||
if (watchdog_counter_ < timeout_iter_num)
|
||||
if (watchdog_counter_ < timeout_iter_num) {
|
||||
SendRobotCmd();
|
||||
else
|
||||
++watchdog_counter_;
|
||||
} else {
|
||||
std::cout << "Warning: cmd timeout, not sent to robot" << std::endl;
|
||||
}
|
||||
} else {
|
||||
SendRobotCmd();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ void ScoutBase::SendRobotCmd() {
|
||||
static uint8_t light_cmd_count = 0;
|
||||
SendMotionCmd(cmd_count++);
|
||||
if (light_ctrl_requested_) SendLightCmd(light_cmd_count++);
|
||||
FeedCmdTimeoutWatchdog();
|
||||
}
|
||||
|
||||
void ScoutBase::SendMotionCmd(uint8_t count) {
|
||||
@@ -56,12 +55,12 @@ void ScoutBase::SendMotionCmd(uint8_t count) {
|
||||
can_frame m_frame;
|
||||
EncodeScoutMsgToCAN(&m_msg, &m_frame);
|
||||
can_if_->SendFrame(m_frame);
|
||||
std::cout << "CAN cmd sent" << std::endl;
|
||||
// std::cout << "CAN cmd sent" << std::endl;
|
||||
} else {
|
||||
// send to serial port
|
||||
EncodeScoutMsgToUART(&m_msg, tx_buffer_, &tx_cmd_len_);
|
||||
serial_if_->SendBytes(tx_buffer_, tx_cmd_len_);
|
||||
std::cout << "serial cmd sent" << std::endl;
|
||||
// std::cout << "serial cmd sent" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +160,8 @@ void ScoutBase::SetMotionCommand(
|
||||
current_motion_cmd_.angular_velocity = static_cast<int8_t>(
|
||||
angular_vel / ScoutMotionCmd::max_angular_velocity * 100.0);
|
||||
current_motion_cmd_.fault_clear_flag = fault_clr_flag;
|
||||
|
||||
FeedCmdTimeoutWatchdog();
|
||||
}
|
||||
|
||||
void ScoutBase::SetLightCommand(ScoutLightCmd cmd) {
|
||||
|
||||
Reference in New Issue
Block a user