import os, sys from tools.persistence import Persistence path = os.path.abspath(os.path.dirname(__file__)) if len(sys.argv) > 1: controller_name = sys.argv[1] else: controller_name = "0" print(f"controller selected: {path}/controller_specs/{controller_name}.txt") controller = Persistence.load_controller( folder_path=f"{path}/controller_specs", name=controller_name) print(controller) run = controller.simulate() print(run)
from tools.strings import StringMng from tools.strix import Strix path = os.path.abspath(os.path.dirname(__file__)) if len(sys.argv) > 1: controller_name = sys.argv[1] else: controller_name = "5" print(f"controller selected: {path}/controller_specs/{controller_name}.txt") a, g, i, o = StringMng.parse_controller_specification_from_file( f"{path}/controller_specs/{controller_name}.txt") realizable, kiss_format, exec_time = Strix.generate_controller(a, g, i, o) controller = Controller(mealy_machine=kiss_format) Persistence.dump_controller(controller, f"{path}/controller_specs", controller_name) print("\n~~~MEALY MACHINE~~~\n" + str(controller)) Store.save_to_file(str(controller), f"{controller_name}_table.txt", absolute_folder_path=f"{path}/controller_specs") run = controller.simulate() print("\n\n\n~~~SIMULATION OF A RUN~~~\n" + run) Store.save_to_file(str(run), f"{controller_name}_run.txt", absolute_folder_path=f"{path}/controller_specs")
from tools.persistence import Persistence from running_example import output_folder_name from tools.storage import Store """Load CGG""" cgg = Persistence.load_cgg(output_folder_name) """Launch a simulation of n_steps where each contexts does change for at least t_min_context """ run = cgg.orchestrate(n_steps=50, t_min_context=6) print(run) """Save simulation as text file""" Store.save_to_file(str(run), file_name="simulation.txt", output_folder_name=output_folder_name)
import os from controller import Controller from tools.persistence import Persistence from tools.storage import Store from tools.strings import StringMng from tools.strix import Strix path = os.path.abspath(os.path.dirname(__file__)) controller_name = "good_0" a, g, i, o = StringMng.parse_controller_specification_from_file(f"{path}/{controller_name}.txt") realizable, kiss_format, exec_time = Strix.generate_controller(a, g, i, o) controller = Controller(mealy_machine=kiss_format) Persistence.dump_controller(controller, path, controller_name) print(controller) Store.save_to_file(str(controller), f"{controller_name}_table.txt", absolute_folder_path=f"{path}") run = controller.simulate() print(run) Store.save_to_file(str(run), f"{controller_name}_run.txt", absolute_folder_path=f"{path}")
assumptions=no_objects_when_hold, guarantees=patrol_living_room & stay_location_if_object & dont_hold_if_no_object & if_drop_not_hold & drop_near_garbage & keep_free_hands), world=w), Node( name="gpse", description="General Purpose Service Robot." "Similar to a modern smart-speaker," "The robot can be asked to do anything and it immediately response with a voice notification", specification=Contract( guarantees=BoundReaction(w["alexa"], w["reply"])), world=w), Node( name="groceries", description= "The robot stores groceries into a pantry shelf while paying attention" " to sorting objects in their appropriate place, i.e. storing an apple next to other fruits.", context=w["housekeeping"] & w["groceries"], specification=Contract( guarantees=patrol_kitchen & PromptReaction(w["groceries_recognized"], w["store"] & w["k2"])), world=w), } """Save set of goals so that they can be loaded later""" Persistence.dump_goals(set_of_goals, output_folder_name) except CGGException as e: raise e
n_day = Node(name="day_patrol_a", context=w["day"], specification=ordered_patrol_day, world=w) n_night = Node(name="night_patrol_b", context=w["night"], specification=ordered_patrol_night, world=w) t_cgg_start = time.time() cgg = Node.build_cgg({n_day, n_night}) t_cgg_end = time.time() t_cgg = t_cgg_end - t_cgg_start cgg.set_session_name(folder_name) cgg.save() print(cgg) cgg.realize_all(t_trans=3) cgg.save() Persistence.dump_cgg(cgg) run = cgg.orchestrate(n_steps=50, t_min_context=6) print(run) except CGGException as e: raise e
import os from tests.synthesis_examples import folder_name from tools.persistence import Persistence path = os.path.abspath(os.path.dirname(__file__)) controller = Persistence.load_controller(path) print(controller) run = controller.simulate() print(run)
from cgg import Node from cgg.exceptions import CGGException from robocup import output_folder_name from tools.persistence import Persistence try: """Load the goals""" set_of_goals = Persistence.load_goals(output_folder_name) """Automatically build the CGG""" cgg = Node.build_cgg(set_of_goals) print(cgg) """Setting the saving folder""" cgg.set_session_name(output_folder_name) """Save CGG as text file""" cgg.save() """Save CGG so that it can be loaded later""" Persistence.dump_cgg(cgg) except CGGException as e: raise e
from tools.persistence import Persistence from tools.storage import Store folder_name = "crome_evaluation" cgg = Persistence.load_cgg(folder_name) """Launch a simulation of n_steps where each contexts does change for at least t_min_context """ run = cgg.orchestrate(n_steps=50, t_min_context=6) print(run)
from tools.persistence import Persistence from robocup import output_folder_name """Load CGG""" cgg = Persistence.load_cgg(output_folder_name) """Realize Specification and Transition Controllers indicating the Maximum Transition Time""" cgg.realize_all(t_trans=3) print(cgg) """Save CGG again with the controllers information""" cgg.save() """Save CGG for persistence""" Persistence.dump_cgg(cgg)