예제 #1
0
from math import *
from modules.utils import *
from modules.pyMultiwii import MultiWii
import modules.UDPserver as udp

# Main configuration
logging = True
update_rate = 0.01  # 100 hz loop cycle
vehicle_weight = 0.84  # Kg
u0 = 1000  # Zero throttle command
uh = 1360  # Hover throttle command
kt = vehicle_weight * g / (uh - u0)
ky = 500 / pi  # Yaw controller gain

# MRUAV initialization
vehicle = MultiWii("/dev/ttyUSB0")
vehicle.getData(MultiWii.ATTITUDE)

# Position coordinates [x, y, x]
desiredPos = {
    'x': 0.0,
    'y': 0.0,
    'z': 1.0
}  # Set at the beginning (for now...)
currentPos = {'x': 0.0, 'y': 0.0, 'z': 0.0}  # It will be updated using UDP

# Initialize RC commands and pitch/roll to be sent to the MultiWii
rcCMD = [1500, 1500, 1500, 1000]
desiredRoll = 1500
desiredPitch = 1500
desiredThrottle = 1000
from math import *
from modules.utils import *
from modules.pyMultiwii import MultiWii
import modules.UDPserver as udp

# Main configuration
logging = True
update_rate = 0.01 # 100 hz loop cycle
vehicle_weight = 0.84 # Kg
u0 = 1000 # Zero throttle command
uh = 1360 # Hover throttle command
kt = vehicle_weight * g / (uh-u0)
ky = 500 / pi # Yaw controller gain

# MRUAV initialization
vehicle = MultiWii("/dev/ttyUSB0")
vehicle.getData(MultiWii.ATTITUDE)

# Position coordinates [x, y, x] 
desiredPos = {'x':0.0, 'y':0.0, 'z':1.0} # Set at the beginning (for now...)
currentPos = {'x':0.0, 'y':0.0, 'z':0.0} # It will be updated using UDP

# Initialize RC commands and pitch/roll to be sent to the MultiWii 
rcCMD = [1500,1500,1500,1000]
desiredRoll = 1500
desiredPitch = 1500
desiredThrottle = 1000
desiredYaw = 1500

# Controller PID's gains (Gains are considered the same for pitch and roll)
p_gains = {'kp': 2.61, 'ki':0.57, 'kd':3.41, 'iMax':2, 'filter_bandwidth':50} # Position Controller gains
예제 #3
0
uh = 1360  # Hover throttle command
kt = vehicle_weight * g / (uh - u0)
kt_sl = (vehicle_weight + sl_weight) * g / (uh - u0)
ky = 500 / pi  # Yaw controller gain

# Trajectory configuration
trajectory = 'circle'
w = (2 * pi) / 15  # It will take 6 seconds to complete a circle
# For Circle
radius = 0.8  # Circle radius
# Infinity trajectory configuration
a = 1.0
b = 1.2

# MRUAV initialization
vehicle = MultiWii("/dev/ttyUSB0")

# Position coordinates [x, y, x]
desiredPos = {
    'x': 0.0,
    'y': 0.0,
    'z': 1.6
}  # Set at the beginning (for now...)
currentPos = {'x': 0.0, 'y': 0.0, 'z': 0.0}  # It will be updated using UDP
sl_currentPos = {'x': 0.0, 'y': 0.0, 'z': 0.0}  # It will be updated using UDP
trajectory = {
    'x': 0.0,
    'y': 0.0,
    'z': 0.0
}  # Trajectory that the vehicle will follow
"""test-send.py: Test script to send RC commands to a MultiWii Board."""

__author__ = "Aldo Vargas"
__copyright__ = "Copyright 2014 Aldux.net"

__license__ = "GPL"
__version__ = "1"
__maintainer__ = "Aldo Vargas"
__email__ = "*****@*****.**"
__status__ = "Development"

from modules.pyMultiwii import MultiWii
import time

if __name__ == "__main__":

    board = MultiWii("/dev/ttyUSB0")
    #board = MultiWii("/dev/tty.SLAB_USBtoUART")
    try:
        board.arm()
        print "Board is armed now!"
        print "In 3 seconds it will disarm..."
        time.sleep(3)
        board.disarm()
        print "Disarmed."
        time.sleep(3)

    except Exception,error:
        print "Error on Main: "+str(error)
