-
Notifications
You must be signed in to change notification settings - Fork 13
Description
I launched the node HdlLocalizationNodelet with robot odometry prediction enabled. It died and reported:
terminate called after throwing an instance of 'std::runtime_error'
what(): can't compare times with different time sourcesAfter some debugging, I found that this error was directly come from line 261 of the file hdl_localization_nodelet.cpp:
hdl-localization-ROS2/hdl_localization/apps/hdl_localization_nodelet.cpp
Lines 260 to 261 in 35de917
| rclcpp::Time last_correction_time = pose_estimator->last_correction_time(); | |
| if (enable_robot_odometry_prediction && last_correction_time != rclcpp::Time((int64_t)0, get_clock()->get_clock_type())) { |
I found that the member PoseEstimator::last_correction_stamp is not explicitly initialized in the constructor of PoseEstimator, and the default constructor of rclcpp::Time will sets its type to RCL_SYSTEM_TIME. Therefore, when the program first comes to line 261, the last_correction_time is of type RCL_SYSTEM_TIME while the right side of the comparison is of type RCL_ROS_TIME, leading to the error.
I think PoseEstimator::last_correction_stamp might need an initialization similar to that of PoseEstimator::prev_stamp, for example:
last_correction_stamp = rclcpp::Time((int64_t)0, init_stamp.get_clock_type());The program did work after adding this line in the constructor.