Skip to content

Commit c2f42d5

Browse files
committed
Fix the issue with the corruption
1 parent 5108030 commit c2f42d5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

joint_state_broadcaster/src/joint_state_broadcaster.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,13 @@ controller_interface::return_type JointStateBroadcaster::update(
420420
const auto & opt = state_interfaces_[i].get_optional(0);
421421
if (opt.has_value())
422422
{
423-
*mapped_values_[map_index++] = opt.value();
423+
*mapped_values_[map_index] = opt.value();
424424
}
425+
// Always advance map_index for every DOUBLE interface, regardless of whether the read
426+
// succeeded. If we only advance on success, a temporary read failure (e.g. lock contention
427+
// on a chained interface) causes all subsequent interfaces to be written into the wrong
428+
// mapped_values_ slots, corrupting the published joint states.
429+
++map_index;
425430
}
426431
}
427432

0 commit comments

Comments
 (0)