Python
Download and Installation
The Python SDK is available as a PyPI package for easy installation.
Supported platforms:
- Linux: x86_64 and aarch64 (Python ≥ 3.10)
- Windows: Python ≥ 3.12
- macOS: Python ≥ 3.12
Installation using pip:
pip install bota-tf-utils
Usage Demo
We provide a demo to get yourself started with the Python SDK.
What you'll find in the demo:
- Wrench, Twist, IMU and Pose transformer setup and configuration
- Static and dynamic TF entry patterns
- Real-time loop integration examples in Python
API Description
All four transformation utilities follow the same interface pattern.
Each class is imported from the bota_tf_utils module and can be constructed with either
a JSON configuration file or a BotaTfConfig object
(see Concept for the config structure).
BotaTfConfig
Configuration object used to construct any of the four transformer classes directly from code, without a JSON file.
- class bota_tf_utils.BotaTfConfig
-
- policy
Policy for handling non-OK conditions (optional; defaults to
BestEffort).
- input_ref_point: Translation
Input reference point: origin frame and translation.
- output_ref_point: Translation
Output reference point: origin frame and translation.
BotaTfWrench
Transforms a 6-DOF wrench [fx, fy, fz, tx, ty, tz] between reference points and
expression axes.
- class bota_tf_utils.BotaTfWrench
Constructor and Destructor
- __init__(config_file: str = '') None
Constructs the transformer. Optionally loads static TF entries from a JSON config file (section key
"tf_wrench_config"). Ifconfig_fileis empty, all entries must be set via the setters below.- Parameters:
config_file (str) – Path to the JSON configuration file (may be empty).
- __init__(config: BotaTfConfig) None
Constructs the transformer from a
BotaTfConfigobject populated in user code. All TF entries present in the config object are applied immediately; any entry not set in the config can still be supplied via the setters below.- Parameters:
config (BotaTfConfig) – Fully or partially populated configuration object.
Metadata
- name() str
Returns the name specified in the config, or an empty string if no name was set.
- Return type:
TF Setters
- set_input_reference_point(origin: str, translation: numpy.ndarray) bool
Sets the translation from origin to the input reference point (expressed in origin axes).
- set_input_expression_axes(origin: str, rotation: numpy.ndarray) bool
Sets the rotation from origin to the input expression axes.
- set_output_reference_point(origin: str, translation: numpy.ndarray) bool
Sets the translation from origin to the output reference point (expressed in origin axes).
- set_output_expression_axes(origin: str, rotation: numpy.ndarray) bool
Sets the rotation from origin to the output expression axes.
Dynamic TF
- set_fixed_to_moving_frame_tf(tf: numpy.ndarray) None
Pushes the current fixed-to-moving-frame transform. Must be called every loop iteration when any TF entry uses
"moving_frame". Cannot be set via JSON or config object.- Parameters:
tf (numpy.ndarray) –
[tx, ty, tz, qw, qx, qy, qz]— translation (metres) followed by unit quaternion from fixed frame to moving frame. Shape(7,), dtypefloat64.
Transform
- update(wrench_in: numpy.ndarray, wrench_out: numpy.ndarray) BotaControlReturnCode
Transforms the input wrench and writes the result into
wrench_outin-place.- Parameters:
wrench_in (numpy.ndarray) – Input wrench
[fx, fy, fz, tx, ty, tz]at the input reference point, expressed in the input expression axes. Shape(6,), dtypefloat64.wrench_out (numpy.ndarray) – Pre-allocated output array of shape
(6,), dtypefloat64. Overwritten in-place with the transformed wrench[fx, fy, fz, tx, ty, tz]at the output reference point, expressed in the output expression axes.
- Returns:
BotaControlReturnCode.OKon success, or a warning/error code according to the configured policy.- Return type:
BotaTfPose
Transforms a 7-DOF pose [px, py, pz, qw, qx, qy, qz] between reference points and
expression axes. Uses config key "tf_pose_config".
Note
BotaTfPose does not have a set_fixed_to_moving_frame_tf() method. The
orientation of the moving frame is encoded directly in the input pose quaternion, so
no separate dynamic TF call is needed each loop iteration.
- class bota_tf_utils.BotaTfPose
Constructor and Destructor
- __init__(config_file: str = '') None
Constructs the transformer. Optionally loads static TF entries from
"tf_pose_config".- Parameters:
config_file (str) – Path to the JSON configuration file (may be empty).
- __init__(config: BotaTfConfig) None
Constructs the transformer from a
BotaTfConfigobject populated in user code.- Parameters:
config (BotaTfConfig) – Fully or partially populated configuration object.
Metadata
TF Setters
Transform
- update(pose_in: numpy.ndarray, pose_out: numpy.ndarray) BotaControlReturnCode
Transforms the input pose and writes the result into
pose_outin-place.- Parameters:
pose_in (numpy.ndarray) – Input pose
[px, py, pz, qw, qx, qy, qz]. Shape(7,), dtypefloat64.pose_out (numpy.ndarray) – Pre-allocated output array of shape
(7,), dtypefloat64. Overwritten in-place with the transformed pose[px, py, pz, qw, qx, qy, qz].
- Return type:
BotaTfTwist
Transforms a 6-DOF twist [vx, vy, vz, wx, wy, wz] between reference points and
expression axes. The interface is identical to BotaTfWrench — only the config key
("tf_twist_config") and the signal semantics differ.
- class bota_tf_utils.BotaTfTwist
- __init__(config_file: str = '') None
Constructs the transformer. Optionally loads static TF entries from
"tf_twist_config".- Parameters:
config_file (str) – Path to the JSON configuration file (may be empty).
- __init__(config: BotaTfConfig) None
Constructs the transformer from a
BotaTfConfigobject populated in user code.- Parameters:
config (BotaTfConfig) – Fully or partially populated configuration object.
- update(twist_in: numpy.ndarray, twist_out: numpy.ndarray) BotaControlReturnCode
Transforms the input twist and writes the result into
twist_outin-place.- Parameters:
twist_in (numpy.ndarray) – Input twist
[vx, vy, vz, wx, wy, wz](m/s and rad/s). Shape(6,), dtypefloat64.twist_out (numpy.ndarray) – Pre-allocated output array of shape
(6,), dtypefloat64. Overwritten in-place with the transformed twist[vx, vy, vz, wx, wy, wz].
- Return type:
BotaTfImu
Transforms a 6-DOF IMU signal [ax, ay, az, wx, wy, wz] between reference points and
expression axes, accounting for the centripetal acceleration term when the reference point
changes. Uses config key "tf_imu_config".
- class bota_tf_utils.BotaTfImu
- __init__(config_file: str = '') None
Constructs the transformer. Optionally loads static TF entries from
"tf_imu_config".- Parameters:
config_file (str) – Path to the JSON configuration file (may be empty).
- __init__(config: BotaTfConfig) None
Constructs the transformer from a
BotaTfConfigobject populated in user code.- Parameters:
config (BotaTfConfig) – Fully or partially populated configuration object.
- update(imu_in: numpy.ndarray, imu_out: numpy.ndarray) BotaControlReturnCode
Transforms the input IMU signal and writes the result into
imu_outin-place.- Parameters:
imu_in (numpy.ndarray) – Input IMU signal
[ax, ay, az, wx, wy, wz](m/s² and rad/s). Shape(6,), dtypefloat64.imu_out (numpy.ndarray) – Pre-allocated output array of shape
(6,), dtypefloat64. Overwritten in-place with the transformed IMU signal[ax, ay, az, wx, wy, wz].
- Return type: