Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to change parent_child_id #31

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .vscode/settings.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not commit personal IDE settings.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"files.associations": {
"*.tcc": "cpp",
"bitset": "cpp",
"istream": "cpp",
"ostream": "cpp",
"*.cps": "javascript",
"*.h": "cpp",
"charconv": "cpp",
"array": "cpp",
"string_view": "cpp",
"*.old": "cpp",
"*.bkp": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"functional": "cpp",
"deque": "cpp",
"string": "cpp",
"vector": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"atomic": "cpp",
"hash_map": "cpp",
"hash_set": "cpp",
"chrono": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"forward_list": "cpp",
"list": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"set": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"bit": "cpp"
}
}
4 changes: 3 additions & 1 deletion src/AprilTagNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class AprilTagNode : public rclcpp::Node {
// parameter
std::mutex mutex;
double tag_edge_size;
std::string parent_frame_id;
std::atomic<int> max_hamming;
std::atomic<bool> profile;
std::unordered_map<int, std::string> tag_frames;
Expand All @@ -81,7 +82,6 @@ class AprilTagNode : public rclcpp::Node {
const image_transport::CameraSubscriber sub_cam;
const rclcpp::Publisher<apriltag_msgs::msg::AprilTagDetectionArray>::SharedPtr pub_detections;
tf2_ros::TransformBroadcaster tf_broadcaster;

pose_estimation_f estimate_pose = nullptr;

void onCamera(const sensor_msgs::msg::Image::ConstSharedPtr& msg_img, const sensor_msgs::msg::CameraInfo::ConstSharedPtr& msg_ci);
Expand Down Expand Up @@ -110,6 +110,7 @@ AprilTagNode::AprilTagNode(const rclcpp::NodeOptions& options)
// read-only parameters
const std::string tag_family = declare_parameter("family", "36h11", descr("tag family", true));
tag_edge_size = declare_parameter("size", 1.0, descr("default tag size", true));
parent_frame_id = declare_parameter("parent_frame_id", "odom", descr("the frame id which is odom by default", true));

// get tag names, IDs and sizes
const auto ids = declare_parameter("tag.ids", std::vector<int64_t>{}, descr("tag ids", true));
Expand Down Expand Up @@ -215,6 +216,7 @@ void AprilTagNode::onCamera(const sensor_msgs::msg::Image::ConstSharedPtr& msg_i
// 3D orientation and position
geometry_msgs::msg::TransformStamped tf;
tf.header = msg_img->header;
tf.header.frame_id = parent_frame_id;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will override the frame ID from the camera in which frame the tag is detected and there is no way to prevent this.

// set child frame name by generic tag name or configured tag name
tf.child_frame_id = tag_frames.count(det->id) ? tag_frames.at(det->id) : std::string(det->family->name) + ":" + std::to_string(det->id);
const double size = tag_sizes.count(det->id) ? tag_sizes.at(det->id) : tag_edge_size;
Expand Down
Loading