Skip to content

Commit

Permalink
bring non-deprecated code before deprecated code
Browse files Browse the repository at this point in the history
Signed-off-by: Kenji Brameld <kenjibrameld@gmail.com>
  • Loading branch information
ijnek committed Aug 20, 2022
1 parent 5068519 commit 6667687
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion zbar_ros/include/zbar_ros/barcode_reader_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class BarcodeReaderNode : public rclcpp::Node
void cleanCb();

rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr camera_sub_;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr barcode_pub_; // DEPRECATED
rclcpp::Publisher<zbar_ros_interfaces::msg::Symbol>::SharedPtr symbol_pub_;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr barcode_pub_; // DEPRECATED
zbar::ImageScanner scanner_;

rclcpp::TimerBase::SharedPtr clean_timer_;
Expand Down
14 changes: 7 additions & 7 deletions zbar_ros/src/barcode_reader_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ BarcodeReaderNode::BarcodeReaderNode()
camera_sub_ = this->create_subscription<sensor_msgs::msg::Image>(
"image", 10, std::bind(&BarcodeReaderNode::imageCb, this, std::placeholders::_1));

barcode_pub_ = this->create_publisher<std_msgs::msg::String>("barcode", 10);
symbol_pub_ = this->create_publisher<zbar_ros_interfaces::msg::Symbol>("symbol", 10);
barcode_pub_ = this->create_publisher<std_msgs::msg::String>("barcode", 10);

throttle_ = this->declare_parameter<double>("throttle_repeated_barcodes", 0.0);
RCLCPP_DEBUG(get_logger(), "throttle_repeated_barcodes : %f", throttle_);
Expand Down Expand Up @@ -96,7 +96,7 @@ void BarcodeReaderNode::imageCb(sensor_msgs::msg::Image::ConstSharedPtr image)
if (throttle_ > 0.0) {
const std::lock_guard<std::mutex> lock(memory_mutex_);

std::string barcode = symbol.data;
const std::string & barcode = symbol.data;
// check if barcode has been recorded as seen, and skip detection
if (barcode_memory_.count(barcode) > 0) {
// check if time reached to forget barcode
Expand All @@ -115,15 +115,15 @@ void BarcodeReaderNode::imageCb(sensor_msgs::msg::Image::ConstSharedPtr image)
now() + rclcpp::Duration(std::chrono::duration<double>(throttle_))));
}

// publish barcode
// publish symbol
RCLCPP_DEBUG(get_logger(), "Publishing Symbol");
symbol_pub_->publish(symbol);

// publish on deprecated barcode topic
RCLCPP_DEBUG(get_logger(), "Publishing data as string");
std_msgs::msg::String barcode_string;
barcode_string.data = symbol.data;
barcode_pub_->publish(barcode_string);

// publish symbol
RCLCPP_DEBUG(get_logger(), "Publishing Symbol");
symbol_pub_->publish(symbol);
}
} else {
RCLCPP_DEBUG(get_logger(), "No barcode detected in image");
Expand Down

0 comments on commit 6667687

Please sign in to comment.