def start(self, code): def run(sdk_conn): '''The run method runs once Cozmo SDK is connected.''' self._robot = sdk_conn.wait_for_robot() self._origin = self._robot.pose self.cubes_to_numbers = {} for key in self._robot.world.light_cubes: self.cubes_to_numbers[self._robot.world.light_cubes.get( key).object_id] = key self.resetCubes() self.resetCustomObjects() self._robot.camera.image_stream_enabled = True bot = self import cozmo exec(code, locals(), locals()) from ws4py.client.threadedclient import WebSocketClient self._camClient = WebSocketClient('ws://localhost:9090/camPub') self._camClient.connect() self._wsClient = WebSocketClient('ws://localhost:9090/WsPub') self._wsClient.connect() self._dataPubThread = threading.Thread( target=self.feedRobotDataInThread) self._dataPubThread.daemon = True self._dataPubThread.start() cozmo.setup_basic_logging() cozmo.robot.Robot.drive_off_charger_on_connect = False cozmo.connect(run) self._robot = None
def __init__(self, *a, **kw): CozGame.__init__(self) # init cozmo cozmo.world.World.light_cube_factory = CustomCube cozmo.setup_basic_logging() cozmo.connect(self.run)
def __init__(self, *a, **kw): cozmo.setup_basic_logging() try: cozmo.connect_with_tkviewer(self.run, force_on_top=True) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
def start(self, code): def run(sdk_conn): '''The run method runs once Cozmo SDK is connected.''' self._robot = sdk_conn.wait_for_robot() self._origin = self._robot.pose self.cubes_to_numbers = {} for key in self._robot.world.light_cubes: self.cubes_to_numbers[self._robot.world.light_cubes.get( key).object_id] = key self.resetCubes() self._robot.camera.image_stream_enabled = True bot = self highlighter = Highlighter() highlighter.start() import cozmo exec(code, locals(), locals()) self._dataPubThread = threading.Thread( target=self.feedRobotDataInThread) self._dataPubThread.daemon = True self._dataPubThread.start() cozmo.setup_basic_logging() cozmo.robot.Robot.drive_off_charger_on_connect = False cozmo.connect(run) self._robot = None
def __init__(self, *a, **kw): #init cozmo cozmo.setup_basic_logging() cozmo.connect(self.run) while True: self.take_input()
def reconnect(): cozmo.setup_basic_logging() try: cozmo.connect_with_tkviewer(run) #cozmo.connect(run) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
def ButtonPressed(self): global server_ip server_ip = self.serverentry.get() self.root.destroy() cozmo.setup_basic_logging() cozmo.connect(run)
def __init__(self, *a, **kw): sys.setrecursionlimit(0x100000) self.setUpFitBit() cozmo.setup_basic_logging() cozmo.connect(self.startResponding)
def __init__(self, *a, **kw): sys.setrecursionlimit(0x100000) self.weatherObj = OpenWeather(PYOWM_API_KEY, self.city) cozmo.setup_basic_logging() cozmo.connect(self.startResponding)
def __init__(self): self._robot = None self._tk_root = 0 self._tk_label_input = 0 self._tk_label_output = 0 if USE_LOGGING: cozmo.setup_basic_logging() cozmo.connect(self.run)
def __init__(self): print("Class 'PlaceCubesAround' Init...") self._coz = None self._cubes = None self._origin = None cozmo.setup_basic_logging() cozmo.connect_with_tkviewer(self.run)
def __init__(self) -> None: self._robot: Robot = None Robot.drive_off_charger_on_connect = False cozmo.setup_basic_logging() self.PI: float = 3.14159265359 self._cubes_connected = False self._freetime = False self._sleeping = False
def run_cozmo(): def run(sdk_conn): #The run method runs once Cozmo is connected. robot = sdk_conn.wait_for_robot() robot.say_text("Hello World").wait_for_completed() robot.say_text("Hello World Again").wait_for_completed() global cozmo_command while True: if cozmo_command.value == 1: robot.turn_in_place(degrees(90)).wait_for_completed() cozmo_command.value = 0 time.sleep(1) if cozmo_command.value == 2: robot.turn_in_place(degrees(-90)).wait_for_completed() cozmo_command.value = 0 if cozmo_command.value == 3: robot.drive_straight(distance_mm(150), speed_mmps(50)).wait_for_completed() cozmo_command.value = 0 if cozmo_command.value == 4: robot.drive_straight(distance_mm(-150), speed_mmps(50)).wait_for_completed() cozmo_command.value = 0 if cozmo_command.value == 5: lookaround = robot.start_behavior( cozmo.behavior.BehaviorTypes.LookAroundInPlace) cubes = robot.world.wait_until_observe_num_objects( num=2, object_type=cozmo.objects.LightCube, timeout=60) lookaround.stop() if len(cubes) < 2: print("Error: need 2 Cubes but only found", len(cubes), "Cube(s)") else: robot.pickup_object(cubes[0]).wait_for_completed() robot.place_on_object(cubes[1]).wait_for_completed() if cozmo_command.value == 6: anim = robot.play_anim_trigger(cozmo.anim.Triggers.MajorWin) anim.wait_for_completed() cozmo_command.value = 0 if cozmo_command.value == 7: robot.set_all_backpack_lights(cozmo.lights.green_light) time.sleep(1) robot.set_all_backpack_lights(cozmo.lights.red_light) time.sleep(1) robot.set_all_backpack_lights(cozmo.lights.blue_light) time.sleep(1) robot.set_all_backpack_lights(cozmo.lights.white_light) time.sleep(1) robot.set_all_backpack_lights(cozmo.lights.off_light) cozmo.setup_basic_logging() try: cozmo.connect(run) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
def __init__(self, *a, **kw): sys.setrecursionlimit(0x100000) self.questions = Questions() cozmo.setup_basic_logging() # cozmo.connect_with_tkviewer(self.startResponding) cozmo.connect(self.startResponding)
def main(args=None): #rospy.init_node('cozmo_driver') rclpy.init(args=args) cozmo.setup_basic_logging() try: cozmo.connect(cozmo_app) except cozmo.ConnectionError as err: sys.exit('A connection error occurred: {}'.format(err)) rclpy.shutdown()
def __init__(self, *a, **kw): CozGame.__init__(self) self._answer = None self._coz = None self._cubes = None cozmo.setup_basic_logging() cozmo.connect(self.run)
def cozmo_main(self): if self._use_logging: cozmo.setup_basic_logging() try: cozmo.connect(self.cozmo_run, connector=cozmo.run.FirstAvailableConnector()) self._cozmo_conn.shutdown() self._cozmo_loop.stop() except cozmo.ConnectionError as e: ue.log('No Cozmo :(')
def __init__(self, focus_time, *a, **kw): WOC.__init__(self) self.focus_time = focus_time self.curr_time = 0 self._face = None self._prevPose = None self._supervisor = None cozmo.setup_basic_logging() cozmo.connect_with_tkviewer(self.run)
def ButtonPressed(self): global currentPlayerName global server_ip currentPlayerName = self.entry.get() server_ip = self.serverentry.get() self.root.destroy() cozmo.setup_basic_logging() cozmo.connect_with_tkviewer(run)
def __init__(self, *a, **kw): WOC.__init__(self) cozmo.setup_basic_logging() try: cozmo.connect(self.run) except cozmo.ConnectionError as e: print("A connection error occurred: %s" % e) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(self.run())
def __init__(self): self._count = 0 self._cube = 0 self._robot = None self._is_busy = False if USE_LOGGING: cozmo.setup_basic_logging() if USE_VIEWER: cozmo.connect_with_tkviewer(self.run) else: cozmo.connect(self.run)
def __init__(self): self.pubnub = Pubnub(publish_key=DatingCozmo.PUBLISH_KEY, subscribe_key=DatingCozmo.SUBSCRIBE_KEY) self.pubnub.subscribe(channels=DatingCozmo.SUBSCRIBE_CHANNEL, callback=self.on_message_received, error=self.error, connect=self.connect, reconnect=self.reconnect, disconnect=self.disconnect) cozmo.setup_basic_logging() cozmo.connect(self.run)
def __init__(self): print("Class 'PowerDown' Init...") self._coz = None self._cubes = None self._target = None self._colors = [RefColor.GREEN, RefColor.RED, RefColor.CYAN] self.complete = False self.action = None self.round_end = False self.failure = False cozmo.setup_basic_logging() cozmo.connect_with_tkviewer(self.run)
def __init__(self): cozmo.conn.CozmoConnection.robot_factory = HorseShoeRobot cozmo.setup_basic_logging() self.pubnub = Pubnub(publish_key=HorseShoe.PUBLISH_KEY, subscribe_key=HorseShoe.SUBSCRIBE_KEY) self.pubnub.subscribe(channels=HorseShoe.SUBSCRIBE_CHANNEL, callback=self.on_message_received, error=self.error, connect=self.connect, reconnect=self.reconnect, disconnect=self.disconnect) self.init_game()
def reconnect(): global logging_is_setup if not logging_is_setup: cozmo.setup_basic_logging() logging_is_setup = True cozmo.robot.Robot.drive_off_charger_on_connect = False try: if len(sys.argv) <= 1: cozmo.connect_with_tkviewer(run) else: cozmo.connect(run) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
def __init__(self, *a, **kw): WOC.__init__(self) if os.path.exists(self.OUTPUT_VIDEO_NAME): os.remove(self.OUTPUT_VIDEO_NAME) if self.INSTAGRAM_PASSWORD == "": with open(self.INSTAGRAM_FILE_NAME) as f: self.INSTAGRAM_PASSWORD = f.readlines()[0]; self.insta = InstagramAPI(self.INSTAGRAM_USER_NAME, self.INSTAGRAM_PASSWORD) self.insta.login() # login cozmo.setup_basic_logging() cozmo.connect(self.run)
def post(self, request, *args, **kwargs): # Abrimos la conexión con Cozmo cozmo.setup_basic_logging() # Leemos los comandos, los parámetros y ejecutamos la orden. data = JSONParser().parse(request) print(data) global commands_to_cozmo commands_to_cozmo = data try: cozmo.connect(run_commands, connector=cozmo.run.FirstAvailableConnector()) except cozmo.ConnectionError as e: sys.exit("Connection Error: %s" % e) return JsonResponse("ACTION COMPLETED", status=200, safe=False)
def __init__(self): self._robot = None self._cubes = [] # initial setting ensures we don't first randomize to PRIMARY_GOAL self._goal = PRIMARY_GOAL self._sfx_success = pygame.mixer.Sound('./sfx/success.wav') self._sfx_tick = pygame.mixer.Sound('./sfx/tick.wav') if USE_LOGGING: cozmo.setup_basic_logging() if USE_VIEWER: cozmo.connect_with_tkviewer(self.run) else: cozmo.connect(self.run)
def __init__(self): # self.startBoard = [] self.startBoard = [["." for x in range(9)] for y in range(9)] self.solveList = [] self._count = 0 self._cube = 0 self._cubes = [] #list of lists self._robot = None self._is_busy = False self.boardSide = 609.6 self.squareSide = 67.73 if USE_LOGGING: cozmo.setup_basic_logging() if USE_VIEWER: cozmo.connect_with_tkviewer(self.run) else: cozmo.connect(self.run)
def setup(robot_config): global camera_id global infoServer global video_port global annotated global colour camera_id = robot_config.get('robot', 'camera_id') infoServer = robot_config.get('misc', 'info_server') video_port = getVideoPort() cozmo.setup_basic_logging() cozmo.robot.Robot.drive_off_charger_on_connect = False extended_command.add_command('.annotate', set_annotated) extended_command.add_command('.autodock', autodock) extended_command.add_command('.color', set_colour) extended_command.add_command('.colour', set_colour) try: thread.start_new_thread(cozmo.run_program, (run, )) # thread.start_new_thread(cozmo.run_program, (run,), {'use_3d_viewer':True}) except KeyboardInterrupt as e: pass except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e) while not coz: try: time.sleep(0.5) print("not coz") except (KeyboardInterrupt, SystemExit): sys.exit() if robot_config.has_section('cozmo'): send_online_status = robot_config.getboolean('cozmo', 'send_online_status') annotated = robot_config.getboolean('cozmo', 'annotated') colour = robot_config.getboolean('cozmo', 'colour') else: send_online_status = True if send_online_status: print("Enabling online status") schedule.repeat_task(10, updateServer)
import sys import cozmo def run(sdk_conn): '''The run method runs once Cozmo is connected.''' robot = sdk_conn.wait_for_robot() cubes = robot.world.wait_until_observe_num_objects(num=3, object_type=cozmo.objects.LightCube, timeout=60) max_dst, targ = 0, None for cube in cubes: translation = robot.pose - cube.pose dst = translation.position.x ** 2 + translation.position.y ** 2 if dst > max_dst: max_dst, targ = dst, cube if len(cubes) < 3: print("Error: need 3 Cubes but only found", len(cubes), "Cube(s)") else: robot.pickup_object(targ).wait_for_completed() if __name__ == '__main__': cozmo.setup_basic_logging() try: cozmo.connect_with_tkviewer(run, force_on_top=True) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)