Skip to content

Commit 84e90a1

Browse files
committed
Fix nan values into /odom topic when can bus is down
Signed-off-by: Gregory Mermet <g.mermet@ez-wheel.com>
1 parent f33f7e9 commit 84e90a1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/diff_drive_controller/DiffDriveController.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,15 @@ namespace ezw {
389389
if (ERROR_NONE != err_l) {
390390
ROS_ERROR(
391391
"Failed to get the NMT state for left motor, EZW_ERR: SMCService : "
392-
"Controller::getPDSState() return error code : %d",
392+
"Controller::getNMTState() return error code : %d",
393393
(int)err_l);
394394
}
395395

396396
err_r = m_right_controller.getNMTState(nmt_state_r);
397397
if (ERROR_NONE != err_r) {
398398
ROS_ERROR(
399399
"Failed to get the NMT state for right motor, EZW_ERR: SMCService : "
400-
"Controller::getPDSState() return error code : %d",
400+
"Controller::getNMTState() return error code : %d",
401401
(int)err_r);
402402
}
403403

@@ -533,6 +533,12 @@ namespace ezw {
533533
return;
534534
}
535535

536+
if (m_left_timestamp_prev_us == left_timestamp_us || m_right_timestamp_prev_us == right_timestamp_us) {
537+
// Nothing to do
538+
// Values have not changed (avoid "nan" values in /odom topic)
539+
return;
540+
}
541+
536542
// Encoder difference between t and t-1
537543
double d_dist_left_m = static_cast<double>(left_dist_now_mm - m_dist_left_prev_mm) / 1000.0;
538544
double d_dist_right_m = static_cast<double>(right_dist_now_mm - m_dist_right_prev_mm) / 1000.0;
@@ -911,6 +917,7 @@ namespace ezw {
911917
"Error reading SAFEIN_1 control word from left motor, EZW_ERR: SMCService : "
912918
"Controller::getSafetyControlWord() return error code : %d",
913919
(int)err);
920+
return;
914921
}
915922
bool safein1_l[6];
916923
safein1_l[0] = safety_control_word.safety_function_0;
@@ -926,6 +933,7 @@ namespace ezw {
926933
"Error reading SAFEIN_1 control word from right motor, EZW_ERR: SMCService : "
927934
"Controller::getSafetyControlWord() return error code : %d",
928935
(int)err);
936+
return;
929937
}
930938
bool safein1_r[6];
931939
safein1_r[0] = safety_control_word.safety_function_0;

0 commit comments

Comments
 (0)