import sys, pygame, martypy # Initialise PyGame pygame.init() # Initialise Marty at his IP address myMarty = martypy.Marty( 'socket://192.168.86.41') # Change IP address to your one # Screen to display swing on screenSize = screenWidth, screenHeight = 800, 600 screen = pygame.display.set_mode(screenSize) # Size of shape to use to represent Marty martySizeX = martySizeY = screenHeight // 2.5 # Colours black = (0, 0, 0) martyColour = (37, 167, 253) # Do this forever - until the user breaks out while True: # Get the information about Marty's swing xAcc = myMarty.get_accelerometer('x') # Clear the screen then draw a shape to represent Marty screen.fill(black) martyX = screenWidth / 2 + xAcc * screenWidth pygame.draw.rect( screen, martyColour,
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. mymarty = martypy.Marty('socket://10.20.0.131') # Address of the Marty WiFi. mymarty.fall_protection(False) mymarty.motor_protection(False) mymarty.buzz_prevention(True) mymarty.hello() def Execute(intent, params, query, cmd): print('intent: %s, params: %s, query: %s' % (intent, params, query)) if intent == 'Motion': motion = params.get('motion') or 'walk' if motion == 'run': return "You know, I don't like running." elif motion == 'walk': steps = int(params.get('number-integer') or '2') if steps < 1:
# http://docs.robotical.io/python/martypy/ import martypy mymarty = martypy.Marty('socket://192.168.2.30') # Change IP accordingly mymarty.hello() # Move to zero positions and wink print("Start walking") count = 0 while count < 10: print("The count is: ", count) mymarty.arms(127, -127, 1000) mymarty.walk(10) mymarty.circle_dance('left', 3000) mymarty.walk(21, 'auto', 127, 40, 1000) mymarty.eyes(90) count = count + 1 print("Done")