Install any skill in seconds. Free to start, no credit card required.
Get Started Free →ROS2 TF2 and Transform management with Clean Architecture (Python & C++)
.claude/skills/harunkurtdev-ros2-transforms-tf2/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-20 | ✗→✓ | ▲ Improved | -17% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 4% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -14% | 0% |
| case-11 | ✗→✓ | ▲ Improved | -2% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 0% | 0% |
This skill demonstrates how to use the ROS2 TF2 (Transform Library) while adhering to Clean Architecture principles. The Domain layer should be protected from direct TF2 dependencies by using Repository or Service patterns.
The domain layer should not depend on TF2 or geometry_msgs.
python# domain/entities/pose.py from dataclasses import dataclass @dataclass class Pose: position: tuple # (x, y, z) orientation: tuple # (x, y, z, w) frame_id: str timestamp: float
cpp// domain/entities/pose.hpp #pragma once #include <string> namespace domain::entities { struct Point3D { double x, y, z; }; struct Quaternion { double x, y, z, w; }; struct Pose { Point3D position; Quaternion orientation; std::string frame_id; double timestamp; }; } // namespace
TF2 implementation resides here.
See previous Python example.
cpp// infrastructure/ros2/services/tf_service.hpp #pragma once #include <rclcpp/rclcpp.hpp> #include <tf2_ros/buffer.h> #include <tf2_ros/transform_listener.h> #include <geometry_msgs/msg/transform_stamped.hpp> #include "domain/interfaces/transform_service.hpp" namespace infrastructure::ros2::services { class TFService : public domain::interfaces::ITransformService { public: explicit TFService(rclcpp::Node::SharedPtr node); std::optional<domain::entities::Pose> get_transform( const std::string& target_frame, const std::string& source_frame) override; private: rclcpp::Node::SharedPtr node_; std::shared_ptr<tf2_ros::Buffer> tf_buffer_; std::shared_ptr<tf2_ros::TransformListener> tf_listener_; }; } // namespace // infrastructure/ros2/services/tf_service.cpp #include "infrastructure/ros2/services/tf_service.hpp" namespace infrastructure::ros2::services { TFService::TFService(rclcpp::Node::SharedPtr node) : node_(node) { tf_buffer_ = std::make_shared<tf2_ros::Buffer>(node_->get_clock()); tf_listener_ = std::make_shared<tf2_ros::TransformListener>(*tf_buffer_); } std::optional<domain::entities::Pose> TFService::get_transform( const std::string& target_frame, const std::string& source_frame) { try { geometry_msgs::msg::TransformStamped t = tf_buffer_->lookupTransform( target_frame, source_frame, tf2::TimePointZero); return domain::entities::Pose{ {t.transform.translation.x, t.transform.translation.y, t.transform.translation.z}, {t.transform.rotation.x, t.transform.rotation.y, t.transform.rotation.z, t.transform.rotation.w}, t.header.frame_id, rclcpp::Time(t.header.stamp).seconds() }; } catch (const tf2::TransformException & ex) { RCLCPP_WARN(node_->get_logger(), "Could not transform %s to %s: %s", source_frame.c_str(), target_frame.c_str(), ex.what()); return std::nullopt; } } } // namespace
cpp// infrastructure/ros2/helpers/tf_publisher.hpp #include <tf2_ros/static_transform_broadcaster.h> class TFPublisher { public: TFPublisher(rclcpp::Node::SharedPtr node) : node_(node) { static_broadcaster_ = std::make_shared<tf2_ros::StaticTransformBroadcaster>(node); } void publish_static(const std::string& parent, const std::string& child, const std::array<double, 3>& trans, const std::array<double, 4>& rot) { geometry_msgs::msg::TransformStamped t; t.header.stamp = node_->get_clock()->now(); t.header.frame_id = parent; t.child_frame_id = child; t.transform.translation.x = trans[0]; // ... static_broadcaster_->sendTransform(t); } private: rclcpp::Node::SharedPtr node_; std::shared_ptr<tf2_ros::StaticTransformBroadcaster> static_broadcaster_; };
tf2_ros.tf2::TransformException.Time(0)) for data synchronization when possible.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-20 | fail→pass | 12,670 | 2,320 | -82% | 1 | 1 | 0% | 1,955 | 1,622 | -17% | 0 | 0 | — |
case-21 | pass→pass | 19,774 | 15,953 | -19% | 1 | 1 | 0% | 3,943 | 4,562 | +16% | 0 | 0 | — |
case-01 | fail→pass | 19,739 | 13,738 | -30% | 1 | 1 | 0% | 4,063 | 4,234 | +4% | 0 | 0 | — |
case-02 | fail→fail | 13,559 | 11,988 | -12% | 1 | 1 | 0% | 2,407 | 3,521 | +46% | 0 | 0 | — |
case-03 | pass→pass | 21,410 | 16,107 | -25% | 1 | 1 | 0% | 4,040 | 4,756 | +18% | 0 | 0 | — |
case-04 | pass→pass | 7,619 | 5,763 | -24% | 1 | 1 | 0% | 1,367 | 2,287 | +67% | 0 | 0 | — |
case-05 | pass→pass | 14,363 | 8,878 | -38% | 1 | 1 | 0% | 2,691 | 2,841 | +6% | 0 | 0 | — |
case-06 | pass→pass | 15,847 | 13,187 | -17% | 1 | 1 | 0% | 3,217 | 3,757 | +17% | 0 | 0 | — |
case-07 | fail→pass | 10,999 | 2,332 | -79% | 1 | 1 | 0% | 1,936 | 1,658 | -14% | 0 | 0 | — |
case-08 | pass→pass | 12,085 | 8,649 | -28% | 1 | 1 | 0% | 2,035 | 2,877 | +41% | 0 | 0 | — |
case-09 | pass→pass | 15,407 | 13,002 | -16% | 1 | 1 | 0% | 2,623 | 3,737 | +42% | 0 | 0 | — |
case-10 | pass→pass | 15,027 | 10,002 | -33% | 1 | 1 | 0% | 2,961 | 3,317 | +12% | 0 | 0 | — |
case-11 | fail→pass | 12,663 | 7,918 | -37% | 1 | 1 | 0% | 2,773 | 2,708 | -2% | 0 | 0 | — |
case-22 | pass→pass | 20,620 | 18,605 | -10% | 1 | 1 | 0% | 4,215 | 4,594 | +9% | 0 | 0 | — |
case-12 | pass→pass | 15,469 | 18,589 | +20% | 1 | 1 | 0% | 2,484 | 4,324 | +74% | 0 | 0 | — |
case-13 | pass→pass | 4,347 | 4,272 | -2% | 1 | 1 | 0% | 703 | 1,924 | +174% | 0 | 0 | — |
case-14 | fail→pass | 9,847 | 2,546 | -74% | 1 | 1 | 0% | 1,643 | 1,647 | +0% | 0 | 0 | — |
case-15 | pass→fail | 13,705 | 11,139 | -19% | 1 | 1 | 0% | 2,288 | 3,166 | +38% | 0 | 0 | — |
case-16 | fail→fail | 17,406 | 14,497 | -17% | 1 | 1 | 0% | 3,273 | 4,070 | +24% | 0 | 0 | — |
case-17 | pass→pass | 9,576 | 5,569 | -42% | 1 | 1 | 0% | 1,625 | 2,188 | +35% | 0 | 0 | — |
case-18 | pass→pass | 6,235 | 4,082 | -35% | 1 | 1 | 0% | 1,012 | 1,990 | +97% | 0 | 0 | — |
case-19 | pass→pass | 13,229 | 2,637 | -80% | 1 | 1 | 0% | 2,208 | 1,687 | -24% | 0 | 0 | — |
case-23 | pass→pass | 9,396 | 5,253 | -44% | 1 | 1 | 0% | 1,614 | 2,119 | +31% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +17 percentage points is the difference between those two pass rates over the 23 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.