Skip to content

How to adapt your world or PROTO to Webots R2022b

ad-daniel edited this page Jul 5, 2022 · 13 revisions

What are EXTERNPROTO

PROTO nodes are a powerful way of describing complex objects or robots. From R2022b, all PROTO files used by a world need to be declared using the EXTERNPROTO keyword. Similarly, every PROTO inserted during the execution of the simulation by a supervisor needs to be declared an Ephemeral EXTERNPROTO prior to import it.

How are EXTERNPROTO declared

Under the hood, EXTERNPROTO and Ephemeral EXTERNPROTO are treated in the same manner, the distinction is only useful for the user. When opening a world in R2022b, declared PROTO will look like:

#VRML_SIM R2022b utf8

EXTERNPROTO "https://raw.githubusercontent.com/cyberbotics/webots/R2022b/projects/objects/backgrounds/protos/TexturedBackground.proto"

WorldInfo {
  basicTimeStep 16
}
Viewpoint {
}
TexturedBackground {
}

In this case, the PROTO TexturedBackground will be retrieved from the corresponding url. Similarly, a PROTO may reference another PROTO, in this case a declaration is also necessary:

#VRML_SIM R2022b utf8

EXTERNPROTO "https://raw.githubusercontent.com/cyberbotics/webots/R2022b/projects/appearances/protos/Plastic.proto"

PROTO MyProto [
  field SFVec3f  size    0.1 0.1 0.1  # Defines the size of the box.
]
{
  Shape {
    appearance Plastic {
    }
    geometry Box {
      size IS size
    }
  }
}

In general, the url can be defined multiple ways:

# remote PROTO
EXTERNPROTO "https://raw.githubusercontent.com/cyberbotics/webots/R2022b/projects/objects/backgrounds/protos/TexturedBackground.proto"

# local PROTO (absolute path)
EXTERNPROTO "/home/user/Documents/my_project/protos/TexturedBackground.proto"

# local PROTO (relative path)
EXTERNPROTO "../protos/TexturedBackground.proto"

The location (url) for official PROTO can be found in the file: WEBOTS_HOME/resources/proto-list.xml

Preparing your world for R2022b

If your world was created before R2022a, generally speaking it should be sufficient for you to load it with Webots R2022b and click the save button. Doing so, the backwards compatibility mechanism will do the declaration for you by assuming you are using the official Webots PROTO and setting the url accordingly.

Local PROTO

Since in principle a PROTO can represent any object, the backwards compatibility mechanism will stop at the world. If you created PROTO nodes yourself, you will need add the declarations to these files manually.

Ephemeral PROTO

Declared PROTO nodes that have no instances in the world will be shown under the Ephemeral EXTERNPROTO panel, which can be opened by clicking the similarly named button:

button

Doing so will open the panel:

ephemeral_externproto

If a PROTO was declared in the world file, the PROTO is not used when the world is loaded, it will show up in this list. Only PROTO included in this list can be inserted into the world using a Supervisor. If your controller spawns PROTO nodes, you need to declare them.

Clone this wiki locally