www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/SendATransformationToTheROSNetworkExample.m
%% Send A Transformation to the ROS Network % This example shows how to create a transformation and send it over the % ROS network. %% % Create a ROS transformation tree. You must be connected to a ROS network % using |rosinit|. Replace |ipaddress| with your ROS network address. ipaddress = '172.28.194.91'; rosinit(ipaddress) tftree = rostf; pause(2); %% % Verify the transformation you want does not exist. |canTransform| % returns false if the transformation is not immediately available. canTransform(tftree,'new_frame','base_link') %% % Create a |TransformStamped| message. Populate with the transformation % information. tform = rosmessage('geometry_msgs/TransformStamped') tform.ChildFrameId = 'new_frame'; tform.Header.FrameId = 'base_link'; tform.Transform.Translation.X = 0.5; tform.Transform.Rotation.Z = 0.75; %% % Send the transformation over the ROS network. sendTransform(tftree,tform) %% % Check if the transformation is now on the ROS network canTransform(tftree,'new_frame','base_link') %% % Shut down the ROS network. rosshutdown