Last active
June 17, 2020 17:37
-
-
Save erica/a97128ec7aae2e01b3ef5b809e375d10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from enum import * | |
| import cozmo | |
| from cozmo.util import degrees | |
| from Triggers import * | |
| # Log Error | |
| def error(message): | |
| print("*********************ERROR:", message) | |
| # Enumerations | |
| class Direction(IntEnum): | |
| '''Driving direction.''' | |
| forward = 1 | |
| backward = -1 | |
| class Speed(IntEnum): | |
| '''Driving speed.''' | |
| normal = 1 | |
| fast = 2 | |
| # Cubes | |
| cube1ID = cozmo.objects.LightCube1Id # paperclip | |
| cube2ID = cozmo.objects.LightCube2Id # lamp | |
| cube3ID = cozmo.objects.LightCube3Id # dot | |
| cubeIDs = [cube1ID, cube2ID, cube3ID] # [1, 2, 3] | |
| # Colors | |
| def lightLevel(level): | |
| return int(level * 255.0) | |
| def lightColor(r: float, g: float, b: float): | |
| return cozmo.lights.Color(rgb=(lightLevel(r), | |
| lightLevel(g), lightLevel(b))) | |
| def light(color): | |
| return cozmo.lights.Light(color) | |
| class Cube: | |
| def __init__(self, cube): | |
| self.cube = cube | |
| def setColor(self, color): | |
| self.cube.set_lights(light(color)) | |
| def switchOff(self): | |
| self.cube.set_lights(cozmo.lights.off_light) | |
| def waitForTap(self, seconds = 3): | |
| try: | |
| self.cube.wait_for_tap(timeout = seconds) | |
| return True | |
| except: | |
| print("cube tap timed out") | |
| return False | |
| class Cozmo: | |
| def __init__(self, robot): | |
| self.robot = robot | |
| self.world = robot.world | |
| self.behaviors = cozmo.behavior.BehaviorTypes | |
| self.currentBehavior = "idle" | |
| self.activeCube = "no cube" | |
| self.cubes = [] | |
| @classmethod | |
| def startUp(self, mainFunction): | |
| '''Initialize basic logging and make connection''' | |
| cozmo.setup_basic_logging() | |
| try: | |
| cozmo.connect(mainFunction) | |
| except cozmo.ConnectionError as err: | |
| sys.exit("Connection error: %s" % err) | |
| @classmethod | |
| def robot(self, sdk_conn): | |
| '''Fetch robot instance''' | |
| return Cozmo(sdk_conn.wait_for_robot()) | |
| def cube(self, idx): | |
| return Cube(self.robot.world.light_cubes.get(cubeIDs[idx])) | |
| def say(self, text): | |
| '''Instruct cozmo to speak text.''' | |
| speak = self.robot.say_text(text) | |
| speak.wait_for_completed() | |
| def drive(self, | |
| time = 3, | |
| direction: Direction = Direction.forward, | |
| speed: Speed = Speed.normal): | |
| '''Drive cozmo for `time` seconds in `direction` at `speed`''' | |
| goSpeed = float(direction) * float(speed) * 50 | |
| self.robot.drive_wheels(goSpeed, goSpeed, duration = time) | |
| def turn(self, degrees = 180): | |
| '''Turn cozmo for n degrees''' | |
| rotation = self.robot.turn_in_place(cozmo.util.degrees(degrees)) | |
| rotation.wait_for_completed() | |
| # Behaviors | |
| def stopBehavior(self): | |
| if self.currentBehavior == "idle": | |
| return | |
| self.currentBehavior.stop() | |
| self.currentBehavior = "idle" | |
| def findFaces(self): | |
| self.currentBehavior = self.robot.start_behavior(self.behaviors.FindFaces) | |
| def knockOverCubes(self): | |
| self.currentBehavior = self.robot.start_behavior(self.behaviors.KnockOverCubes) | |
| def lookAroundInPlace(self): | |
| self.currentBehavior = self.robot.start_behavior(self.behaviors.LookAroundInPlace) | |
| def pounceOnMotion(self): | |
| self.currentBehavior = self.robot.start_behavior(self.behaviors.PounceOnMotion) | |
| def rollBlock(self): | |
| self.currentBehavior = self.robot.start_behavior(self.behaviors.RollBlock) | |
| def stackBlocks(self): | |
| self.currentBehavior = self.robot.start_behavior(self.behaviors.StackBlocks) | |
| def findACube(self): | |
| self.lookAroundInPlace() | |
| try: | |
| cube = self.robot.world.wait_for_observed_light_cube(timeout=30) | |
| self.stopBehavior() | |
| self.activeCube = cube | |
| self.cubes = [cube] | |
| return True | |
| except: | |
| self.activeCube = "no cube" | |
| self.cubes = [] | |
| self.stopBehavior() | |
| return False | |
| def findCubes(self, count): | |
| self.lookAroundInPlace() | |
| self.cubes = self.robot.world.wait_until_observe_num_objects(num=count, object_type=cozmo.objects.LightCube, timeout=60) | |
| self.stopBehavior() | |
| return self.cubes | |
| def countCubes(self): | |
| count = len(self.cubes) | |
| responses = { 0 : "No cubes", 1 : "One cube", 2 : "Two cubes", 3 : "Three Cubes" } | |
| response = responses[count] | |
| self.say(response) | |
| def pickupCube(idx): | |
| if idx < len(self.cubes): | |
| self.robot.pickup_object(self.cubes[idx]).wait_for_completed() | |
| else: | |
| error("Bad cube idx " + str(idx)) | |
| def takeCube(self): | |
| if self.activeCube == "no cube": | |
| error("No cube") | |
| self.say("No cube") | |
| self.robot.pickup_object(self.activeCube).wait_for_completed() | |
| def dropCube(self): | |
| if self.activeCube == "no cube": | |
| error("No cube") | |
| self.say("No cube") | |
| self.robot.place_object_on_ground_here(self.activeCube).wait_for_completed() | |
| # Triggered Animations | |
| def trigger(self, triggerName): | |
| if triggerName in triggerActions: | |
| theTrigger = getTrigger(triggerName) | |
| try: | |
| anim = self.robot.play_anim_trigger(theTrigger) | |
| anim.wait_for_completed() | |
| except: | |
| error("problem during anim") | |
| def celebrate(self): | |
| self.trigger("MajorWin") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Cozmo import * | |
| # Fire Engine Red (FF0E00, [255, 14, 0], [1.00, 0.06, 0.00]) | |
| colorRed = lightColor(1.0000, 0.0561, 0.0000) | |
| # Tangerine (FF8D00, [255, 141, 0], [1.00, 0.56, 0.00]) | |
| colorOrange = lightColor(1.0000, 0.5561, 0.0000) | |
| # Bright Yellow (F0FF00, [240, 255, 0], [0.94, 1.00, 0.00]) | |
| colorYellow = lightColor(0.9439, 1.0000, 0.0000) | |
| # Bright Lime Green (71FF00, [113, 255, 0], [0.44, 1.00, 0.00]) | |
| colorLime = lightColor(0.4439, 1.0000, 0.0000) | |
| # Bright Green (00FF0E, [0, 255, 14], [0.00, 1.00, 0.06]) | |
| colorGreen = lightColor(0.0000, 1.0000, 0.0561) | |
| # Turquoise Green (00FF8D, [0, 255, 141], [0.00, 1.00, 0.56]) | |
| colorTurquoise = lightColor(0.0000, 1.0000, 0.5561) | |
| # Cyan (00F0FF, [0, 240, 255], [0.00, 0.94, 1.00]) | |
| colorCyan = lightColor(0.0000, 0.9439, 1.0000) | |
| # Bright Blue (0071FF, [0, 113, 255], [0.00, 0.44, 1.00]) | |
| colorBlue = lightColor(0.0000, 0.4439, 1.0000) | |
| # Primary Blue (0E00FF, [14, 0, 255], [0.06, 0.00, 1.00]) | |
| colorPurpleBlue = lightColor(0.0561, 0.0000, 1.0000) | |
| # Vivid Purple (8D00FF, [141, 0, 255], [0.56, 0.00, 1.00]) | |
| colorPurple = lightColor(0.5561, 0.0000, 1.0000) | |
| # Bright Magenta (FF00F0, [255, 0, 240], [1.00, 0.00, 0.94]) | |
| colorMagenta = lightColor(1.0000, 0.0000, 0.9439) | |
| # Strong Pink (FF0071, [255, 0, 113], [1.00, 0.00, 0.44]) | |
| colorPink = lightColor(1.0000, 0.0000, 0.4439) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Cozmo import * | |
| # print(dir(cozmo.anim.Triggers)) | |
| # This list must be updated with each SDK release | |
| triggerActions = {"AcknowledgeFaceInitPause" : cozmo.anim.Triggers.AcknowledgeFaceInitPause, | |
| "AcknowledgeFaceNamed" : cozmo.anim.Triggers.AcknowledgeFaceNamed, | |
| "AcknowledgeFaceUnnamed" : cozmo.anim.Triggers.AcknowledgeFaceUnnamed, | |
| "AcknowledgeObject" : cozmo.anim.Triggers.AcknowledgeObject, | |
| "AskToBeRightedLeft" : cozmo.anim.Triggers.AskToBeRightedLeft, | |
| "AskToBeRightedRight" : cozmo.anim.Triggers.AskToBeRightedRight, | |
| "BlockReact" : cozmo.anim.Triggers.BlockReact, | |
| "BuildPyramidReactToBase" : cozmo.anim.Triggers.BuildPyramidReactToBase, | |
| "BuildPyramidSuccess" : cozmo.anim.Triggers.BuildPyramidSuccess, | |
| "CantHandleTallStack" : cozmo.anim.Triggers.CantHandleTallStack, | |
| "ConnectWakeUp" : cozmo.anim.Triggers.ConnectWakeUp, | |
| "Count" : cozmo.anim.Triggers.Count, | |
| "CozmoSaysBadWord" : cozmo.anim.Triggers.CozmoSaysBadWord, | |
| "CozmoSaysGetIn" : cozmo.anim.Triggers.CozmoSaysGetIn, | |
| "CozmoSaysGetOut" : cozmo.anim.Triggers.CozmoSaysGetOut, | |
| "CozmoSaysIdle" : cozmo.anim.Triggers.CozmoSaysIdle, | |
| "CozmoSaysSpeakGetInLong" : cozmo.anim.Triggers.CozmoSaysSpeakGetInLong, | |
| "CozmoSaysSpeakGetInMedium" : cozmo.anim.Triggers.CozmoSaysSpeakGetInMedium, | |
| "CozmoSaysSpeakGetInShort" : cozmo.anim.Triggers.CozmoSaysSpeakGetInShort, | |
| "CozmoSaysSpeakGetOutLong" : cozmo.anim.Triggers.CozmoSaysSpeakGetOutLong, | |
| "CozmoSaysSpeakGetOutMedium" : cozmo.anim.Triggers.CozmoSaysSpeakGetOutMedium, | |
| "CozmoSaysSpeakGetOutShort" : cozmo.anim.Triggers.CozmoSaysSpeakGetOutShort, | |
| "CozmoSaysSpeakLoop" : cozmo.anim.Triggers.CozmoSaysSpeakLoop, | |
| "CubeMovedSense" : cozmo.anim.Triggers.CubeMovedSense, | |
| "CubeMovedUpset" : cozmo.anim.Triggers.CubeMovedUpset, | |
| "CubePounceFake" : cozmo.anim.Triggers.CubePounceFake, | |
| "CubePounceGetIn" : cozmo.anim.Triggers.CubePounceGetIn, | |
| "CubePounceGetOut" : cozmo.anim.Triggers.CubePounceGetOut, | |
| "CubePounceGetReady" : cozmo.anim.Triggers.CubePounceGetReady, | |
| "CubePounceGetUnready" : cozmo.anim.Triggers.CubePounceGetUnready, | |
| "CubePounceIdleLiftDown" : cozmo.anim.Triggers.CubePounceIdleLiftDown, | |
| "CubePounceIdleLiftUp" : cozmo.anim.Triggers.CubePounceIdleLiftUp, | |
| "CubePounceLoseHand" : cozmo.anim.Triggers.CubePounceLoseHand, | |
| "CubePounceLoseRound" : cozmo.anim.Triggers.CubePounceLoseRound, | |
| "CubePounceLoseSession" : cozmo.anim.Triggers.CubePounceLoseSession, | |
| "CubePouncePounceClose" : cozmo.anim.Triggers.CubePouncePounceClose, | |
| "CubePouncePounceNormal" : cozmo.anim.Triggers.CubePouncePounceNormal, | |
| "CubePounceWinHand" : cozmo.anim.Triggers.CubePounceWinHand, | |
| "CubePounceWinRound" : cozmo.anim.Triggers.CubePounceWinRound, | |
| "CubePounceWinSession" : cozmo.anim.Triggers.CubePounceWinSession, | |
| "DriveEndAngry" : cozmo.anim.Triggers.DriveEndAngry, | |
| "DriveEndDefault" : cozmo.anim.Triggers.DriveEndDefault, | |
| "DriveEndLaunch" : cozmo.anim.Triggers.DriveEndLaunch, | |
| "DriveLoopAngry" : cozmo.anim.Triggers.DriveLoopAngry, | |
| "DriveLoopDefault" : cozmo.anim.Triggers.DriveLoopDefault, | |
| "DriveLoopLaunch" : cozmo.anim.Triggers.DriveLoopLaunch, | |
| "DriveStartAngry" : cozmo.anim.Triggers.DriveStartAngry, | |
| "DriveStartDefault" : cozmo.anim.Triggers.DriveStartDefault, | |
| "DriveStartLaunch" : cozmo.anim.Triggers.DriveStartLaunch, | |
| "DroneModeBackwardDrivingEnd" : cozmo.anim.Triggers.DroneModeBackwardDrivingEnd, | |
| "DroneModeBackwardDrivingLoop" : cozmo.anim.Triggers.DroneModeBackwardDrivingLoop, | |
| "DroneModeBackwardDrivingStart" : cozmo.anim.Triggers.DroneModeBackwardDrivingStart, | |
| "DroneModeCliffEvent" : cozmo.anim.Triggers.DroneModeCliffEvent, | |
| "DroneModeForwardDrivingEnd" : cozmo.anim.Triggers.DroneModeForwardDrivingEnd, | |
| "DroneModeForwardDrivingLoop" : cozmo.anim.Triggers.DroneModeForwardDrivingLoop, | |
| "DroneModeForwardDrivingStart" : cozmo.anim.Triggers.DroneModeForwardDrivingStart, | |
| "DroneModeGetIn" : cozmo.anim.Triggers.DroneModeGetIn, | |
| "DroneModeGetOut" : cozmo.anim.Triggers.DroneModeGetOut, | |
| "DroneModeIdle" : cozmo.anim.Triggers.DroneModeIdle, | |
| "DroneModeKeepAlive" : cozmo.anim.Triggers.DroneModeKeepAlive, | |
| "DroneModeTurboDrivingStart" : cozmo.anim.Triggers.DroneModeTurboDrivingStart, | |
| "FacePlantRoll" : cozmo.anim.Triggers.FacePlantRoll, | |
| "FacePlantRollArmUp" : cozmo.anim.Triggers.FacePlantRollArmUp, | |
| "FailedToRightFromFace" : cozmo.anim.Triggers.FailedToRightFromFace, | |
| "FlipDownFromBack" : cozmo.anim.Triggers.FlipDownFromBack, | |
| "FrustratedByFailure" : cozmo.anim.Triggers.FrustratedByFailure, | |
| "FrustratedByFailureMajor" : cozmo.anim.Triggers.FrustratedByFailureMajor, | |
| "GoToSleepGetIn" : cozmo.anim.Triggers.GoToSleepGetIn, | |
| "GoToSleepGetOut" : cozmo.anim.Triggers.GoToSleepGetOut, | |
| "GoToSleepOff" : cozmo.anim.Triggers.GoToSleepOff, | |
| "GoToSleepSleeping" : cozmo.anim.Triggers.GoToSleepSleeping, | |
| "HikingDrivingEnd" : cozmo.anim.Triggers.HikingDrivingEnd, | |
| "HikingDrivingLoop" : cozmo.anim.Triggers.HikingDrivingLoop, | |
| "HikingDrivingStart" : cozmo.anim.Triggers.HikingDrivingStart, | |
| "HikingInterestingEdgeThought" : cozmo.anim.Triggers.HikingInterestingEdgeThought, | |
| "HikingIntro" : cozmo.anim.Triggers.HikingIntro, | |
| "HikingLookAround" : cozmo.anim.Triggers.HikingLookAround, | |
| "HikingObserve" : cozmo.anim.Triggers.HikingObserve, | |
| "HikingReactToEdge" : cozmo.anim.Triggers.HikingReactToEdge, | |
| "HikingReactToNewArea" : cozmo.anim.Triggers.HikingReactToNewArea, | |
| "HikingReactToPossibleMarker" : cozmo.anim.Triggers.HikingReactToPossibleMarker, | |
| "HikingSquintEnd" : cozmo.anim.Triggers.HikingSquintEnd, | |
| "HikingSquintLoop" : cozmo.anim.Triggers.HikingSquintLoop, | |
| "HikingSquintStart" : cozmo.anim.Triggers.HikingSquintStart, | |
| "HikingWakeUpOffCharger" : cozmo.anim.Triggers.HikingWakeUpOffCharger, | |
| "IdleOnCharger" : cozmo.anim.Triggers.IdleOnCharger, | |
| "InteractWithFaceTrackingIdle" : cozmo.anim.Triggers.InteractWithFaceTrackingIdle, | |
| "InteractWithFacesInitialNamed" : cozmo.anim.Triggers.InteractWithFacesInitialNamed, | |
| "InteractWithFacesInitialUnnamed" : cozmo.anim.Triggers.InteractWithFacesInitialUnnamed, | |
| "KnockOverEyes" : cozmo.anim.Triggers.KnockOverEyes, | |
| "KnockOverFailure" : cozmo.anim.Triggers.KnockOverFailure, | |
| "KnockOverGrabAttempt" : cozmo.anim.Triggers.KnockOverGrabAttempt, | |
| "KnockOverPreActionNamedFace" : cozmo.anim.Triggers.KnockOverPreActionNamedFace, | |
| "KnockOverPreActionUnnamedFace" : cozmo.anim.Triggers.KnockOverPreActionUnnamedFace, | |
| "KnockOverSuccess" : cozmo.anim.Triggers.KnockOverSuccess, | |
| "LookInPlaceForFacesBodyPause" : cozmo.anim.Triggers.LookInPlaceForFacesBodyPause, | |
| "LookInPlaceForFacesHeadMovePause" : cozmo.anim.Triggers.LookInPlaceForFacesHeadMovePause, | |
| "MajorFail" : cozmo.anim.Triggers.MajorFail, | |
| "MajorWin" : cozmo.anim.Triggers.MajorWin, | |
| "MeetCozmoFirstEnrollmentCelebration" : cozmo.anim.Triggers.MeetCozmoFirstEnrollmentCelebration, | |
| "MeetCozmoFirstEnrollmentRepeatName" : cozmo.anim.Triggers.MeetCozmoFirstEnrollmentRepeatName, | |
| "MeetCozmoFirstEnrollmentSayName" : cozmo.anim.Triggers.MeetCozmoFirstEnrollmentSayName, | |
| "MeetCozmoGetIn" : cozmo.anim.Triggers.MeetCozmoGetIn, | |
| "MeetCozmoLookFaceGetIn" : cozmo.anim.Triggers.MeetCozmoLookFaceGetIn, | |
| "MeetCozmoLookFaceGetOut" : cozmo.anim.Triggers.MeetCozmoLookFaceGetOut, | |
| "MeetCozmoLookFaceInterrupt" : cozmo.anim.Triggers.MeetCozmoLookFaceInterrupt, | |
| "MeetCozmoReEnrollmentSayName" : cozmo.anim.Triggers.MeetCozmoReEnrollmentSayName, | |
| "MeetCozmoRenameFaceSayName" : cozmo.anim.Triggers.MeetCozmoRenameFaceSayName, | |
| "MeetCozmoScanningIdle" : cozmo.anim.Triggers.MeetCozmoScanningIdle, | |
| "MemoryMatchCozmoGetOut" : cozmo.anim.Triggers.MemoryMatchCozmoGetOut, | |
| "MemoryMatchCozmoLoseHand" : cozmo.anim.Triggers.MemoryMatchCozmoLoseHand, | |
| "MemoryMatchCozmoWinGame" : cozmo.anim.Triggers.MemoryMatchCozmoWinGame, | |
| "MemoryMatchCozmoWinHand" : cozmo.anim.Triggers.MemoryMatchCozmoWinHand, | |
| "MemoryMatchPlayerLoseHand" : cozmo.anim.Triggers.MemoryMatchPlayerLoseHand, | |
| "MemoryMatchPlayerLoseHandSolo" : cozmo.anim.Triggers.MemoryMatchPlayerLoseHandSolo, | |
| "MemoryMatchPlayerWinGame" : cozmo.anim.Triggers.MemoryMatchPlayerWinGame, | |
| "MemoryMatchPlayerWinHand" : cozmo.anim.Triggers.MemoryMatchPlayerWinHand, | |
| "MemoryMatchPlayerWinHandLong" : cozmo.anim.Triggers.MemoryMatchPlayerWinHandLong, | |
| "MemoryMatchPlayerWinHandSolo" : cozmo.anim.Triggers.MemoryMatchPlayerWinHandSolo, | |
| "MemoryMatchPointCenter" : cozmo.anim.Triggers.MemoryMatchPointCenter, | |
| "MemoryMatchPointCenterFast" : cozmo.anim.Triggers.MemoryMatchPointCenterFast, | |
| "MemoryMatchPointLeftBig" : cozmo.anim.Triggers.MemoryMatchPointLeftBig, | |
| "MemoryMatchPointLeftBigFast" : cozmo.anim.Triggers.MemoryMatchPointLeftBigFast, | |
| "MemoryMatchPointLeftSmall" : cozmo.anim.Triggers.MemoryMatchPointLeftSmall, | |
| "MemoryMatchPointLeftSmallFast" : cozmo.anim.Triggers.MemoryMatchPointLeftSmallFast, | |
| "MemoryMatchPointRightBig" : cozmo.anim.Triggers.MemoryMatchPointRightBig, | |
| "MemoryMatchPointRightBigFast" : cozmo.anim.Triggers.MemoryMatchPointRightBigFast, | |
| "MemoryMatchPointRightSmall" : cozmo.anim.Triggers.MemoryMatchPointRightSmall, | |
| "MemoryMatchPointRightSmallFast" : cozmo.anim.Triggers.MemoryMatchPointRightSmallFast, | |
| "MemoryMatchReactToPattern" : cozmo.anim.Triggers.MemoryMatchReactToPattern, | |
| "MemoryMatchReactToPatternSolo" : cozmo.anim.Triggers.MemoryMatchReactToPatternSolo, | |
| "MemoryMatchSoloGameOver" : cozmo.anim.Triggers.MemoryMatchSoloGameOver, | |
| "NamedFaceInitialGreeting" : cozmo.anim.Triggers.NamedFaceInitialGreeting, | |
| "NeutralFace" : cozmo.anim.Triggers.NeutralFace, | |
| "NothingToDoBoredEvent" : cozmo.anim.Triggers.NothingToDoBoredEvent, | |
| "NothingToDoBoredIdle" : cozmo.anim.Triggers.NothingToDoBoredIdle, | |
| "NothingToDoBoredIntro" : cozmo.anim.Triggers.NothingToDoBoredIntro, | |
| "NothingToDoBoredOutro" : cozmo.anim.Triggers.NothingToDoBoredOutro, | |
| "OnLearnedPlayerName" : cozmo.anim.Triggers.OnLearnedPlayerName, | |
| "OnSawNewNamedFace" : cozmo.anim.Triggers.OnSawNewNamedFace, | |
| "OnSawNewUnnamedFace" : cozmo.anim.Triggers.OnSawNewUnnamedFace, | |
| "OnSawOldNamedFace" : cozmo.anim.Triggers.OnSawOldNamedFace, | |
| "OnSawOldUnnamedFace" : cozmo.anim.Triggers.OnSawOldUnnamedFace, | |
| "OnSpeedtapCozmoConfirm" : cozmo.anim.Triggers.OnSpeedtapCozmoConfirm, | |
| "OnSpeedtapFakeout" : cozmo.anim.Triggers.OnSpeedtapFakeout, | |
| "OnSpeedtapGameCozmoWinHighIntensity" : cozmo.anim.Triggers.OnSpeedtapGameCozmoWinHighIntensity, | |
| "OnSpeedtapGameCozmoWinLowIntensity" : cozmo.anim.Triggers.OnSpeedtapGameCozmoWinLowIntensity, | |
| "OnSpeedtapGamePlayerWinHighIntensity" : cozmo.anim.Triggers.OnSpeedtapGamePlayerWinHighIntensity, | |
| "OnSpeedtapGamePlayerWinLowIntensity" : cozmo.anim.Triggers.OnSpeedtapGamePlayerWinLowIntensity, | |
| "OnSpeedtapGetOut" : cozmo.anim.Triggers.OnSpeedtapGetOut, | |
| "OnSpeedtapHandCozmoWin" : cozmo.anim.Triggers.OnSpeedtapHandCozmoWin, | |
| "OnSpeedtapHandPlayerWin" : cozmo.anim.Triggers.OnSpeedtapHandPlayerWin, | |
| "OnSpeedtapIdle" : cozmo.anim.Triggers.OnSpeedtapIdle, | |
| "OnSpeedtapRoundCozmoWinHighIntensity" : cozmo.anim.Triggers.OnSpeedtapRoundCozmoWinHighIntensity, | |
| "OnSpeedtapRoundCozmoWinLowIntensity" : cozmo.anim.Triggers.OnSpeedtapRoundCozmoWinLowIntensity, | |
| "OnSpeedtapRoundPlayerWinHighIntensity" : cozmo.anim.Triggers.OnSpeedtapRoundPlayerWinHighIntensity, | |
| "OnSpeedtapRoundPlayerWinLowIntensity" : cozmo.anim.Triggers.OnSpeedtapRoundPlayerWinLowIntensity, | |
| "OnSpeedtapTap" : cozmo.anim.Triggers.OnSpeedtapTap, | |
| "OnWaitForCubesMinigameSetup" : cozmo.anim.Triggers.OnWaitForCubesMinigameSetup, | |
| "OnWiggle" : cozmo.anim.Triggers.OnWiggle, | |
| "OnboardingBirth" : cozmo.anim.Triggers.OnboardingBirth, | |
| "OnboardingCubeDockFail" : cozmo.anim.Triggers.OnboardingCubeDockFail, | |
| "OnboardingDiscoverCube" : cozmo.anim.Triggers.OnboardingDiscoverCube, | |
| "OnboardingDriveEnd" : cozmo.anim.Triggers.OnboardingDriveEnd, | |
| "OnboardingDriveLoop" : cozmo.anim.Triggers.OnboardingDriveLoop, | |
| "OnboardingDriveStart" : cozmo.anim.Triggers.OnboardingDriveStart, | |
| "OnboardingEyesOn" : cozmo.anim.Triggers.OnboardingEyesOn, | |
| "OnboardingGetOut" : cozmo.anim.Triggers.OnboardingGetOut, | |
| "OnboardingHelloPlayer" : cozmo.anim.Triggers.OnboardingHelloPlayer, | |
| "OnboardingHelloWorld" : cozmo.anim.Triggers.OnboardingHelloWorld, | |
| "OnboardingIdle" : cozmo.anim.Triggers.OnboardingIdle, | |
| "OnboardingInteractWithCube" : cozmo.anim.Triggers.OnboardingInteractWithCube, | |
| "OnboardingPreBirth" : cozmo.anim.Triggers.OnboardingPreBirth, | |
| "OnboardingReactToCube" : cozmo.anim.Triggers.OnboardingReactToCube, | |
| "OnboardingReactToCubePutDown" : cozmo.anim.Triggers.OnboardingReactToCubePutDown, | |
| "OnboardingReactToFace" : cozmo.anim.Triggers.OnboardingReactToFace, | |
| "OnboardingSoundOnlyLiftEffortPickup" : cozmo.anim.Triggers.OnboardingSoundOnlyLiftEffortPickup, | |
| "OnboardingSoundOnlyLiftEffortPlaceLow" : cozmo.anim.Triggers.OnboardingSoundOnlyLiftEffortPlaceLow, | |
| "PatternGuessNewIdea" : cozmo.anim.Triggers.PatternGuessNewIdea, | |
| "PatternGuessThinking" : cozmo.anim.Triggers.PatternGuessThinking, | |
| "PetDetectionCat" : cozmo.anim.Triggers.PetDetectionCat, | |
| "PetDetectionDog" : cozmo.anim.Triggers.PetDetectionDog, | |
| "PetDetectionShort" : cozmo.anim.Triggers.PetDetectionShort, | |
| "PetDetectionShort_Cat" : cozmo.anim.Triggers.PetDetectionShort_Cat, | |
| "PetDetectionShort_Dog" : cozmo.anim.Triggers.PetDetectionShort_Dog, | |
| "PetDetectionSneeze" : cozmo.anim.Triggers.PetDetectionSneeze, | |
| "PlacedOnCharger" : cozmo.anim.Triggers.PlacedOnCharger, | |
| "PopAWheelieInitial" : cozmo.anim.Triggers.PopAWheelieInitial, | |
| "PopAWheeliePreActionNamedFace" : cozmo.anim.Triggers.PopAWheeliePreActionNamedFace, | |
| "PopAWheeliePreActionUnnamedFace" : cozmo.anim.Triggers.PopAWheeliePreActionUnnamedFace, | |
| "PopAWheelieRealign" : cozmo.anim.Triggers.PopAWheelieRealign, | |
| "PopAWheelieRetry" : cozmo.anim.Triggers.PopAWheelieRetry, | |
| "PounceDriveEnd" : cozmo.anim.Triggers.PounceDriveEnd, | |
| "PounceDriveLoop" : cozmo.anim.Triggers.PounceDriveLoop, | |
| "PounceDriveStart" : cozmo.anim.Triggers.PounceDriveStart, | |
| "PounceFace" : cozmo.anim.Triggers.PounceFace, | |
| "PounceFail" : cozmo.anim.Triggers.PounceFail, | |
| "PounceGetOut" : cozmo.anim.Triggers.PounceGetOut, | |
| "PounceInitial" : cozmo.anim.Triggers.PounceInitial, | |
| "PouncePounce" : cozmo.anim.Triggers.PouncePounce, | |
| "PounceSuccess" : cozmo.anim.Triggers.PounceSuccess, | |
| "ProceduralLive" : cozmo.anim.Triggers.ProceduralLive, | |
| "PutDownBlockKeepAlive" : cozmo.anim.Triggers.PutDownBlockKeepAlive, | |
| "PutDownBlockPutDown" : cozmo.anim.Triggers.PutDownBlockPutDown, | |
| "ReactToBlockPickupSuccess" : cozmo.anim.Triggers.ReactToBlockPickupSuccess, | |
| "ReactToBlockRetryPickup" : cozmo.anim.Triggers.ReactToBlockRetryPickup, | |
| "ReactToCliff" : cozmo.anim.Triggers.ReactToCliff, | |
| "ReactToCliffDetectorStop" : cozmo.anim.Triggers.ReactToCliffDetectorStop, | |
| "ReactToMotorCalibration" : cozmo.anim.Triggers.ReactToMotorCalibration, | |
| "ReactToNewBlockAsk" : cozmo.anim.Triggers.ReactToNewBlockAsk, | |
| "ReactToNewBlockBig" : cozmo.anim.Triggers.ReactToNewBlockBig, | |
| "ReactToNewBlockSmall" : cozmo.anim.Triggers.ReactToNewBlockSmall, | |
| "ReactToOnLeftSide" : cozmo.anim.Triggers.ReactToOnLeftSide, | |
| "ReactToOnRightSide" : cozmo.anim.Triggers.ReactToOnRightSide, | |
| "ReactToPickup" : cozmo.anim.Triggers.ReactToPickup, | |
| "ReactToPokeReaction" : cozmo.anim.Triggers.ReactToPokeReaction, | |
| "ReactToPokeStartled" : cozmo.anim.Triggers.ReactToPokeStartled, | |
| "ReactToUnexpectedMovement" : cozmo.anim.Triggers.ReactToUnexpectedMovement, | |
| "RequestGameDrivingFail" : cozmo.anim.Triggers.RequestGameDrivingFail, | |
| "RequestGameKeepAwayAccept0" : cozmo.anim.Triggers.RequestGameKeepAwayAccept0, | |
| "RequestGameKeepAwayAccept1" : cozmo.anim.Triggers.RequestGameKeepAwayAccept1, | |
| "RequestGameKeepAwayDeny0" : cozmo.anim.Triggers.RequestGameKeepAwayDeny0, | |
| "RequestGameKeepAwayDeny1" : cozmo.anim.Triggers.RequestGameKeepAwayDeny1, | |
| "RequestGameKeepAwayIdle0" : cozmo.anim.Triggers.RequestGameKeepAwayIdle0, | |
| "RequestGameKeepAwayIdle1" : cozmo.anim.Triggers.RequestGameKeepAwayIdle1, | |
| "RequestGameKeepAwayInitial0" : cozmo.anim.Triggers.RequestGameKeepAwayInitial0, | |
| "RequestGameKeepAwayInitial1" : cozmo.anim.Triggers.RequestGameKeepAwayInitial1, | |
| "RequestGameKeepAwayPreDrive0" : cozmo.anim.Triggers.RequestGameKeepAwayPreDrive0, | |
| "RequestGameKeepAwayPreDrive1" : cozmo.anim.Triggers.RequestGameKeepAwayPreDrive1, | |
| "RequestGameKeepAwayRequest0" : cozmo.anim.Triggers.RequestGameKeepAwayRequest0, | |
| "RequestGameKeepAwayRequest1" : cozmo.anim.Triggers.RequestGameKeepAwayRequest1, | |
| "RequestGameMemoryMatchAccept0" : cozmo.anim.Triggers.RequestGameMemoryMatchAccept0, | |
| "RequestGameMemoryMatchAccept1" : cozmo.anim.Triggers.RequestGameMemoryMatchAccept1, | |
| "RequestGameMemoryMatchDeny0" : cozmo.anim.Triggers.RequestGameMemoryMatchDeny0, | |
| "RequestGameMemoryMatchDeny1" : cozmo.anim.Triggers.RequestGameMemoryMatchDeny1, | |
| "RequestGameMemoryMatchIdle0" : cozmo.anim.Triggers.RequestGameMemoryMatchIdle0, | |
| "RequestGameMemoryMatchIdle1" : cozmo.anim.Triggers.RequestGameMemoryMatchIdle1, | |
| "RequestGameMemoryMatchInitial0" : cozmo.anim.Triggers.RequestGameMemoryMatchInitial0, | |
| "RequestGameMemoryMatchInitial1" : cozmo.anim.Triggers.RequestGameMemoryMatchInitial1, | |
| "RequestGameMemoryMatchPreDrive0" : cozmo.anim.Triggers.RequestGameMemoryMatchPreDrive0, | |
| "RequestGameMemoryMatchPreDrive1" : cozmo.anim.Triggers.RequestGameMemoryMatchPreDrive1, | |
| "RequestGameMemoryMatchRequest0" : cozmo.anim.Triggers.RequestGameMemoryMatchRequest0, | |
| "RequestGameMemoryMatchRequest1" : cozmo.anim.Triggers.RequestGameMemoryMatchRequest1, | |
| "RequestGamePickupFail" : cozmo.anim.Triggers.RequestGamePickupFail, | |
| "RequestGameSpeedTapAccept0" : cozmo.anim.Triggers.RequestGameSpeedTapAccept0, | |
| "RequestGameSpeedTapAccept1" : cozmo.anim.Triggers.RequestGameSpeedTapAccept1, | |
| "RequestGameSpeedTapDeny0" : cozmo.anim.Triggers.RequestGameSpeedTapDeny0, | |
| "RequestGameSpeedTapDeny1" : cozmo.anim.Triggers.RequestGameSpeedTapDeny1, | |
| "RequestGameSpeedTapIdle0" : cozmo.anim.Triggers.RequestGameSpeedTapIdle0, | |
| "RequestGameSpeedTapIdle1" : cozmo.anim.Triggers.RequestGameSpeedTapIdle1, | |
| "RequestGameSpeedTapInitial0" : cozmo.anim.Triggers.RequestGameSpeedTapInitial0, | |
| "RequestGameSpeedTapInitial1" : cozmo.anim.Triggers.RequestGameSpeedTapInitial1, | |
| "RequestGameSpeedTapPreDrive0" : cozmo.anim.Triggers.RequestGameSpeedTapPreDrive0, | |
| "RequestGameSpeedTapPreDrive1" : cozmo.anim.Triggers.RequestGameSpeedTapPreDrive1, | |
| "RequestGameSpeedTapRequest0" : cozmo.anim.Triggers.RequestGameSpeedTapRequest0, | |
| "RequestGameSpeedTapRequest1" : cozmo.anim.Triggers.RequestGameSpeedTapRequest1, | |
| "RollBlockInitial" : cozmo.anim.Triggers.RollBlockInitial, | |
| "RollBlockPreActionNamedFace" : cozmo.anim.Triggers.RollBlockPreActionNamedFace, | |
| "RollBlockPreActionUnnamedFace" : cozmo.anim.Triggers.RollBlockPreActionUnnamedFace, | |
| "RollBlockPutDown" : cozmo.anim.Triggers.RollBlockPutDown, | |
| "RollBlockRealign" : cozmo.anim.Triggers.RollBlockRealign, | |
| "RollBlockRetry" : cozmo.anim.Triggers.RollBlockRetry, | |
| "RollBlockSuccess" : cozmo.anim.Triggers.RollBlockSuccess, | |
| "SdkTextToSpeech" : cozmo.anim.Triggers.SdkTextToSpeech, | |
| "Shiver" : cozmo.anim.Triggers.Shiver, | |
| "Shocked" : cozmo.anim.Triggers.Shocked, | |
| "Sleeping" : cozmo.anim.Triggers.Sleeping, | |
| "SoftSparkUpgradeLift" : cozmo.anim.Triggers.SoftSparkUpgradeLift, | |
| "SoftSparkUpgradeTracks" : cozmo.anim.Triggers.SoftSparkUpgradeTracks, | |
| "SoundOnlyLiftEffortPickup" : cozmo.anim.Triggers.SoundOnlyLiftEffortPickup, | |
| "SoundOnlyLiftEffortPlaceHigh" : cozmo.anim.Triggers.SoundOnlyLiftEffortPlaceHigh, | |
| "SoundOnlyLiftEffortPlaceLow" : cozmo.anim.Triggers.SoundOnlyLiftEffortPlaceLow, | |
| "SoundOnlyLiftEffortPlaceRoll" : cozmo.anim.Triggers.SoundOnlyLiftEffortPlaceRoll, | |
| "SoundOnlyTurnSmall" : cozmo.anim.Triggers.SoundOnlyTurnSmall, | |
| "SparkDrivingLoop" : cozmo.anim.Triggers.SparkDrivingLoop, | |
| "SparkDrivingStart" : cozmo.anim.Triggers.SparkDrivingStart, | |
| "SparkDrivingStop" : cozmo.anim.Triggers.SparkDrivingStop, | |
| "SparkFailure" : cozmo.anim.Triggers.SparkFailure, | |
| "SparkGetIn" : cozmo.anim.Triggers.SparkGetIn, | |
| "SparkGetOut" : cozmo.anim.Triggers.SparkGetOut, | |
| "SparkIdle" : cozmo.anim.Triggers.SparkIdle, | |
| "SparkPickupFinalCubeReaction" : cozmo.anim.Triggers.SparkPickupFinalCubeReaction, | |
| "SparkPickupInitialCubeReaction" : cozmo.anim.Triggers.SparkPickupInitialCubeReaction, | |
| "SparkSuccess" : cozmo.anim.Triggers.SparkSuccess, | |
| "SpeedTapDrivingEnd" : cozmo.anim.Triggers.SpeedTapDrivingEnd, | |
| "SpeedTapDrivingLoop" : cozmo.anim.Triggers.SpeedTapDrivingLoop, | |
| "SpeedTapDrivingStart" : cozmo.anim.Triggers.SpeedTapDrivingStart, | |
| "StackBlocksPreActionNamedFace" : cozmo.anim.Triggers.StackBlocksPreActionNamedFace, | |
| "StackBlocksPreActionUnnamedFace" : cozmo.anim.Triggers.StackBlocksPreActionUnnamedFace, | |
| "StackBlocksRetry" : cozmo.anim.Triggers.StackBlocksRetry, | |
| "StackBlocksSuccess" : cozmo.anim.Triggers.StackBlocksSuccess, | |
| "StartSleeping" : cozmo.anim.Triggers.StartSleeping, | |
| "SuccessfulWheelie" : cozmo.anim.Triggers.SuccessfulWheelie, | |
| "Surprise" : cozmo.anim.Triggers.Surprise, | |
| "TurtleRoll" : cozmo.anim.Triggers.TurtleRoll, | |
| "UnitTestAnim" : cozmo.anim.Triggers.UnitTestAnim, | |
| "WorkoutPickupRealign" : cozmo.anim.Triggers.WorkoutPickupRealign, | |
| "WorkoutPickupRetry" : cozmo.anim.Triggers.WorkoutPickupRetry, | |
| "WorkoutPostLift_highEnergy" : cozmo.anim.Triggers.WorkoutPostLift_highEnergy, | |
| "WorkoutPostLift_lowEnergy" : cozmo.anim.Triggers.WorkoutPostLift_lowEnergy, | |
| "WorkoutPostLift_mediumEnergy" : cozmo.anim.Triggers.WorkoutPostLift_mediumEnergy, | |
| "WorkoutPreLift_highEnergy" : cozmo.anim.Triggers.WorkoutPreLift_highEnergy, | |
| "WorkoutPreLift_lowEnergy" : cozmo.anim.Triggers.WorkoutPreLift_lowEnergy, | |
| "WorkoutPreLift_mediumEnergy" : cozmo.anim.Triggers.WorkoutPreLift_mediumEnergy, | |
| "WorkoutPutDown_highEnergy" : cozmo.anim.Triggers.WorkoutPutDown_highEnergy, | |
| "WorkoutPutDown_lowEnergy" : cozmo.anim.Triggers.WorkoutPutDown_lowEnergy, | |
| "WorkoutPutDown_lowEnergy_simple" : cozmo.anim.Triggers.WorkoutPutDown_lowEnergy_simple, | |
| "WorkoutPutDown_mediumEnergy" : cozmo.anim.Triggers.WorkoutPutDown_mediumEnergy, | |
| "WorkoutStrongLift_highEnergy" : cozmo.anim.Triggers.WorkoutStrongLift_highEnergy, | |
| "WorkoutStrongLift_lowEnergy" : cozmo.anim.Triggers.WorkoutStrongLift_lowEnergy, | |
| "WorkoutStrongLift_mediumEnergy" : cozmo.anim.Triggers.WorkoutStrongLift_mediumEnergy, | |
| "WorkoutTransition_highEnergy" : cozmo.anim.Triggers.WorkoutTransition_highEnergy, | |
| "WorkoutTransition_lowEnergy" : cozmo.anim.Triggers.WorkoutTransition_lowEnergy, | |
| "WorkoutTransition_mediumEnergy" : cozmo.anim.Triggers.WorkoutTransition_mediumEnergy, | |
| "WorkoutWeakLift_highEnergy" : cozmo.anim.Triggers.WorkoutWeakLift_highEnergy, | |
| "WorkoutWeakLift_lowEnergy" : cozmo.anim.Triggers.WorkoutWeakLift_lowEnergy, | |
| "WorkoutWeakLift_mediumEnergy" : cozmo.anim.Triggers.WorkoutWeakLift_mediumEnergy} | |
| def lookupTrigger(name): | |
| '''Returns list of case-insensitive matches to trigger name''' | |
| results = [] | |
| for key in triggerActions: | |
| if name.lower() in key.lower(): | |
| results.append(key) | |
| return results | |
| def getTrigger(name): | |
| '''Returns trigger with exact name match or idle''' | |
| return triggerActions.get(name, cozmo.anim.Triggers.OnboardingIdle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Erica,
This is really important work! Thank you so much for sharing! I have a Cozmo and I am trying to get my students (High School) to program it. Your thought on abstraction is spot on! I would love to talk to you more about it! Here is my email so maybe we can chat.
[email protected]