Skip to content

Commit

Permalink
Minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
spk170 committed Nov 1, 2017
1 parent 0deae47 commit 21f0678
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
8 changes: 4 additions & 4 deletions backyard_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def velocity_callback(msg_name,msg):
pass
elif self.flight_state == States.LANDING:
if self.global_position[2] - self.global_home[2] < 0.1:
print(abs(msg.down))
if abs(msg.down)<0.01:
self.disarming_transition()
elif self.flight_state == States.DISARMING:
Expand Down Expand Up @@ -155,12 +154,13 @@ def start(self):

super().start()

while self.in_mission:
pass
#Only required if they do threaded
#while self.in_mission:
# pass

self.stop_log()

if __name__ == "__main__":
drone = BackyardFlyer()
drone = BackyardFlyer(threaded=False)
time.sleep(2)
drone.start()
12 changes: 8 additions & 4 deletions drone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logger
from connection import mavlink_connection as mc
from connection import message_types as mt
import time


class Drone:
Expand Down Expand Up @@ -414,13 +415,13 @@ def stop_log(self):
def start(self):
"""Starts the connection to the drone"""
self.connection.start()
self.tlog.close()



def stop(self):
"""Stops the connection to the drone"""
"""Stops the connection to the drone and closes the log"""
self.disconnect()

self.tlog.close()

def run(self):
"""Runs the connection in a while loop,
Expand All @@ -434,5 +435,8 @@ def run(self):
else:
self.start()



if __name__ == "__main__":
drone = Drone(threaded=False)
time.sleep(2)
drone.start()
20 changes: 13 additions & 7 deletions logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ def log_data(self,data):

self.log.write('\n')


#Returns a numpy 2D array of the data
def read_log(self,filename):
return np.loadtxt(filename,delimiter=',',dtype='Float64')



def log_telemetry_data(self,data):
for i in range(len(data)):
if type(data[i]) == float:
self.log.write('{0:.7f}'.format(data[i]))
else:
self.log.write(data[i].__str__())
if i != len(data)-1:
self.log.write(',')

self.log.write('\n')

#Returns a numpy 2D array of the data
def read_log(filename):
return np.loadtxt(filename,delimiter=',',dtype='Float64')



Expand Down

0 comments on commit 21f0678

Please sign in to comment.