Exemple #1
0
 def main():
     magnet = mpu92_test.get_magnet();
     mag = mag()
     mag.calcenter(42.0,-5.0,38.0,-10.0)
     mag.mag_x = magnet[0] + self.center_x
     mag.mag_y = magnet[1] + self.center_y
     print(instance.mag_x)
     print(instance.mag_y)
     while True:
         magnet = mpu92_test.get_magnet();
         self.mag_x = magnet[0] + self.center_x
         self.mag_y = magnet[1] + self.center_y
         print(self.mag_x)
         print(self.mag_y)
         time.sleep(0.1)
Exemple #2
0
def calc():
    maxX = -100
    maxY = -100
    minX = 100
    minY = 100
    t_end = time.time() + 10
    setspeed = 100
    motor = Motor.Motor(18, 25, 24, 13, 27, 17)
    time.sleep(5)
    while time.time() < t_end:
        magnet = mpu92_test.get_magnet()
        if (maxX < magnet[0]):
            maxX = magnet[0]
        if (minX > magnet[0]):
            minX = magnet[0]
        if (maxY < magnet[1]):
            maxY = magnet[1]
        if (minY > magnet[1]):
            minY = magnet[1]
        #print("magnet[%+4.2f, %+4.2f, %+4.2f]" % (magnet[0], magnet[1], magnet[2]), end="\t")
        print("maxx", maxX)
        print("minx", minX)
        print()
        print("maxy", maxY)
        print("miny", minY)
        print()
        motor.set_speed(-100, 100)
        time.sleep(1)
Exemple #3
0
def main():
    maxX = -10000
    maxY = -10000
    minX = 10000
    minY = 10000
    t_end = time.time() + 30
    setspeed = 100
    motor = Motor.Motor(18, 25, 24,13, 27, 17)
    #time.sleep(5)
    while time.time() < t_end:     
        magnet = mpu92_test.get_magnet()
        print(magnet)
        if(maxX < magnet[0]):
            maxX = magnet[0]
        if(minX > magnet[0]):
            minX = magnet[0]
        if(maxY < magnet[1]):
            maxY = magnet[1]
        if(minY > magnet[1]):
            minY = magnet[1]
#         print("maxx",maxX)
#         print("minx",minX)
#         print()
#         print("maxy",maxY)
#         print("miny",minY)
#         print()
        motor.set_speed(setspeed,setspeed) 
        time.sleep(1) 
Exemple #4
0
def main():

    maxX = -100
    maxY = -100
    minX = 100
    minY = 100

    while True:
        magnet = mpu92_test.get_magnet()

        if (maxX < magnet[0]):
            maxX = magnet[0]
        if (minX > magnet[0]):
            minX = magnet[0]
        if (maxY < magnet[1]):
            maxY = magnet[1]
        if (minY > magnet[1]):
            minY = magnet[1]

        #print("magnet[%+4.2f, %+4.2f, %+4.2f]" % (magnet[0], magnet[1], magnet[2]), end="\t")

        print("maxx", maxX)
        print("minx", minX)
        print()
        print("maxy", maxY)
        print("miny", minY)
        print()

        time.sleep(1)
Exemple #5
0
import mpu92_test
import time

center_x = (42.0 + -5.0) / 2.0
center_y = (38.0 + -10.0) / 2.0
magnet = mpu92_test.get_magnet()
print(magnet[0] + center_x)
print(magnet[1] + center_y)
while True:
    magnet = mpu92_test.get_magnet()
    print(magnet[0] + center_x)
    print()
    print(magnet[1] + center_y)
    time.sleep(1)