예제 #5
0
    #altitude = board.getData(MultiWii.ALTITUDE)  #estalt
    #data = board.getData(MultiWii.MOTOR)  #m1,m2,m3,m4
    #data = board.getData(MultiWii.RC)  #roll,pitch,yaw
    data = board.getData(MultiWii.RAW_IMU)  #g,a,m
    #pid = board.getData(MultiWii.PID)
    #gps = board.getData(MultiWii.RAW_GPS)
    return data


def setData():
    rcCMD = [1520, 1520, 1520, 1500]
    board.sendCMD(8, MultiWii.SET_RAW_RC, rcCMD)


serialPort = "/dev/ttyACM0"
board = MultiWii(serialPort)
try:
    print("init  getData()")
    print(getData(board))
    board.arm()
    time.sleep(1)
    print("armed getData() x2")
    time.sleep(0.1)
    print(getData(board))
    time.sleep(1)
    print(getData(board))
    time.sleep(1)
    print("armed setData()")
    setData()
    time.sleep(1)
    print("armed getData()")
"""test-attitude.py: Main module to test communication with a MultiWii Board by asking attitude."""

__author__ = "Aldo Vargas"
__copyright__ = "Copyright 2014 Aldux.net"

__license__ = "GPL"
__version__ = "1"
__maintainer__ = "Aldo Vargas"
__email__ = "*****@*****.**"
__status__ = "Development"

from modules.pyMultiwii import MultiWii
from sys import stdout

if __name__ == "__main__":

    board = MultiWii("/dev/ttyUSB0")
    #board = MultiWii("/dev/tty.SLAB_USBtoUART")
    try:
        while True:
            board.getData(MultiWii.ATTITUDE)
            #print board.attitude #uncomment for regular printing

            # Fancy printing (might not work on windows...)
            message = "angx = {:+.2f} \t angy = {:+.2f} \t heading = {:+.2f} \t elapsed = {:+.4f} \t".format(float(board.attitude['angx']),float(board.attitude['angy']),float(board.attitude['heading']),float(board.attitude['elapsed']))
            stdout.write("\r%s" % message )
            stdout.flush()
            # End of fancy printing
    except Exception,error:
        print "Error on Main: "+str(error)
예제 #7
0
import time
import datetime
import csv
import threading
from math import *
from modules.utils import *
from modules.pyMultiwii import MultiWii
import modules.UDPserver as udp

#roll, pitch, yaw, throttle
rcCMD = [1500, 1500, 1500, 1000]

vehicle = MultiWii("COM3")


def control():
    global vehicle
    global rcCMD

    while True:
        if udp.active:
            print "UDP is active"
            break
        else:
            print "Waiting for UDP server"
        time.sleep(0.5)

    try:

        while True:
            for x in udp.message:
예제 #8
0
__copyright__ = "Copyright 2015 Aldux.net"

__license__ = "GPL"
__version__ = "1"
__maintainer__ = "Aldo Vargas"
__email__ = "*****@*****.**"
__status__ = "Development"

from Tkinter import *
from modules.pyMultiwii import MultiWii
import modules.utils as utils
from modules.printer import ThermalPrinter
import time, csv, datetime, random

# MultiWii Initialization
board = MultiWii("/dev/ttyUSB0")
#board = MultiWii("/dev/tty.usbserial-A801WYAE")

# Events data Initialization
reader = reader = csv.reader(open('data.csv', 'rU'), delimiter=';')
events = list(reader)
events.sort()
events.pop(0)
for i in range(len(events)):
    try:
        csvdate = datetime.datetime.strptime(events[i][0], "%Y-%m-%dT%H:%M:%S")
    except:
        csvdate = datetime.datetime.strptime(events[i][0], "%Y-%m-%d")
    tempdate = csvdate - datetime.timedelta(days=70)
    events[i][0] = tempdate.strftime('%d %b %Y')
