from ravestate import registry from ravestate.property import PropertyBase registry.register(name="rawio", props=(PropertyBase(name="in", default=""), PropertyBase(name="out", default="")))
import rclpy from ravestate import registry from ravestate.state import state from ravestate.receptor import receptor from ravestate.property import PropertyBase from std_msgs.msg import String rclpy.init() node = rclpy.create_node("vision_node") @state(triggers=":startup") def facerec_run(ctx): @receptor(ctx_wrap=ctx, write="facerec:face") def face_recognition_callback(ctx, msg): ctx["facerec:face"] = msg node.create_subscription(String, "/roboy/vision/recognized_faces", face_recognition_callback) rclpy.spin(node) @state(triggers=":shutdown") def facerec_shutdown(): node.destroy_node() rclpy.shutdown() registry.register(name="facerec", props=PropertyBase(name="face", default=""), states=(facerec_run, facerec_shutdown))
from ravestate.state import state from ravestate.receptor import receptor import ravestate_rawio @state(read="rawio:in") def console_shutdown(ctx): rawin = ctx["rawio:in"] if "bye" in rawin: ctx.shutdown() @state(triggers=":startup") def console_input(ctx): @receptor(ctx_wrap=ctx, write="rawio:in") def write_console_input(ctx_input, value: str): ctx_input["rawio:in"] = value while not ctx.shutting_down(): input_value = input("> ") write_console_input(input_value) @state(read="rawio:out") def console_output(ctx): print(ctx["rawio:out"]) registry.register(name="consoleio", states=(console_shutdown, console_input, console_output))
from ravestate_ui import service @state(triggers=":startup", write="rawio:out") def hello_world(ctx): ctx["rawio:out"] = "Hello f*****g world!" @state(read="rawio:in", write="rawio:out") def generic_answer(ctx): ctx["rawio:out"] = "Your input contains {} characters!".format( len(ctx["rawio:in"])) @state(read="facerec:face", write="rawio:out") def face_recognized(ctx): if ctx["facerec:face"]: ctx["rawio:out"] = "I see you, {}!".format(ctx["facerec:face"]) registry.register(name="hi", states=(hello_world, generic_answer, face_recognized)) ctx = Context() ctx.add_module("ravestate_conio") # ctx.add_module("ravestate_tts_watson") # ctx.add_module("ravestate_facerec") ctx.add_module("hi") ctx.run() service.advertise(ctx=ctx) ctx.shutdown()
from ravestate import registry from ravestate_tts_watson import states registry.register(name="tts_watson", states=(states.audio_talk, ))