tools

ROS 2 helper utilities.

This module defines shared ROS 2 helper utilities used by RobotBlockSet ROS 2 interfaces. It currently provides a lightweight TF client for querying frame transforms and returning them as pose vectors.

class robotblockset.ros2.tools.TFClient(node: rclpy.node.Node, base_frame: str | None = 'world', ee_frame: str | None = 'ee_frame')[source]

Bases: object

Helper to encapsulate TF2 Buffer/Listener and provide pose queries.

Initialize a TF2 client for pose lookups.

Parameters:
  • node (Node) – ROS 2 node used to create the TF buffer and listener.

  • base_frame (str, optional) – Frame to use as the base (default “world”).

  • ee_frame (str, optional) – Frame to use as the end-effector (default “ee_frame”).

__init__(node: rclpy.node.Node, base_frame: str | None = 'world', ee_frame: str | None = 'ee_frame') None[source]

Initialize a TF2 client for pose lookups.

Parameters:
  • node (Node) – ROS 2 node used to create the TF buffer and listener.

  • base_frame (str, optional) – Frame to use as the base (default “world”).

  • ee_frame (str, optional) – Frame to use as the end-effector (default “ee_frame”).

get_pose(base_frame: str | None = None, ee_frame: str | None = None, timeout: float = 2.0) ndarray | None[source]

Look up a transform and return it as a pose vector.

Parameters:
  • base_frame (str, optional) – Override for the base frame.

  • ee_frame (str, optional) – Override for the end-effector frame.

  • timeout (float, optional) – Lookup timeout in seconds.

Returns:

Pose vector [x, y, z, qw, qx, qy, qz].

Return type:

np.ndarray

Raises:

RuntimeError – If the transform cannot be retrieved within the timeout.

Classes

TFClient(node[, base_frame, ee_frame])

Helper to encapsulate TF2 Buffer/Listener and provide pose queries.