scenic.simulators.webots.simulator

Interface to Webots for dynamic simulations.

This interface is intended to be instantiated from inside the controller script of a Webots Robot node with the supervisor field set to true. Such a script can create a WebotsSimulator (passing in a reference to the supervisor node) and then call its simulate method as usual to run a simulation. For an example, see examples/webots/generic/controllers/scenic_supervisor.py.

Scenarios written for this interface should use our generic Webots world model scenic.simulators.webots.model or a model derived from it. Objects which are instances of WebotsObject will be matched to Webots nodes; see the model documentation for details.

Summary of Module Members

Functions

getFieldSafe

Get field from webots object.

isPhysicsEnabled

Whether or not physics is enabled for this WebotsObject

Classes

WebotsSimulation

Simulation object for Webots.

WebotsSimulator

Simulator object for Webots.

Member Details

class WebotsSimulator(supervisor)[source]

Bases: Simulator

Simulator object for Webots.

Parameters:

supervisor – Supervisor node handle from the Webots Python API.

class WebotsSimulation(scene, supervisor, coordinateSystem=<scenic.simulators.webots.utils.WebotsCoordinateSystem object>, *, timestep, **kwargs)[source]

Bases: Simulation

Simulation object for Webots.

Attributes:

supervisor – Webots supervisor node used for the simulation. This is exposed for the use of scenarios which need to call Webots APIs directly; e.g. simulation().supervisor.setLabel(...).

getFieldSafe(webotsObject, fieldName)[source]

Get field from webots object. Return null if no such field exists.

Needed to workaround this issue (https://github.com/cyberbotics/webots/issues/5646)

Parameters:
  • webotsObject – webots object

  • fieldName – name of the field to look for

Returns:

Field|None – Field object if the field with the given name exists. None otherwise.

isPhysicsEnabled(webotsObject)[source]

Whether or not physics is enabled for this WebotsObject