Theater Demo Script

The following script demonstrates a basic action sequence representing one iteration of a show. Each action sends commands as OSC messages and then waits. The script must exit to allow other shows or idle time between performances.

#!/usr/bin/env python3
"""demo-show.py : demonstration of scripting action across all theater units
"""
import argparse, time, logging
import numpy as np

from pythonosc import osc_message_builder
from pythonosc import udp_client

import theater.config
import theater.network

# import common logging functions
import theater.logging

# initialize logging for this module
log = logging.getLogger('demo')

#================================================================
if __name__ == "__main__":

    # set up logging
    theater.logging.open_log_file('logs/demo-show.log')
    log.info("Starting demo-show.py")

    parser = argparse.ArgumentParser( description = "Simple scripted show.")
    parser.add_argument("--ip", default=theater.config.theater_IP,
                        help="IP address of the OSC receiver (default: %(default)s).")
    theater.logging.add_logging_args(parser)
    args = parser.parse_args()

    # Modify logging settings as per common arguments.
    theater.logging.configure_logging(args)

    # create OSC clients to send messages to the theater system
    network = theater.network.TheaterNetwork(args)

    # pulse each RGBA fixture with a specific color
    color_table = {'rgba1' : [0, 0, 255, 0],
                   'rgba2' : [255, 0, 0, 0],
                   'rgba3' : [0, 0, 0, 255],
                   'rgba4' : [0, 255, 0, 255],}

    for fixture in ['rgba1', 'rgba2', 'rgba3', 'rgba4']:
        network.lights.send_message("/fixture", [fixture] + color_table[fixture])
        log.debug("Lighting fixture %s", fixture)
        time.sleep(2)
        network.lights.send_message("/fixture", [fixture, 0, 0, 0, 0])

    # activate each mono light
    for fixture in ['lamp1', 'lamp2', 'lamp3', 'lamp4']:
        network.lights.send_message("/fixture", [fixture, 255])
        log.debug("Lighting fixture %s", fixture)
        time.sleep(1)

    # activate each fan one at a time
    for fixture in ['fan1', 'fan2', 'fan3', 'fan4']:
        network.lights.send_message("/fixture", [fixture, 255])
        log.debug("Lighting fixture %s", fixture)
        time.sleep(2)

    # deactivate each fan one at a time
    for fixture in ['fan1', 'fan2', 'fan3', 'fan4']:
        network.lights.send_message("/fixture", [fixture, 0])
        log.debug("Lighting fixture %s", fixture)
        time.sleep(2)

    # deactivate mono lights
    for fixture in ['lamp1', 'lamp2', 'lamp3', 'lamp4']:
        network.lights.send_message("/fixture", [fixture, 0])
        log.debug("Lighting fixture %s", fixture)
        time.sleep(1)

    # pulse each RGBA fixture full on
    for fixture in ['rgba1', 'rgba2', 'rgba3', 'rgba4']:
        network.lights.send_message("/fixture", [fixture, 255, 255, 255, 255])
        log.debug("Lighting fixture %s", fixture)
        time.sleep(2)
        network.lights.send_message("/fixture", [fixture, 0, 0, 0, 0])

    log.info("Exiting demo-show.py")

Motion Demo Script

The following script demonstrates issuing motion commands to a capstan winch set providing four stepper-motor capstan drives. Each action sends commands as OSC messages and then waits. The script must exit to allow other shows or idle time between performances.

#!/usr/bin/env python3
"""winch-demo.py : demonstration of scripting theater actions
"""
import argparse, time, logging
import numpy as np

from pythonosc import osc_message_builder
from pythonosc import udp_client

import theater.config
import theater.network

# import common logging functions
import theater.logging

# initialize logging for this module
show_name = 'winch-demo'
log = logging.getLogger(show_name)

#================================================================
if __name__ == "__main__":

    # set up logging
    theater.logging.open_log_file('logs/' + show_name + '.log')
    log.info("Starting %s", show_name)

    parser = argparse.ArgumentParser( description = "Simple scripted show.")
    parser.add_argument("--ip", default=theater.config.theater_IP,
                        help="IP address of the OSC receiver (default: %(default)s).")
    theater.logging.add_logging_args(parser)
    args = parser.parse_args()

    # Modify logging settings as per common arguments.
    theater.logging.configure_logging(args)

    # create OSC clients to send messages to the theater system
    network = theater.network.TheaterNetwork(args)

    # select a single motion unit; each winch set has a separate server
    winch1 = network.motion_server_by_name('winch1')
    winch2 = network.motion_server_by_name('winch2')

    # move each winch axis in turn
    for axis in ['x', 'y', 'z', 'a']:
        winch1.send_message("/spline", [axis, 0.0, 180.0, 180.0])
        time.sleep(0.5)

    # reverse back to start; each spline is relative to current position
    for axis in ['x', 'y', 'z', 'a']:
        winch1.send_message("/spline", [axis, 0.0, -180.0, -180.0])
        time.sleep(0.5)

    # Similar, but with a multi-segment cubic Beizer spline.  Each segment
    # requires three knot values.
    for axis in ['x', 'y', 'z', 'a']:
        winch1.send_message("/spline", [axis, 0.0, 180.0, 180.0,  90.0, -45.0, 0.0])
        time.sleep(0.5)

    # coordinated movement across different winch sets
    for axis in ['x', 'y', 'z', 'a']:
        winch1.send_message("/spline", [axis, 0.0, -180.0, -180.0])
        winch2.send_message("/spline", [axis, 0.0, -180.0, -180.0])
        time.sleep(0.5)

    log.info("Exiting %s", show_name)