vrinsertrobot

Add robot to virtual world

Description

example

node = vrinsert(RBT) creates an empty virtual world and inserts the visual representation of the Robotics System Toolbox™ robotics.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 robotics.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.

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

example

[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.

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.

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

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.wrl','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);

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.wrl');
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);

Input Arguments

collapse all

Robotics System Toolbox RigidBodyTree object. For more information, see rigidBodyTree.

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.

Introduced in R2018b