Skip to content

Commit

Permalink
do not publish tf
Browse files Browse the repository at this point in the history
  • Loading branch information
jplapp committed Nov 28, 2024
1 parent afb0dc5 commit f672048
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/AprilTagNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class AprilTagNode : public rclcpp::Node {
double tag_edge_size;
std::atomic<int> max_hamming;
std::atomic<bool> profile;
std::atomic<bool> publish_tf;
std::unordered_map<int, std::string> tag_frames;
std::unordered_map<int, double> tag_sizes;

Expand Down Expand Up @@ -144,6 +145,7 @@ AprilTagNode::AprilTagNode(const rclcpp::NodeOptions& options)

declare_parameter("max_hamming", 0, descr("reject detections with more corrected bits than allowed"));
declare_parameter("profile", false, descr("print profiling information to stdout"));
declare_parameter("publish_tf", false, descr("estimate pose and publish tf"));

if(!frames.empty()) {
if(ids.size() != frames.size()) {
Expand Down Expand Up @@ -238,6 +240,9 @@ void AprilTagNode::onImage(const sensor_msgs::msg::Image::ConstSharedPtr& msg_im
std::memcpy(msg_detection.homography.data(), det->H->data, sizeof(double) * 9);
msg_detections.detections.push_back(msg_detection);

if(!publish_tf){
continue;
}
// 3D orientation and position
geometry_msgs::msg::TransformStamped tf;
tf.header = msg_img->header;
Expand All @@ -252,7 +257,9 @@ void AprilTagNode::onImage(const sensor_msgs::msg::Image::ConstSharedPtr& msg_im
}

pub_detections->publish(msg_detections);
tf_broadcaster.sendTransform(tfs);
if(publish_tf){
tf_broadcaster.sendTransform(tfs);
}

apriltag_detections_destroy(detections);
}
Expand All @@ -275,6 +282,7 @@ AprilTagNode::onParameter(const std::vector<rclcpp::Parameter>& parameters)
IF("detector.debug", td->debug)
IF("max_hamming", max_hamming)
IF("profile", profile)
IF("publish_tf", publish_tf)
}

mutex.unlock();
Expand Down

0 comments on commit f672048

Please sign in to comment.