Exemple #1
0
    # TODO use the dynamical model equation to get the motor voltage
    motorPowerM1 = limitThrust(thrust + pitch + yaw)
    motorPowerM2 = limitThrust(thrust - roll - yaw)
    motorPowerM3 = limitThrust(thrust - pitch + yaw)
    motorPowerM4 = limitThrust(thrust + roll - yaw)

    # Log the motor powers:
    print "------------------------"
    print "motorPowerM1:" + motorPowerM1
    print "motorPowerM2:" + motorPowerM2
    print "motorPowerM3:" + motorPowerM3
    print "motorPowerM4:" + motorPowerM4
    print "------------------------"

    # Set motor speeds
    motor1.setSpeed(motorPowerM1)
    motor2.setSpeed(motorPowerM2)
    motor3.setSpeed(motorPowerM3)
    motor4.setSpeed(motorPowerM4)

    # Start Motors
    for mot in motors:
        mot.go()

    # Kalman Prediction
    # MyKalman.predict()
    # delay = 4e-3 #delay ms (250 Hz)
    delay = 20e-3  # delay ms (50 Hz)
    time.sleep(delay)

############################
            # m_front_left.setSpeed(int(270))
            # m_front_right.setSpeed(int(270))
            # m_back_right.setSpeed(int(270))
            # m_back_left.setSpeed(int(270))
            print "front_left: {} front_right: {} back_right: {} back_left: {}".format(
                front_left, front_right, back_right, back_left
            )
    else:
        return


# ================================ Main ========================================

socket_in_ahrs = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
socket_in_ahrs.bind(("0.0.0.0", 7000))

# thread = threading.Thread(target=getInput)
# thread.start()

while True:
    try:
        loop()
    except KeyboardInterrupt:
        print "im here"
        m_front_left.setSpeed(int(270))
        m_front_right.setSpeed(int(270))
        m_back_right.setSpeed(int(270))
        m_back_left.setSpeed(int(270))
        sys.exit(0)
GPIO.setup("P8_4", GPIO.OUT)
GPIO.output("P8_4", GPIO.HIGH)

GPIO.setup("P8_11", GPIO.OUT)
GPIO.output("P8_11", GPIO.HIGH)

GPIO.setup("P9_15", GPIO.OUT)
GPIO.output("P9_15", GPIO.HIGH)

GPIO.setup("P9_23", GPIO.OUT)
GPIO.output("P9_23", GPIO.HIGH)
##############################

speed = 0

m1 = Motor(1)
m1.setSpeed(speed)
m1.go()

m2 = Motor(2)
m2.setSpeed(speed * (-1))
m2.go()

m3 = Motor(3)
m3.setSpeed(speed)
m3.go()

m4 = Motor(4)
m4.setSpeed(speed * (-1))
m4.go()
Exemple #4
0
GPIO.setup("P8_4", GPIO.OUT)
GPIO.output("P8_4", GPIO.HIGH)

GPIO.setup("P8_11", GPIO.OUT)
GPIO.output("P8_11", GPIO.HIGH)

GPIO.setup("P9_15", GPIO.OUT)
GPIO.output("P9_15", GPIO.HIGH)

GPIO.setup("P9_23", GPIO.OUT)
GPIO.output("P9_23", GPIO.HIGH)
##############################

speed = 0

m1 = Motor(1)
m1.setSpeed(speed)
m1.go()

m2 = Motor(2)
m2.setSpeed(speed * (-1))
m2.go()

m3 = Motor(3)
m3.setSpeed(speed)
m3.go()

m4 = Motor(4)
m4.setSpeed(speed * (-1))
m4.go()
Exemple #5
0
GPIO.output("P8_4", GPIO.HIGH)

GPIO.setup("P8_11", GPIO.OUT)
GPIO.output("P8_11", GPIO.HIGH)

GPIO.setup("P9_15", GPIO.OUT)
GPIO.output("P9_15", GPIO.HIGH)

GPIO.setup("P9_23", GPIO.OUT)
GPIO.output("P9_23", GPIO.HIGH)
##############################

speed = 0

m1 = Motor(1);
m1.setSpeed(speed);
m1.go()

m2 = Motor(2);
m2.setSpeed(speed*(-1));
m2.go()

m3 = Motor(3);
m3.setSpeed(speed);
m3.go()

m4 = Motor(4);
m4.setSpeed(speed*(-1));
m4.go()

Exemple #6
0
    #TODO use the dynamical model equation to get the motor voltage
    motorPowerM1 = limitThrust(thrust + pitch + yaw)
    motorPowerM2 = limitThrust(thrust - roll - yaw)
    motorPowerM3 = limitThrust(thrust - pitch + yaw)
    motorPowerM4 = limitThrust(thrust + roll - yaw)

    #Log the motor powers:
    print "------------------------"
    print "motorPowerM1:" + motorPowerM1
    print "motorPowerM2:" + motorPowerM2
    print "motorPowerM3:" + motorPowerM3
    print "motorPowerM4:" + motorPowerM4
    print "------------------------"

    #Set motor speeds
    motor1.setSpeed(motorPowerM1)
    motor2.setSpeed(motorPowerM2)
    motor3.setSpeed(motorPowerM3)
    motor4.setSpeed(motorPowerM4)

    #Start Motors
    for mot in motors:
        mot.go()

    #Kalman Prediction
    #MyKalman.predict()
    #delay = 4e-3 #delay ms (250 Hz)
    delay = 20e-3  #delay ms (50 Hz)
    time.sleep(delay)

############################
Exemple #7
0
from motors import Motor
import getch


# FRONT_RIGHT min 305
# FRONT_LEFT min 308
# BACK_LEFT min  332
# BACK_RIGHT min 322
m1 = Motor(Motor.FRONT_LEFT)
m2 = Motor(Motor.FRONT_RIGHT)
m3 = Motor(Motor.BACK_LEFT)
m4 = Motor(Motor.BACK_RIGHT)
speed = 270
while True:
  c = getch.getch()

  if c == 'w':
    speed = speed + 1
  if c == 's':
    speed = speed - 1

  m1.setSpeed(speed)
  m2.setSpeed(speed)
  m3.setSpeed(speed)
  m4.setSpeed(speed)
#GPIO.output("P8_11", GPIO.HIGH)
#
#GPIO.setup("P9_15", GPIO.OUT)
#GPIO.output("P9_15", GPIO.HIGH)
#
#GPIO.setup("P9_23", GPIO.OUT)
#GPIO.output("P9_23", GPIO.HIGH)
###############################

# initial timer
time.sleep(10)

speed = 10

m1 = Motor(1);
m1.setSpeed(speed);
m1.go()

m2 = Motor(2);
m2.setSpeed(speed);
m2.go()

m3 = Motor(3);
m3.setSpeed(speed);
m3.go()

m4 = Motor(4);
m4.setSpeed(speed));
m4.go()

time.sleep(10)