Fix FixedLagSmoother crash on first optimization cycle in auto-start mode - #434
Open
ikhann wants to merge 1 commit into
Open
Fix FixedLagSmoother crash on first optimization cycle in auto-start mode#434ikhann wants to merge 1 commit into
ikhann wants to merge 1 commit into
Conversation
…mode The lag_expiration_ member was default-constructed, which produces an rclcpp::Time with the RCL_SYSTEM_TIME clock type. On the first optimization cycle it is passed to processQueue() before ever being assigned, where it is compared against RCL_ROS_TIME sensor stamps. rclcpp throws "can't compare times with different time sources" for such comparisons, the exception escapes the optimization thread, and the node aborts via std::terminate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the fixed-lag smoother is configured without any ignition sensors it auto-starts
("No ignition sensors were specified. Optimization will begin immediately."), and then aborts on
the very first sensor transaction:
Root cause
lag_expiration_is default-constructed, which produces anrclcpp::Timewith theRCL_SYSTEM_TIMEclock type. On the first optimization cycle it is passed toprocessQueue()before ever being assigned, and compared against
RCL_ROS_TIMEsensor stamps(
if (min_stamp < lag_expiration)), which throws. The exception escapes the optimization thread,so the whole node terminates.
Configurations with an ignition sensor return from
processQueue()before reaching thatcomparison, which is why this only manifests in auto-start mode. The existing
// TODO(CH3): We might have to make sure lag_expiration_ has been initialisedat theprocessQueue()call site, and the reset path (which already re-initializeslag_expiration_with
RCL_ROS_TIME), both point at this.Reproduction (before this patch)
Any config with a sensor model but no ignition sensor, e.g. Unicycle2D + Odometry2D, then:
ros2 run fuse_optimizers fixed_lag_smoother_node --ros-args -r __node:=fixed_lag_node --params-file autostart.yaml ros2 topic pub -r 2 /odom nav_msgs/msg/Odometry "{header: auto, pose: {pose: {position: {x: 1.0}}, covariance: [...]}}"The node aborts on the first optimization cycle after the first message.
Fix
Initialize the member with the
RCL_ROS_TIMEclock type, mirroring the existingstart_time_member two declarations below it. The now-resolved TODO comment is removed.