Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
import socket
import sys, select, termios, tty
import cPickle as pickle
import pprint
import math
from multiprocessing import Process
def uav_client(uav_id, dispatch_heading):
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect the socket to the port where the server is listening
uav_id = uav_id
server_address = ('localhost', int("1000%s" % uav_id))
print >> sys.stderr, 'connecting to %s port %s' % server_address
sock.connect(server_address)
try:
x_speed =-250
y_speed =-800
altitude = 7
heading = dispatch_heading
# Send data
predispatch_count = 53
postdispatch_count = 50
picked = False
while True:
command = {"x_speed": x_speed, "y_speed": y_speed, "altitude": altitude, "heading": heading}
message = pickle.dumps(command)
pprint.pprint(command)
sock.sendall(message)
# Look for the response
data = sock.recv(4096)
data = pickle.loads(data)
pprint.pprint(data)
except KeyboardInterrupt:
print >> sys.stderr, 'closing socket'
sock.close()
def move(x,y):
deneme=data["active_uav"]["location"]
instant_location_x,instant_location_y = deneme.split(',')
instant_location_x=float(instant_location_x)
instant_location_y=float(instant_location_y)
mesafe =(instant_location_x-x)*(instant_location_x-x) + (instant_location_y-y) * (instant_location_y-y)
mesafe = math.sqrt(mesafe)
print (mesafe)
top=abs(instant_location_x-x) + abs(instant_location_y-y)
oran=50/top
x_speed=oran*(instant_location_x-x)
y_speed=oran*(instant_location_y-y)
while mesafe ==0:
command={"x_speed":x_speed,"y_speed":y_speed}
def dist_from_node():
deneme=data["active_uav"]["location"]
instant_location_x,instant_location_y = deneme.split(',')
instant_location_x=float(instant_location_x)
instant_location_y=float(instant_location_y)
#liste sayısı düzenlenmeli!
dist_list=[0,0,0,0,0,0,0,0]
for i in range (len(data["uav_link"])):
i=str(i+1)
hm="uav_"+i
deneme=data["uav_link"][hm]["location"]
uav_loc_x,uav_loc_y=deneme.split(',')
uav_loc_y=float(uav_loc_y)
uav_loc_x=float(uav_loc_x)
dist=(instant_location_x - uav_loc_x)**2 + (instant_location_y - uav_loc_y)**2
dist=math.sqrt(dist)
dist_list[x]=dist
x=x+1
return dist_list
def formation_fly(u_b,a_b,u_k,a_k):
#eğer yön 1. bölgede ise
sin_ak=math.sin(a_k)
cos_ak=math.cos(a_k)
deneme=data["uav_guide"]["location"]
guide_x,guide_y = deneme.split(',')
guide_x=float(guide_x)
guide_y=float(guide_y)
uav0_x=guide_x+sin_ak*u_k
uav0_y=guide_y+cos_ak*u_k
#formasyon başındaki iha konumu
sin_ab=abs(math.sin(a_b))
cos_ab=abs(math.cos(a_b))
ub_x=sin_ab*u_b
ub_y=cos_ab*u_b
uav1_x=uav0_x+ub_x
uav1_y=uav0_y+ub_y
uav2_x=uav0_x+ub_x
uav2_y=uav0_y-ub_y
for i in range (len(data["uav_link"])-1//2):
for i in range (len(data["uav_link"]-1//2)):
#her uav kendi link de gözüken id sini bulur.
def find_id():
for i in range(len(data["uav_link"])):
i=str(i)
hm="uav_"+i
try:
data["uav_link"][hm]
except:
id=i
return i
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team