Main Content

vrinsertrobot

(To be removed) Add robot to virtual world

vrinsertrobot will be removed in a future release. For more information, see Version History.

Description

node = vrinsert(RBT) creates an empty virtual world and inserts the visual representation of the Robotics System Toolbox™ rigidBodyTree object RBT into it. It then returns a handle to the newly created node in the virtual world.

example

node = vrinsertrobot(parent,RBT) inserts the visual representation of the Robotics System Toolbox rigidBodyTree object RBT into an existing virtual world or node specified by parent. If parent is a virtual world, object specified by RBT is placed at its root. If parent is a node within a virtual world, the inserted object is placed as a direct child of parent.

example

[node, W] = vrinsertrobot(...) also returns a handle to the virtual world W in addition to the visualization of the rigidBodyTree object represented by node.

[node, W, tforms] = vrinsertrobot(...) also returns a handle to the appropriate transforms tforms, which can be used to make additional changes to the robot pose.

example

Examples

collapse all

This example shows you how to import and insert a rigidBodyTree object for the KUKA LBR iiwa robot manipulator into a newly created world.

Import Robot

Create the rigidBodyTree object from the URDF file of the associated robot.

RBT = importrobot('iiwa7.urdf');
RBT.DataFormat = 'Row';

For more information on the rigidBodyTree structure, see rigidBodyTree (Robotics System Toolbox).

Insert and View Robot

Create an empty world and open it.

w = vrworld('');
open(w);
view(w);

Create a node in an empty world using vrinsertrobot.

node = vrinsertrobot(w,RBT);

View the created world in the Simulink® 3D Animation™ internal viewer.

vrdrawnow

Figure contains objects of type hgjavacomponent, uimenu, uipanel, uitoolbar.

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);

Figure Simple Robot Scene contains objects of type hgjavacomponent, uimenu, uipanel, uitoolbar.

This example shows you how to insert a robot into a virtual world and update its pose

Import the Robot and Set up the World

Import the KUKA LFR iiwa robot from its URDF definition and insert it to the virtual world created from robot_scene.x3d.

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);

Figure Simple Robot Scene contains objects of type hgjavacomponent, uimenu, uipanel, uitoolbar.

Change the Pose of the Robot

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

Figure Simple Robot Scene contains objects of type hgjavacomponent, uimenu, uipanel, uitoolbar.

Figure Simple Robot Scene contains objects of type hgjavacomponent, uimenu, uipanel, uitoolbar.

Input Arguments

collapse all

Robotics System Toolbox rigidBodyTree object. For more information, see rigidBodyTree (Robotics System Toolbox).

Node in the virtual world hierarchy under which to insert the robot specified by RBT. If a vrworld object is provided, the robot is inserted at the ROOT node of the world.

Output Arguments

collapse all

Handle to the newly inserted robot in the virtual world, returned as a vrnode object. For more information, see vrnode.

Handle to the virtual world containing the robot, returned as a vrworld object. For more information, see vrworld.

List of transformations applied to the robot, returned as a cell array of vrnode objects.

Version History

Introduced in R2018b

collapse all

R2023b: To be removed

The vrinsertrobot will be removed in a future release. Instead, use sim3d classes and Simulation 3D blocks to interface MATLAB® and Simulink® with the Unreal Engine® 3D simulation environment. To get started, see Create 3D Simulations in Unreal Engine Environment.

See Also

| | (Robotics System Toolbox) | (Robotics System Toolbox)