def hello_monkey(): """Respond to incoming calls with a simple text message.""" roomba = Create2() roomba.start() roomba.safe() response = "" msg = request.values.get('Body', None) arrayMsg = msg.split() secondArg = float(arrayMsg[1]) print(msg) print(arrayMsg) if "forward" in msg: roomba.straight(secondArg) elif "backward" in msg: roomba.clockwise(180) roomba.straight(secondArg) elif "turn-" in msg: print("Success Turn ", secondArg) roomba.counterclockwise(secondArg) elif "turn" in msg: roomba.clockwise(secondArg) else: roomba.drive(0, 0) time.sleep(0.5) roomba.drive(0, 0) resp = twilio.twiml.Response() resp.message(msg) return str(resp)
from roomba.create2 import Create2 import time r = Create2() r.start() r.safe() time.sleep(2) user_input = raw_input("Enter a command:") while(user_input != "quit"): if(user_input == "forward"): r.straight(50) time.sleep(0.1) r.drive(0,0) elif(user_input == "left"): r.counterclockwise(50) time.sleep(0.1) r.drive(0,0) elif(user_input == "back"): r.straight(-50) time.sleep(0.1) r.drive(0,0) elif(user_input == "right"): r.clockwise(50) time.sleep(0.1) r.drive(0,0) else: print("Please enter, \"left\", \"right\", \"forward\", or \"backward\"") user_input = raw_input("Enter a command:") r.drive(0,0)
import requests import time from roomba.create2 import Create2 roomba = Create2() roomba.start() roomba.safe() URL = 'https://twilio-plays-roomba.herokuapp.com/next' def run_command(message): command = message.lower() print("Running command: {}".format(message)) if command == 'forward': roomba.straight(50) elif command == 'backward': roomba.straight(-1 * 50) elif command == 'turn clockwise': roomba.clockwise(50) elif command == 'turn counterclockwise': roomba.counterclockwise(50) else: print("Not a valid command: {}".format(message)) time.sleep(0.5) roomba.drive(0, 0) def validate(message): command = command.lower() if command not in [