Skip to content

Commit

Permalink
Dynamic setting of params in speckle filter
Browse files Browse the repository at this point in the history
Done previously by berend-kupers, but removed during code review because
we thought it needed a separate node inside the filter. Here we use the
params_interface_ member variable of the filter base class instead of
creating a new node.

The callback needs to be post_set_params and not on_set_params because
the changes haven't been finalized yet when on_set_params is called.
  • Loading branch information
jonbinney committed Aug 27, 2024
1 parent 15a6e7d commit 27bf41c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions include/laser_filters/speckle_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ class LaserScanSpeckleFilter : public filters::FilterBase<sensor_msgs::msg::Lase
break;
}

post_set_parameters_callback_handle_ = params_interface_->add_post_set_parameters_callback(
std::bind(&LaserScanSpeckleFilter::reconfigureCB, this, std::placeholders::_1));

return true;
}
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -248,11 +251,8 @@ class LaserScanSpeckleFilter : public filters::FilterBase<sensor_msgs::msg::Lase
return true;
}

rcl_interfaces::msg::SetParametersResult reconfigureCB(std::vector<rclcpp::Parameter> parameters)
void reconfigureCB(std::vector<rclcpp::Parameter> parameters)
{
auto result = rcl_interfaces::msg::SetParametersResult();
result.successful = true;

for (auto parameter : parameters)
{
if(logging_interface_ != nullptr)
Expand Down Expand Up @@ -289,9 +289,6 @@ class LaserScanSpeckleFilter : public filters::FilterBase<sensor_msgs::msg::Lase
default:
break;
}

return result;

}

////////////////////////////////////////////////////
Expand All @@ -303,6 +300,7 @@ class LaserScanSpeckleFilter : public filters::FilterBase<sensor_msgs::msg::Lase
double max_range = 0;
double max_range_difference = 0;
int filter_window = 0;
rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_parameters_callback_handle_;
};
}
#endif /* speckle_filter.h */

0 comments on commit 27bf41c

Please sign in to comment.