Example #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")
Example #2
0
    def open(self):

        print('connection opened...')
        self.m = TwoMotorDriveSteer(13,15,7,11)
        self.rangeFinder = RangeFinder(16,18)
Example #3
0
#!/usr/bin/env python

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):