def __init__(self): self.homelocation = 1 rospy.init_node('drone_pilot') self.wppub = rospy.Publisher('/wp_cords', PoseArray, queue_size=60) self.msgpub = PoseArray() self.gui_status = rospy.Publisher('status_msg', String, queue_size=1, latch=True) self.takeoff = rospy.Publisher('activation', Int32, queue_size=1, latch=True) self.progress = rospy.Publisher('/progbar', Int16, queue_size=1) rospy.Subscriber('whycon/poses', PoseArray, self.get_pose) rospy.Subscriber('/qr', String, self.setqr) rospy.Subscriber('drone_init', Int32, self.set_guicommand) self.counter = 0 self.takeoffland = -1 self.cruize = 18.0 self.drone_x = 0.0 self.drone_y = 0.0 self.drone_z = 24.0 self.home_x = 0.0 self.home_y = 0.0 self.wp_x = 0.0 self.wp_y = 0.0 self.wp_z = 0.0 #self.authenticationflag = 0 # Do not remove to be uncommented when feature of invalid QR is to be used self.coordinatespub = [0.0, 0.0, 30.0] pose = Pose() pose.position = Point(*self.coordinatespub) self.msgpub.poses.append(pose) self.startrun = 0 self.startend = 1 self.coordinates = csvio.csvread( '/home/' + getpass.getuser() + '/catkin_ws/src/shravas/src/coordinates.csv') self.coordinates1 = nofly.main(self.coordinates) #csvio.csvwrite(self.coordinates1,'/home/'+getpass.getuser()+'/catkin_ws/src/shravas/src/coords.csv') #print(self.coordinates) #print(self.coordinates1) for index in range(len(self.coordinates)): self.coordinates[index]['x'] = float(self.coordinates[index]['x']) self.coordinates[index]['y'] = float(self.coordinates[index]['y']) self.coordinates[index]['z'] = float(self.coordinates[index]['z']) self.coordinates[index]['delivery'] = int( self.coordinates[index]['delivery']) #self.coordinates=[{"x":0,"y":0,"Z":0,"qr":0,"delivery":0},{"x":-8.0,"y":4.0,"Z":20,"qr":"QuadDrop","delivery":2},{"x":0.7,"y":-0.63,"Z":20,"qr":"WANK","delivery":1},{"x":0,"y":0,"Z":0,"qr":0,"delivery":-1}] self.qr_pub = "no code" self.start_time = 0.0 self.end_time = 0.0
def auth(uname, password): password = encrypt(password) list = csvio.csvread('/home/' + getpass.getuser() + '/catkin_ws/src/shravas/src/dat.csv') for index in list: if (index['uname'] == uname and index['password'] == password): return 1 else: return -1
def __init__(self): self.homelocation = 1 rospy.init_node('drone_pilot') self.msgpub = PoseArray() self.posepos = Pose() self.wppub = rospy.Publisher('/wp_cords', PoseArray, queue_size=60) self.gui_status = rospy.Publisher('status_msg', String, queue_size=1, latch=True) self.takeoff = rospy.Publisher('activation', Int32, queue_size=1, latch=True) self.progress = rospy.Publisher('/progbar', Int16, queue_size=1) rospy.Subscriber('whycon/poses', PoseArray, self.get_pose) rospy.Subscriber('/qr', String, self.setqr) rospy.Subscriber('drone_init', Int32, self.set_guicommand) self.cruize = 15.0 self.delivery_z = 18.0 self.counter = 0 self.takeoffland = -100 self.drone_x = 0.0 self.drone_y = 0.0 self.drone_z = 24.0 self.home_x = 0.0 self.home_y = 0.0 self.startend = 2 #self.authenticationflag = 0 # Do not remove to be uncommented when feature of invalid QR is to be used self.coordinatespub = [0.0, 0.0, 30.0] self.create_pose_array() self.coordinates = csvio.csvread( '/home/' + getpass.getuser() + '/catkin_ws/src/shravas/src/coordinates.csv') self.coordinates1 = nofly.main(self.coordinates) print(self.coordinates) print(self.coordinates1) for index in range(len(self.coordinates)): self.coordinates[index]['x'] = float(self.coordinates[index]['x']) self.coordinates[index]['y'] = float(self.coordinates[index]['y']) self.coordinates[index]['z'] = float(self.coordinates[index]['z']) self.coordinates[index]['delivery'] = int( self.coordinates[index]['delivery']) self.qr_pub = "no code"
if(co.x==s.x and co.y==s.y): print("path plannning not possible") sys.exit(1) elif (co.x==d.x and co.y==d.y): rwp.append({'y':d.y,'x':d.x,'delivery':int(wp[i]['delivery']),'z':float(wp[i]['z']),'qr':wp[i]['qr']}) elif((co.x!=s.x and co.y!=s.y) or (co.x!=d.x and co.y!=d.y)): #print("inserting") rwp.append({'y':co.y,'x':co.x,'delivery':-2,'z':float(wp[i]['z']),'qr':''}) rwp.append({'y':d.y,'x':d.x,'delivery':int(wp[i]['delivery']),'z':float(wp[i]['z']),'qr':wp[i]['qr']}) return rwp #csvwrite(rwp,"outputcsv.csv") #print(wp.x,wp.y) if __name__ == '__main__': ''' Function Name: __main__ Logic: For testing purposes only ''' #wp=[{"x":-8.52,"y":0.14,"z":0,"qr":0,"delivery":0},{"x":-4.4,"y":2.94,"z":20,"qr":"QuadDrop","delivery":2},{"x":0.7,"y":-0.63,"z":20,"qr":"WANK","delivery":1},{"x":0,"y":0,"z":0,"qr":0,"delivery":-1}] #cir=nofl(-6.7,1.5,2.0) wp=csvio.csvread('/home/walst/catkin_ws/src/shravas/src/coordinates.csv') rs=main(wp) for i in range(len(wp)): print(wp[i]) print("\n\n") for i in range(len(rs)): print(rs[i]) #print(rs[1]['x'],rs[1]['y'])
global pathh pathh = "/home/" + getpass.getuser() + "/catkin_ws/src/shravas/src/" global wificard wc = os.listdir('/sys/class/net/') wificard = "wlo1" #wificard = "wlp2s0" #for i in range(len(wc)): # if(wc[i]!='lo'): # wificard=str(wc[i]) # else: # wificard="wlo1" global delidat, ls ls = csvio.csvread(pathh + "coordinates.csv") delidat = csvio.csvread(pathh + "deliverydata.csv") drobj = rospy.Publisher('/drone_init', Int32, queue_size=1) eng = rospy.Publisher('/eng_init', Int32, queue_size=1) def start(): drobj.publish(1) def emstop(): drobj.publish(0) def callback():