Main Content

waitForTransform

Wait until a transformation is available

waitForTransformwill be removed in a future release. UsegetTransformwith a specifiedtimeout代替。使用infto wait indefinitely.

Description

waitForTransform(tftree,targetframe,sourceframe)waits until the transformation betweentargetframeandsourceframeis 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/

创建一个ROS交易nsformation 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 aTransformationTreeobject handle. You can create a transformation tree by calling therostffunction.

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

Initial coordinate frame, specified as a string scalar or character vector. You can view the available frames for transformation usingtftree.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.

Extended Capabilities

Version History

Introduced in R2019b