def run_test(): import blast_world_test world = blast_planner.BlastPlannableWorld(blast_world_test.make_test_world(".")) initial_pickup_point = blast_world.BlastPt(17.460, 38.323, -2.330, "clarkcenterfirstfloor") #Grab the bag world.append_plan([blast_world.BlastCodeStep(None, "PLAN", {"world_limits": {"robot-location": {"stair4": initial_pickup_point}}, "extra_steps": [("stair4", "grab-object", {"tts-text": "Money Bag"}),],}, "plan_return"), blast_world.BlastCodeStep(None, "IF", {"condition": ('?', blast_world.BlastParameterPtr('plan_return')), "label_false": 'failure'}), blast_world.BlastCodeStep(None, "SETROBOTHOLDER", {"holder": "stair4.left-arm", "require-preexisting": True, "object-type": "coffee_money_bag"}), #Buy the coffee blast_world.BlastCodeStep(None, "PLAN", {"extra_steps": [("stair4", "buy-coffee", {"shop": "clark_peets_coffee_shop"}),],}, "plan_return"), blast_world.BlastCodeStep(None, "IF", {"condition": blast_world.BlastParameterPtr('plan_return'), "label_false": 'failure'}), #Return the bag blast_world.BlastCodeStep(None, "PLAN", {"world_limits": {"robot-location": {"stair4": initial_pickup_point}}, "extra_steps": [("stair4", "give-object", {"tts-text": "Coffee Cup"}),],}, "plan_return"), blast_world.BlastCodeStep(None, "IF", {"condition": blast_world.BlastParameterPtr('plan_return'), "label_false": 'failure'}), blast_world.BlastCodeStep(None, "RETURN"), blast_world.BlastCodeStep("failure", "FAIL") ], ["stair4",]) world.try_exec()
def test_main(): import blast_world_test man = BlastManager(["test_actions",], blast_world_test.make_test_world()) prog_id = man.plan_action("stair4", "coffee-run", {"person_location": blast_world.BlastPt(17.460, 38.323, -2.330, "clarkcenterfirstfloor"), "shop": "clark_peets_coffee_shop"}, {}) if prog_id == None: print "Failed to plan", prog_id man.stop() return False if man.wait_for_program(prog_id) == False: print "Action execution failed" man.stop() return False man.stop() a = "0a74cbe0c1cd7804120143ffe687a63bf8baec2f00d11e47583d075b7b3fc0350a5bcf3be0a1e4d6977904" a = a + "dde7e04531ac7662d74ade2749085a3deb79df8e417fa7d2bd93a92d744e22058b29c0012b2f282516" if a != man.world.world.get_hex_hash_state(): return False return True
def five_coffee_run_exec(): import blast_world_test world = blast_planner.BlastPlannableWorld(blast_world_test.make_test_world(".")) initial_pickup_point = blast_world.BlastPt(17.460, 38.323, -2.330, "clarkcenterfirstfloor") rand_point = blast_world.BlastPt(17.460, 38.323, -2.330, "clarkcenterfirstfloordoor") world.append_plan([blast_world.BlastCodeStep(None, "PLAN", {"world_limits": {"robot-location": {"stair4": rand_point}}}, "plan_return"), blast_world.BlastCodeStep(None, "IF", {"condition": blast_world.BlastParameterPtr('plan_return'), "label_false": 'failure'}), blast_world.BlastCodeStep(None, "PLAN", {"extra_steps": [("stair4", "five-coffee-run", {"shop": "clark_peets_coffee_shop", "person_location": initial_pickup_point}),],}, "plan_return"), blast_world.BlastCodeStep(None, "IF", {"condition": blast_world.BlastParameterPtr('plan_return'), "label_false": 'failure'}), blast_world.BlastCodeStep(None, "RETURN"), blast_world.BlastCodeStep("failure", "FAIL") ], ["stair4",]) world.run(True) world.print_old() print "Planned:", world.times_planned
def run(a, w): global manager, global_feed_alive, edit_types manager = blast_action.BlastManager(a, w) manager.on_robot_change = on_robot_change manager.world.on_program_changed = on_program_change manager.on_surface_change = on_surface_change edit_types = manager.world.world.types.copy() #mthread = ManagerThread() #mthread.start() app.run(debug=DEBUG, host='0.0.0.0', threaded=True, use_reloader=False, use_evalex=False) print "Terminating" queue_load(None, "terminate", None) global_feed_alive = False manager.stop() #mthread.alive = False #mthread.join() if __name__ == '__main__': if "--test" in sys.argv: my_path = os.path.dirname(os.path.abspath(__file__)) sys.path.append(my_path + "/../blast_test") my_path += "/../blast_test" import blast_world_test run(["test_actions"], blast_world_test.make_test_world(my_path))