Skip to content

Commit

Permalink
Fix deprecation warning calling declare_parameter
Browse files Browse the repository at this point in the history
As of ros2/rclcpp#1522, we must also declare the type of the parameter.
We can do this implicitly by providing a default value.

Prior to this change, distance_ was being default-initialized to 0.0 anyways.

Signed-off-by: Jacob Perron <[email protected]>
  • Loading branch information
jacobperron authored and Joshua Whitley committed Mar 18, 2021
1 parent 683d980 commit ad431c2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions depth_image_proc/src/crop_foremost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ class CropForemostNode : public rclcpp::Node
CropForemostNode::CropForemostNode(const rclcpp::NodeOptions & options)
: Node("CropForemostNode", options)
{
this->declare_parameter("distance");
this->get_parameter("distance", distance_);
distance_ = this->declare_parameter("distance", 0.0);

// Monitor whether anyone is subscribed to the output
// TODO(ros2) Implement when SubscriberStatusCallback is available
Expand Down

0 comments on commit ad431c2

Please sign in to comment.