Ejemplo n.º 1
0
class WheelManagerTest(TestCase):
    AN_ANGLE = 5
    ZERO_ANGLE = 0

    A_POINT = (5,5)
    ORIGIN_POINT = (0,0)


    def setUp(self):
        self.wheelMotorMock = MagicMock()
        self.serialPortCommunicator = MagicMock()
        self.wheelManager = WheelManager(self.serialPortCommunicator)


    def test_whenMoveInfiniteIsCalledOnAPointThenVitesseIsSet(self):
        self.wheelManager.moveForever(2,2)

        self.assertTrue(self.serialPortCommunicator.driveMoteurLine.call_count != 0)



    def test_whenMoveToIsCalledOnAPointThenVitesseIsSet(self):
        self.wheelManager.moveTo(self.A_POINT)

        self.assertTrue(self.serialPortCommunicator.driveMoteurLine.call_count != 0)


    def test_whenRotationIsCalledThenSetVitesse(self):
        self.wheelManager.rotate(self.AN_ANGLE)

        self.assertTrue(self.serialPortCommunicator.driveMoteurRotation.call_count == 1)


    def test_whenMoveToIsCalledOnTheCurrentPositionThenVitesseNotSet(self):
        self.wheelManager.moveTo(self.ORIGIN_POINT)

        self.assertTrue(self.serialPortCommunicator.driveMoteurLine.call_count == 0)


    def test_setOrientationThenGoodRotation(self):
        self.wheelManager.setOrientation(90,91)
        self.assertTrue(self.serialPortCommunicator.driveMoteurRotation.call_count == 1)
Ejemplo n.º 2
0
        self.goBackwardToGrabTreasure()
        time.sleep(0.1)
        self.ascendArm()
        time.sleep(3)
        self.deactivateMagnet()
        time.sleep(0.1)
        return True


if __name__ == "__main__":
    # __init__(self, wheelManager, robotVision, maestro, spc):
    # def __init__(self, wheelManager, cameraTower, videoCapture):

    m = Controller()
    spc = SerialPortCommunicator()
    wm = WheelManager(spc)

    rv = RobotVision(wm, CameraTower(m), cv2.VideoCapture(0))
    pa = PositionAdjuster(wm, rv, m, spc)

    while True:
        print "Voltage : ", pa.readCondensatorVoltage()
        time.sleep(5)
    # a = raw_input("Press to mode recharge")
    # pa.rechargeMagnet()
    # a = raw_input("Press to mode stop magnet")
    # pa.deactivateMagnet()
    # a = raw_input("Press to start magnet")
    # pa.activateMagnet()
    # a = raw_input("Press to stop magnet")
    # pa.deactivateMagnet()
Ejemplo n.º 3
0
 def setUp(self):
     self.wheelMotorMock = MagicMock()
     self.serialPortCommunicator = MagicMock()
     self.wheelManager = WheelManager(self.serialPortCommunicator)
Ejemplo n.º 4
0
import fcntl
from threading import Thread
from socketIO_client import SocketIO
import time
from Client.Robot.Movement.WheelManager import WheelManager
from Logic.BotDispatcher import BotDispatcher
import subprocess
c = os.path.dirname(__file__)
configPath = os.path.join(c, "..", "..", "Shared", "config.json")

subprocess.call(['./cameraSettings.sh'])
with open(configPath) as json_data_file:
    config = json.load(json_data_file)
socketIO = SocketIO(config['url'], int(config['port']))
spc = SerialPortCommunicator()
botDispatcher = BotDispatcher(WheelManager(spc), Controller(), spc)



def goToNextPosition(data):
    print("heading toward next coordinates")
    botDispatcher.lastPositionGoneTo = (data['positionTOx'], data['positionTOy'])
    botDispatcher.followPath(data)


def startRound(json):
    print("start round")
    botDispatcher.lastPositionGoneTo = (json['positionX'], json['positionY'])
    socketIO.emit("needNewCoordinates")

def alignToTreasure(json):