예제 #9
0
#import modules.UDPserver as udp
message = [1500, 1500, 1500, 1050, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
udp = {'active': True, 'message': message}

# Main configuration
logging = True
update_rate = 0.01  # 100 hz loop cycle
vehicle_weight = 0.84  # Kg
u0 = 1000  # Zero throttle command
#uh = 1360 # Hover throttle command
uh = 1060  # Hover throttle command
kt = vehicle_weight * g / (uh - u0)
ky = 500 / pi  # Yaw controller gain

# MRUAV initialization
vehicle = MultiWii("/dev/ttyACM0")

# Position coordinates [x, y, x]
desiredPos = {
    'x': 0.0,
    'y': 0.0,
    'z': 1.0
}  # Set at the beginning (for now...)
currentPos = {'x': 0.0, 'y': 0.0, 'z': 0.0}  # It will be updated using UDP

# Initialize RC commands and pitch/roll to be sent to the MultiWii
rcCMD = [1500, 1500, 1500, 1000]
desiredRoll = desiredPitch = desiredYaw = 1500
desiredThrottle = 1000

# Controller PID's gains (Gains are considered the same for pitch and roll)
예제 #10
0
"""test-attitude.py: Main module to test communication with a MultiWii Board by asking attitude."""

__author__ = "Kiran Kumar Lekkala"

__maintainer__ = "Aldo Vargas"
__email__ = "*****@*****.**"
__status__ = "Development"

from modules.pyMultiwii import MultiWii
from sys import stdout

if __name__ == "__main__":

    board = MultiWii("/dev/ttyUSB0")
    #board = MultiWii("/dev/tty.SLAB_USBtoUART")
    try:
        while True:
            board.getData(MultiWii.RC)
            #print board.attitude #uncomment for regular printing

            # Fancy printing (might not work on windows...)
            message = "angx = {:+f} \t angy = {:+f} \t heading = {:+f} \t elapsed = {:+f} \t".format(float(board.rcChannels['roll']),float(board.rcChannels['pitch']),float(board.rcChannels['yaw']),float(board.rcChannels['throttle']))
            stdout.write("\r%s" % message )
            stdout.flush()
            # End of fancy printing
    except Exception,error:
        print "Error on Main: "+str(error)
예제 #11
0
"""test-attitude.py: Main module to test communication with a MultiWii Board by asking attitude."""

__author__ = "Kiran Kumar Lekkala"

__maintainer__ = "Aldo Vargas"
__email__ = "*****@*****.**"
__status__ = "Development"

from modules.pyMultiwii import MultiWii
from sys import stdout

if __name__ == "__main__":

    board = MultiWii("/dev/ttyUSB0")
    #board = MultiWii("/dev/tty.SLAB_USBtoUART")
    try:
        while True:
            board.getData(MultiWii.MOTOR)

            # Fancy printing (might not work on windows...)
            message = "angx = {:+f} \t angy = {:+f} \t heading = {:+f} \t elapsed = {:+f} \t".format(float(board.motor['m1']),float(board.motor['m2']),float(board.motor['m3']),float(board.motor['m4']))
            stdout.write("\r%s" % message )
            stdout.flush()
            # End of fancy printing
    except Exception,error:
        print "Error on Main: "+str(error)
예제 #12
0
from math import *
from modules.utils import *
from modules.pyMultiwii import MultiWii
import modules.UDPserver as udp

# Main configuration
logging = True
update_rate = 0.01  # 100 hz loop cycle
vehicle_weight = 0.84  # Kg
u0 = 1000  # Zero throttle command
uh = 1360  # Hover throttle command
kt = vehicle_weight * g / (uh - u0)
ky = 500 / pi  # Yaw controller gain

# MRUAV initialization
vehicle = MultiWii("COM3")
vehicle.getData(MultiWii.ATTITUDE)

# Position coordinates [x, y, x]
desiredPos = {
    'x': 0.0,
    'y': 0.0,
    'z': 1.0
}  # Set at the beginning (for now...)
currentPos = {'x': 0.0, 'y': 0.0, 'z': 0.0}  # It will be updated using UDP

# Initialize RC commands and pitch/roll to be sent to the MultiWii
rcCMD = [1500, 1500, 1500, 1000]
desiredRoll = 1500
desiredPitch = 1500
desiredThrottle = 1000