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 __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): 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 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): 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 __init__(self): threading.Thread.__init__(self) self._round = 0 self._cube = 0 self._robot = None self._wait_for_tap_flag = False self._did_cozmo_tap_flag = False self._tap_action_finished = False self._animation_triggered = False self._trigger_message = False self._message = "" if USE_LOGGING: cozmo.setup_basic_logging() try: if USE_VIEWER: cozmo.connect_with_tkviewer(self.run) else: cozmo.connect(self.run) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
def main(): ib = IceBreaker() cozmo.setup_basic_logging() cozmo.connect_with_tkviewer(ib.run)
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)
def lights_blue(self): self.robot.set_all_backpack_lights(cozmo.lights.blue_light) ### startup async def run(sdk_conn): '''The run method runs once the Cozmo SDK is connected.''' robot = await sdk_conn.wait_for_robot() # Create the BallSearcher ballSearcher = BallSearcher(robot, aggression) try: await ballSearcher.main() except KeyboardInterrupt: print("") print("Exit requested by user") if __name__ == '__main__': cozmo.setup_basic_logging() cozmo.camera.Camera.enable_auto_exposure = False cozmo.robot.Robot.drive_off_charger_on_connect = False # Stay on charger until init try: cozmo.connect_with_tkviewer(run, force_on_top=True) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
def cozmoDoThisFunctionWithCameraFeed(cozmoFunction): cozmo.setup_basic_logging() try: cozmo.connect_with_tkviewer(cozmoFunction, force_on_top=True) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
robot = sdk_conn.wait_for_robot() #robot.go_to_pose(Pose(200, 200, 0,angle_z=degrees(90)), relative_to_robot=False).wait_for_completed() #print (robot.pose) tasks = [0, 0, 90, 0, 270, 0, 0] cozmo.objects.OBJECT_VISIBILITY_TIMEOUT = 0.2 while (True): pin = robot.world.visible_object_count() print(pin) obj = robot.world.visible_objects if (pin > 0): cube = robot.world.wait_until_observe_num_objects( num=1, object_type=cozmo.objects.LightCube, timeout=60) k = cube[-1].pose translation = robot.pose - k if (math.fabs(float(translation.position.x))) <= 5: break print(translation) robot.drive_straight(distance_mm(10), speed_mmps(50)).wait_for_completed() if __name__ == '__main__': cozmo.setup_basic_logging() try: cozmo.connect_with_tkviewer(run) except cozmo.ConnectionError as e: sys.exit("A connection error occurred: %s" % e)
def __init__(self, **kwargs): 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 main(): p = Patrol() cozmo.setup_basic_logging() cozmo.connect_with_tkviewer(p.run)
def __init__(self, *a, **kw): # init cozmo cozmo.setup_basic_logging() cozmo.connect_with_tkviewer(self.run)