Ejemplo n.º 1
0
def sound_element_thread(sound_queue):
    """
    Registers all of the sound playback commands for this element
    and handles when they're called
    """

    elem = Element("sound")

    # Register our callback to play sounds
    elem_class = SoundElement(sound_queue)
    elem.command_add("play_sound", elem_class.command_cb)
    elem.command_loop()
Ejemplo n.º 2
0
    run_element = Element("run_demo")

    res = run_element.command_send("robot_api",
                                   "home", {
                                       "v": VEL,
                                       "a": ACCEL
                                   },
                                   serialize=True)
    if (res['err_code'] != 0):
        return Response(err_code=1,
                        err_str="Failed to move to home position",
                        serialize=True)

    # turn off control
    set_control(run_element, False)

    return Response("Success", serialize=True)


if __name__ == '__main__':
    '''
    Mainloop, wait for the command to run the grab and then do
    the grab
    '''

    element = Element("demo")
    element.command_add("run", run_demo, timeout=60000)
    element.command_add("driving_position", driving_position, timeout=10000)
    element.command_add("home", home, timeout=10000)
    element.command_loop()
Ejemplo n.º 3
0
            buff = "{},".format(x_val)

            # And add each item from the iterable
            try:
                for v in val:
                    buff += "{},".format(v)
            except:
                buff += "{}".format(val)

            # Finish off with a newline and write to file
            buff += "\n"
            files[key].write(buff)

    # And note the success
    return Response("Success", serialize=True)


if __name__ == '__main__':
    elem = Element("record")
    elem.command_add("start", start_recording, timeout=1000, deserialize=True)
    elem.command_add("stop", stop_recording, timeout=1000, deserialize=True)
    elem.command_add("wait", wait_recording, timeout=60000, deserialize=True)
    elem.command_add("list", list_recordings, timeout=1000)
    elem.command_add("get", get_recording, timeout=1000, deserialize=True)
    elem.command_add("plot", plot_recording, timeout=1000000, deserialize=True)
    elem.command_add("csv", csv_recording, timeout=10000, deserialize=True)

    # Want to launch the plot thread s.t. our plot API can return quickly

    elem.command_loop()