Skip to content

Commit

Permalink
don't advertise services if feature not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeferguson committed Feb 8, 2024
1 parent 44d5b36 commit d7f44d2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions image_view/src/image_saver_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,21 @@ ImageSaverNode::ImageSaverNode(const rclcpp::NodeOptions & options)
std::bind(
&ImageSaverNode::service, this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
start_srv_ = this->create_service<std_srvs::srv::Trigger>(
"start",
std::bind(
&ImageSaverNode::callbackStartSave, this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
end_srv_ = this->create_service<std_srvs::srv::Trigger>(
"end",
std::bind(
&ImageSaverNode::callbackEndSave, this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));

// Advertise start/end services if the feature is enabled
if (request_start_end_)
{
start_srv_ = this->create_service<std_srvs::srv::Trigger>(
"start",
std::bind(
&ImageSaverNode::callbackStartSave, this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
end_srv_ = this->create_service<std_srvs::srv::Trigger>(
"end",
std::bind(
&ImageSaverNode::callbackEndSave, this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
}
}

bool ImageSaverNode::saveImage(
Expand Down

0 comments on commit d7f44d2

Please sign in to comment.