-
Notifications
You must be signed in to change notification settings - Fork 6
feat(s57_layer): parameterize tide invalidation threshold #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,9 +63,24 @@ void S57Layer::onInitialize() | |
| declareParameter("sea_surface_frame", rclcpp::ParameterValue(sea_surface_frame_)); | ||
| node->get_parameter(name_+".sea_surface_frame", sea_surface_frame_); | ||
|
|
||
| const double default_tide_invalidate_threshold = tide_invalidate_threshold_; | ||
| declareParameter("tide_invalidate_threshold", rclcpp::ParameterValue(tide_invalidate_threshold_)); | ||
| node->get_parameter(name_+".tide_invalidate_threshold", tide_invalidate_threshold_); | ||
| // ROS 2 parameters are external input — validate. Negative would make | ||
| // every tide change exceed the threshold (continuous invalidation = | ||
| // costmap stalls); non-finite would silently disable invalidation. | ||
| if(!std::isfinite(tide_invalidate_threshold_) || tide_invalidate_threshold_ < 0.0) | ||
| { | ||
| RCLCPP_WARN_STREAM(logger_, | ||
| "Invalid tide_invalidate_threshold value " << tide_invalidate_threshold_ | ||
| << " m; using default " << default_tide_invalidate_threshold << " m instead."); | ||
| tide_invalidate_threshold_ = default_tide_invalidate_threshold; | ||
| } | ||
|
|
||
| if(!chart_datum_frame_.empty() && !sea_surface_frame_.empty()) | ||
| RCLCPP_INFO_STREAM(logger_, "Tide correction enabled: sea surface height in chart datum frame (" | ||
| << sea_surface_frame_ << " expressed in " << chart_datum_frame_ << ")"); | ||
| << sea_surface_frame_ << " expressed in " << chart_datum_frame_ | ||
| << "), invalidate threshold " << tide_invalidate_threshold_ << " m"); | ||
|
|
||
| declareParameter("s57_grids_namespace", rclcpp::ParameterValue(s57_grids_namespace_)); | ||
| node->get_parameter(name_+".s57_grids_namespace", s57_grids_namespace_); | ||
|
|
@@ -135,7 +150,7 @@ void S57Layer::updateBounds(double, double, double, double* min_x, double* min_y | |
| { | ||
| auto transform = tf_->lookupTransform(chart_datum_frame_, sea_surface_frame_, tf2::TimePointZero); | ||
| double new_offset = transform.transform.translation.z; | ||
| if(std::abs(new_offset - tide_offset_) > 0.01) | ||
| if(std::abs(new_offset - tide_offset_) > tide_invalidate_threshold_) | ||
|
||
| { | ||
| tide_offset_ = new_offset; | ||
| RCLCPP_INFO_STREAM(logger_, "Tide offset updated: " << tide_offset_ << " m (water above chart datum)"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tide_invalidate_threshold_is loaded from a parameter but never validated. If it’s configured as a negative value,std::abs(...) > tide_invalidate_threshold_will be true on every update, forcing continuous invalidations and potentially recreating the same timeout behavior this change is meant to mitigate. Consider clamping to >= 0 (and rejecting non-finite values) after reading the parameter, with a warning and fallback to the default.