def getMission(request): server = InteropServer.objects.all()[0] auvsi_client = client.Client(url=server.url, username=server.username, password=server.password) auvsi_client = client.Client(url='http://127.0.0.1:8000', username='******', password='******') mission = auvsi_client.get_mission(1) with open('controlcenter/missions/mission_file.json', 'w') as mission_file: mission_file.write(MessageToJson(mission)) mission_file = ParseJsonFile(os.getcwd() + '/controlcenter/missions/mission_file.json') maxAltitude = mission_file.altitudeMax minAltitude = mission_file.altitudeMin wayPointsDict = constructDict(mission_file.wayPointsList, 3) boundaryDict = constructDict(mission_file.boundaryPointsList, 3) searchPointsDict = constructDict(mission_file.searchPointList, 3) return render( request, 'controlcenter/get_mission.html', { 'way_points_dict': wayPointsDict, 'max_altitude': maxAltitude, 'min_altitude': minAltitude, 'boundary_dict': boundaryDict, 'search_dict': searchPointsDict })
def __init__(self): try: print("got into init") #establishes interop connect. Creating an interop client object automatically makes a call to connect to interop self.client1 = client.Client(url=GCSSettings.INTEROP_URL, username=GCSSettings.INTEROP_USERNAME, password=GCSSettings.INTEROP_PASSWORD) # self.asyncClient = AsyncClient(GCSSettings.INTEROP_URL, GCSSettings.INTEROP_USERNAME, GCSSettings.INTEROP_PASSWORD) except Exception as e: print(e)
def login(self): if self.login_status: # No need to relogin return try: self.client = client.Client( url=self.config['interop']['url'], username=self.config['interop']['username'], password=self.config['interop']['password']) self.login_status = True except Exception as e: print("Interop login failed: {}".format(str(e))) self.login_status = False return self.initialize()
def upload2Interop(self): s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = s9 = None s1 = self.text1.get() s2 = self.entry2.get() s3 = self.entry3.get() s4 = self.text4.get() s5 = self.text5.get() s6 = self.text6.get() s7 = self.entry7.get() s8 = self.text8.get() s9 = self.entry9.get() if s9 == "": s9 = None target_response = OrderedDict([("id", 1), ( "mission", 1, ), ("type", s1), ("latitude", s2), ("longitude", s3), ("orientation", s4), ("shape", s5), ("background_color", s6), ("alphanumeric", s7), ("alphanumeric_color", s8), ("description", s9), ("autonomous", False)]) # print target_response json_str = json.dumps(target_response) print(json_str) x = self.gps() print("Latitude and Longitude : ") with open(str(self.index2) + ".json", 'w') as outfile: json.dump(target_response, outfile) a = str(self.index2) + ".json" b = "cp " + a + " mydata/" + a os.system(b) myclient = client.Client(url='http://localhost:8000', username='******', password='******') """target=interop.Odlc(id=None, user='******', type=s1, latitude=s2, longitude=s3, orientation=s4, shape=s5, background_color=s6, alphanumeric=s7, alphanumeric_color=s8, description=None, autonomous=False) target = client.post_odlc(target)""" odlc = interop_api_pb2.Odlc() odlc.mission = 1 odlc.type = interop_api_pb2.Odlc.STANDARD #odlc.latitude = s2 #odlc.longitude = s3 odlc.orientation = 4 odlc.shape = 5 odlc.shape_color = 6 odlc.alphanumeric = s7 odlc.alphanumeric_color = 8 odlc = myclient.post_odlc(odlc) print(str(self.index2) + ".jpg") with open(str(self.index2) + ".jpg", 'rb') as f: image_data = f.read() myclient.put_odlc_image(odlc.id, image_data) self.index2 += 1
from auvsi_suas.client import client from auvsi_suas.proto import interop_api_pb2 from google.protobuf import json_format client = client.Client(url='http://10.10.130.10:80', username='******', password='******') mission = client.get_mission(3) print(json_format.MessageToJson(mission))
from auvsi_suas.client import client from auvsi_suas.proto import interop_api_pb2 import urllib import json import time import datetime import csv from google.protobuf.json_format import MessageToJson, MessageToDict client = client.Client(url='http://10.10.130.10:80', username='******', password='******') #client = client.Client(url='http://127.0.0.1:8000', username='******', password='******') #client = client.Client(url='http://10.10.130.66:8000', username='******', password='******') mission = client.get_mission(3) #DictObj = MessageToDict(mission) #print(DictObj) #print(DictObj["offAxisOdlcPos"]) #print(DictObj["flyZones"][0]["boundaryPoints"]) #print (mission) #print(type(mission)) try: x = urllib.request.urlopen('http://10.10.130.104:56781/mavlink/') #print(x.read()) # Catching the exception generated except Exception as e: print(str(e))
'Found duplicate odlc files for %s: %s and %s' % (name, odlcs[name], entry)) odlcs[name] = os.path.join(odlc_dir, entry) elif ext.lower() in ['.png', '.jpg', '.jpeg']: if name in images: raise ValueError( 'Found duplicate odlc images for %s: %s and %s' % (name, images[name], entry)) images[name] = os.path.join(odlc_dir, entry) pairs = {} for k, v in odlcs.items(): if k in images: pairs[v] = images[k] else: pairs[v] = None # logger.info('Found odlc-image pairs:\n%s' % pprint.pformat(pairs)) for odlc, image in pairs.items(): upload_odlc(client, odlc, image) if __name__ == "__main__": client = client.Client(url='http://127.0.0.1:8000', username='******', password='******') upload_odlcs(client, '/Users/shadow/interop/client/testdata')
def upload2Interop(self): s0 = self.mission.get() s1 = self.text1.get() s4 = self.text4.get() s5 = self.text5.get() s6 = self.text6.get() s7 = self.entry7.get() s8 = self.text8.get() s9 = self.entry9.get() typeDict = { "standard": interop_api_pb2.Odlc.STANDARD, "emergent": interop_api_pb2.Odlc.EMERGENT, "off_axis": interop_api_pb2.Odlc.OFF_AXIS } orientationDict = { "n": 1, "ne": 2, "e": 3, "se": 4, "s": 5, "sw": 6, "w": 7, "nw": 8 } shapeDict = { "circle": 1, "semicircle": 2, "quarter_circle": 3, "triangle": 4, "square": 5, "rectangle": 6, "trapezoid": 7, "pentagon": 8, "hexagon": 9, "heptagon": 10, "octagon": 11, "star": 12, "cross": 13 } colourDict = { "white": 1, "black": 2, "gray": 3, "red": 4, "blue": 5, "green": 6, "yellow": 7, "purple": 8, "brown": 9, "orange": 10 } myclient = client.Client(url='http://10.10.130.10:80', username='******', password='******') currPath = self._images[self._image_pos] odlc = interop_api_pb2.Odlc() odlc.mission = int(s0) odlc.type = typeDict[s1] try: odlc.latitude = float(gpcrop[currPath[10:]][0]) odlc.longitude = float(gpcrop[currPath[10:]][1]) except KeyError: print("OOPs") if s4 != "Orientation": odlc.orientation = orientationDict[s4] if s5 != "Shape": odlc.shape = shapeDict[s5] if s6 != "Background Colour": odlc.shape_color = colourDict[s6] if s7 != "": odlc.alphanumeric = s7 if s8 != "Alphanumeric Colour": odlc.alphanumeric_color = colourDict[s8] if s9 != "" and odlc.type == interop_api_pb2.Odlc.EMERGENT: odlc.description = s9 odlc = myclient.post_odlc(odlc) with open(currPath, 'rb') as f: image_data = f.read() myclient.put_odlc_image(odlc.id, image_data)
with open('2.SUAS2019.txt', 'a') as writer: writer.write("\t".join(map(str, airdroprow))) # Write Airdrop coordinate writer.write('\n') writer.write("\t".join(map( str, joerow))) # Write emergentLastKnownPos coordinate writer.write('\n') writer.write("\t".join(map(str, landingrow))) # Write Landing coordinate writer.write('\n') return # Create client object client = client.Client(url='http://192.168.137.1:8000', username='******', password='******') #Get missions mission_id = int(input('Select mission ID:')) mission = client.get_mission(mission_id) json_mission = json_format.MessageToJson(mission) # Use json library to read the mission data json_parsed = json.loads(json_mission) # json_parsed = json.loads(mission) # Write flyzones altitude altmax = json_parsed['flyZones'][0]['altitudeMax'] altmin = json_parsed['flyZones'][0]['altitudeMin'] print("Flyzone alt:", "Max", altmax, "Min", altmin)
def main(): client1 = client.Client(url='http://127.0.0.1:8000', username='******', password='******') mission = client1.get_mission(1) print(type(mission))
from auvsi_suas.client import client from auvsi_suas.proto import interop_api_pb2 import json from google.protobuf import json_format client = client.Client(url='http://localhost:8000', username='******', password='******') mission = client.get_mission(2) print(json_format.MessageToJson(mission)) # print (mission)