diff --git a/image_view/src/image_saver_node.cpp b/image_view/src/image_saver_node.cpp index 4982732d0..8f41a1b68 100644 --- a/image_view/src/image_saver_node.cpp +++ b/image_view/src/image_saver_node.cpp @@ -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( - "start", - std::bind( - &ImageSaverNode::callbackStartSave, this, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); - end_srv_ = this->create_service( - "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( + "start", + std::bind( + &ImageSaverNode::callbackStartSave, this, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + end_srv_ = this->create_service( + "end", + std::bind( + &ImageSaverNode::callbackEndSave, this, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + } } bool ImageSaverNode::saveImage(