File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
rmf_fleet_adapter/src/rmf_fleet_adapter Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,22 @@ void estimate_path_traveling(
8888 assert (!state.path .empty ());
8989
9090 const std::size_t remaining_count = state.path .size ();
91+
92+ // Add bounds checking to prevent race condition crash
93+ if (remaining_count > info.waypoints .size ()) {
94+ RCLCPP_WARN (
95+ node->get_logger (),
96+ " Race condition detected: Robot reports %zu remaining waypoints but RMF plan only "
97+ " has %zu waypoints. This happens when robot still reports from old path while RMF has "
98+ " replanned a shorter path. Robot: %s, Fleet: %s. Using fallback estimation." ,
99+ remaining_count, info.waypoints .size (),
100+ info.robot_name .c_str (), info.fleet_name .c_str ());
101+
102+ // Fallback: estimate based on robot's current location relative to final goal
103+ estimate_state (node, state.location , info);
104+ return ;
105+ }
106+
91107 const std::size_t i_target_wp = info.waypoints .size () - remaining_count;
92108 info.target_plan_index = i_target_wp;
93109 const auto & target_wp = info.waypoints .at (i_target_wp);
You can’t perform that action at this time.
0 commit comments