Link Search Menu Expand Document

Scenes in arena-py

Scenes give arena-py programs access to an ARENA scene. It provides an interface to add/update objects, run animations, and many more! There are 3 main ways to define which server, scene name, and other arguments you wish to use:

  1. Python Object Args
  2. Environment Variable Args
  3. Command Line Args

Python Object Args

To get access to a scene in the ARENA, create a Scene object. Make sure you have proper permissions to access it!

scene = Scene(host="", scene="example")
# scene = Arena(host="", scene="example") works too

Scene Object Arguments

See Scene API Spec.

  • host: Base ARENA URL.
  • realm: ARENA realm name.
  • scene: ARENA scene name.
  • namespace: ARENA namespace. Default value is ARENA username.
  • video: If true, request permissions for video conference. Default = False.
  • debug: If true, print a log of all publish messages from this client. Default = False.
  • cli_args: If true, several standardized parameters are available. Default = False.
  • debug: If True, print authentication debug information and every published message. Ignore this parameter.
  • network_latency_interval: Interval (in ms) to run network graph latency update. Default value is 10000 (10 secs). Ignore this parameter.

Scene Object Callbacks

See Scene Callbacks.

Environment Variable Args

It is also possible to override these args un Scene() using environmental variables at the command line as shown below. This allows a simple way to re-target applications for your own environment without having to change the parameters manually in the code.

export # ARENA webserver main host
export SCENE=scene
export NAMESPACE=namespace

Definitions of other environment variables are available.

Command Line Args

The cli_args parameter can be used to avoid defining many of these parameters in the Scene() object, and expect the user to supply them on the command line. Several have been standardized, and we make it simple to include custom args for your program.

Simple CLI

If you have scene-dependant settings, like position, rogation, scale, which might change with each scene name change, you can supply them on the command line. Usage:

python -s example -p -10 0 10 -r 0 45 0 -c 0.5 0.5 0.5

Then you can consume them in your program:

scene = Scene(cli_args=True)

This is a list of the most common options available in this mode, (python3 -h to view):

-h, --help            show this help message and exit
-mh HOST, --host HOST
                        ARENA webserver main host to connect to
                        Namespace of scene
-s SCENE, --scene SCENE
                        Scene to publish and listen to
-d DEVICE, --device DEVICE
                        Device to publish and listen to
                        App position as cartesian.x cartesian.y cartesian.z
                        App rotation as euler.x euler.y euler.z
                        App scale as cartesian.x cartesian.y cartesian.z
-D, --debug           Debug mode.

Advanced CLI

You can add arbitrary arguments to any arena program.

python -s example --config ./configuration.json

You can specify the dictionary of help text, used in usage help, and the config will at least be None if unused. Simply set cli_args to true, use --config on the CLI, and then reference, but it’s a little unsafe if unused.

scene = Scene(cli_args={"config": "The location of the config file to load."})
# scene = Scene(cli_args=True)  # works too!
file = open(scene.args["config"])

Access to Persisted Objects

To get access to Objects in the persist database, you can use get_persisted_obj.

def main():
    obj = scene.get_persisted_obj(object_id)
    print(obj) # obj should be an object in persist with persist=True

You can also just do:

def main():
    obj = scene.all_objects[object_id]
    print(obj) # obj should be an object in persist with persist=True