import os

NAME = "Tai Chi"

# The Choregraphe project lives in a sibling folder with the same name
# as this file (minus the .py) - e.g. gestures/5_tai_chi/ next to
# gestures/5_tai_chi.py - containing manifest.xml and a
# behavior_1/behavior.xar subfolder, exactly what Choregraphe's
# "Export as package" produces.
PACKAGE_DIR = os.path.splitext(os.path.abspath(__file__))[0]
BEHAVIOR_SUBDIR = "behavior_1"


def run(motion, tts, teleop):
    # Deploys (first run only, cached after) + runs the actual
    # Choregraphe behavior on the robot - this blocks until it
    # finishes, same pattern as the Gangnam Style gesture.
    teleop.behavior_runner.ensure_running(PACKAGE_DIR, BEHAVIOR_SUBDIR)

    # Tai chi moves legs/hips through slow stances, so bring him back
    # to a known walk-ready stance afterward.
    teleop.idle_crouch()
