Main Content

waitForTransform

Wait until a transformation is available

waitForTransform will be removed in a future release. Use getTransform with a specified timeout instead. Use inf to wait indefinitely.

Description

waitForTransform(tftree,targetframe,sourceframe) waits until the transformation between targetframe and sourceframe is available in the transformation tree, tftree. This functions disables the command prompt until a transformation becomes available on the ROS network.

example

waitForTransform(tftree,targetframe,sourceframe,timeout) specifies a timeout period in seconds. If the transformation does not become available, MATLAB® displays an error, but continues running the current program.

Examples

collapse all

Connect to the ROS network. Specify the IP address of your network.

rosinit('192.168.17.129')
Initializing global node /matlab_global_node_48383 with NodeURI http://192.168.17.1:54695/

Create a ROS transformation tree.

tftree = rostf;

Wait for the transformation between the target frame, /camera_depth_frame, and the source frame, /base_link, to be available. Specify a timeout of 5 seconds.

waitForTransform(tftree,'/camera_depth_frame','/base_link',5);

Get the transformation.

tform = getTransform(tftree,'/camera_depth_frame','/base_link');

When you are finished, disconnect from the ROS network.

rosshutdown
Shutting down global node /matlab_global_node_48383 with NodeURI http://192.168.17.1:54695/

Input Arguments

collapse all

ROS transformation tree, specified as a TransformationTree object handle. You can create a transformation tree by calling the rostf function.

Target coordinate frame, specified as a string scalar or character vector. You can view the available frames for transformation by calling tftree.AvailableFrames.

Initial coordinate frame, specified as a string scalar or character vector. You can view the available frames for transformation using tftree.AvailableFrames.

Timeout period, specified as a numeric scalar in seconds. If the transformation does not become available, MATLAB displays an error, but continues running the current program.

Introduced in R2019b