%% Add Robot to World and Change its Pose
% This example shows you how to insert a robot into a virtual world and update its pose
%% Import the Robot and Setup the World
% Import the KUKA LFR iiwa robot from its URDF definition and insert it to the virtual world created from robot_scene.wrl.

RBT = importrobot('iiwa7.urdf');
RBT.DataFormat = 'row';
robotWorld = vrworld('robot_scene');
open(robotWorld);

%
%% Get Transforms of Current Pose of the Robot
% The tforms output argument contains a list of transforms that describe the robot pose in its initial or 'home' configuration.

[node, W, tforms] = vrinsertrobot(robotWorld, RBT);
vrfigure(robotWorld);

%
%% Change the Pose of the Robot

vrupdaterobot(RBT, tforms, randomConfiguration(RBT));
vrdrawnow;
vrfigure(robotWorld);

% Copyright 2018 The MathWorks, Inc.