• 沒有找到結果。

Scene Tree Window

在文檔中 Webots User Guide (頁 32-37)

As seen in the previous section, to access to the Scene Tree Window you can either chooseScene Tree Windowin theEditmenu, or click on the pointer button and double-click on a solid object.

The scene tree contains all information necessary to describe the graphic representation and sim-ulation of the 3D world. A world in Webots includes one or more robots and their environment.

The scene tree of Webots is structured like a VRML97 file. It is composed of a list of nodes, each containing fields. Fields can contain values (text string, numerical values) or nodes.

Some nodes in Webots are VRML97 nodes, partially or totally implemented, while others are specific to Webots. For instance theSolidnode inherits from theTransformnode of VRML97 and can be selected and moved with the buttons in the World Window.

This section describes the buttons of the Scene Tree Window, the VRML97 nodes, the Webots specific nodes and how to write a.wbtfile in a text editor.

3.4. SCENE TREE WINDOW 33

Figure 3.3: Scene Tree Window

3.4.1 Buttons of the Scene Tree Window

The scene tree with the list of nodes appears on the left side of the window. Clicking on the+in front of a node or double-clicking on the node displays the fields inside the node, and similarly expands the fields. The field values can be defined on the top right side of the window. Five editing buttons are available on the bottom right side of the window:

Cut

Copy

Paste after

These three buttons let you cut, copy and paste nodes and fields. However, you can’t perform these operations on the first three nodes of the tree (WorldInfo, ViewpointandBackground).

These nodes are mandatory and cannot be duplicated. Similarly, you can’t copy theSupervisor node because only one supervisor is allowed. Please note that when you cut or copy a robot node, like aDifferentialWheelsorSupervisornode, thecontrollerfield of this node is reset to"void".

34 CHAPTER 3. GETTING STARTED WITH WEBOTS

Delete: This button allows you to delete a node. It appears only if a node is selected. If a field is selected, theDefault Valuebutton appears instead.

Default Value: You can click on this button to reset a field to its default value(s). A field with values must be selected in order to perform this button. If a node is selected, the Delete

button replaces it.

Transform: This button allows you to transform a node into another one.

Insert after: With this button, you can insert a node after the one currently selected. This new node contains fields with default values, which you can of course modify to suit your needs.

This button also allows you to add a node to a childrenfield. In all cases, the software only permits you to insert a coherent node.

Insert Node: Use this to insert a node into a field whose value is a node. You can insert only a coherent node.

Export Node: Use this button to export a node into a file. Usually, nodes are saved in your objectsdirectory. Such saved nodes can then be reused in other worlds.

Import Node: Use this button to import a previously saved node into the scene tree. Usually, saved nodes are located in the Webots objectsdirectory or in your own objectsdirectory.

The Webotsobjectsdirectory already contains a few nodes that can be easily imported.

3.4.2 VRML97 nodes

A number of VRML97 nodes are partially or completely supported in Webots.

The exact features of VRML97 are the subject of a standard managed by the International Stan-dards Organization (ISO/IEC 14772-1:1997).

You can find the complete specifications of VRML97 on the official VRML97 Web site2. The following VRML97 nodes are supported in Webots:

• Appearance

• Background

2http://www.web3d.org

3.4. SCENE TREE WINDOW 35

• Box

• Color

• Cone

• Coordinate

• Cylinder

• DirectionalLight

• ElevationGrid

• Fog

• Group

• ImageTexture

• IndexedFaceSet

• IndexedLineSet

• Material

• PointLight

• Shape

• Sphere

• Switch

• TextureCoordinate

• TextureTransform

• Transform

• Viewpoint

• WorldInfo

The Webots Reference Manual gives a list of nodes supported in Webots and specify which fields are actually used. For a comprehensive description of the VRML97 nodes, please refer to the VRML97 documentation.

36 CHAPTER 3. GETTING STARTED WITH WEBOTS

3.4.3 Webots specific nodes

In order to implement powerful simulations including mobile robots with different propulsion schemes (wheeled robots, legged robots or flying robots), a number of nodes specific to Webots have been added to the VRML97 set of nodes.

VRML97 uses a hierarchical structure for nodes. For example, the Transform node inherits from the Group node, such that, like theGroup node, the Transform node has a children field, but it also adds three additional fields: translation,rotationandscale.

In the same way, Webots introduces new nodes which inherit from the VRML97 Transform node, principally the Solid node. Other Webots nodes (DifferentialWheels, Camera, TouchSensor, etc.) inherit from thisSolidnode.

The Reference Manual gives a complete description of all Webots nodes and their respective fields.

3.4.4 Principle of the collision detection

The collision detection engine is able to detect a collision between twoSolidnodes. It calculates the intersection between the bounding objects of the solids. A bounding object (described in the boundingObjectfield of theSolidnode) is a geometric shape or a group of geometric shapes which bounds the solid. If the boundingObject field is NULL, then no collision detection is performed for thisSolidnode. ASolidnode may contain other Solidnodes aschildren, each of them having its own bounding object.

The collision detection is mainly used to detect if a robot (for example aDifferentialWheels node) collides with an obstacle (Solidnode), or with another robot. TwoSolidnodes can never inter-penetrate each other; their movement is stopped just before the collision.

Example: A solid with a bounding box different from its list of children.

Let us consider the Khepera robot model. It is not exactly aSolidnode, but the principle for the boundingObjectis the same. Open thekhepera.wbtfile and look at theboundingObject field of the DifferentialWheels node. The bounding object is a cylinder which has been transformed. See figure 3.4.

3.4.5 Writing a Webots file in a text editor

It is possible to write a Webots world file (.wbt) using a text editor. A world file contains a header, nodes containing fields and values. Note that only a few VRML97 nodes are imple-mented, and that there are nodes specific to Webots. Moreover, comments can only be written in the DEF, and not like in a VRML97 file.

The Webots header is:

在文檔中 Webots User Guide (頁 32-37)

相關文件