%% Insert Robot into an Existing World
% This example shows how to insert a rigidBodyTree object to an existing world and update the viewer.
%% Open a Virtual World
% Open up a virtual world in the Simulink 3D Animation™ viewer. This example uses the robot_scene.wrl world. To create your own virtual world, see Create a Virtual World

robotWorld = vrworld('robot_scene','new');
open(robotWorld);

%
%% Add Robot to the Existing World
% Import the KUKA LBR iiwa robot from its URDF definition into a rigidBodyTree object.

rbt = importrobot('iiwa7.urdf');
rbt.DataFormat = 'row';

% Add the robot to the robotWorld world object created in the previous step.

n = vrinsertrobot(robotWorld,rbt);

% Update the scene, even if the viewer is closed. Open the updated world and scene in the internal viewer.

vrdrawnow
view(robotWorld);

% Copyright 2018 The MathWorks, Inc.