예제 #1
0
class WSHandler(tornado.websocket.WebSocketHandler):
    def open(self):

        print('connection opened...')
        self.m = TwoMotorDriveSteer(13,15,7,11)
        self.rangeFinder = RangeFinder(16,18)

    def on_message(self, message):      # receives the data from the webpage and is stored in the variable message

        print(message)
        if message == "get":
            self.rangeFinder.sendData(message)
            time.sleep(0.1)
            x = self.rangeFinder.getData()
            print(x)
            
        else:
            self.m.sendData(message)
       
    def on_close(self):
        print('connection closed...')
        self.m.sendData("stop")
        self.m.sendData("coast")
        self.m.sendData("center")
예제 #2
0
파일: hack_demo.py 프로젝트: harmsm/rpyBot
from robotDevices import TwoMotorDriveSteer
import time

def cleanUp(m):
    """
    """

    m.sendData("stop")
    m.sendData("coast")
    m.sendData("center")

try:

    m = TwoMotorDriveSteer(13,15,7,11)

    m.sendData("coast")
    m.sendData("center")

    m.sendData("forward")
    time.sleep(2)
    m.sendData("reverse")
    time.sleep(2)
    m.sendData("stop")

    for i in range(3):
        m.sendData("right"); time.sleep(0.3)
        m.sendData("left"); time.sleep(0.3)

    for i in range(2):
        m.sendData("right")
        m.sendData("forward")