-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
How to adapt your world or PROTO to Webots R2022b
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.
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
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.
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.
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:

Doing so will open the panel:

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.