From 242ba6da20c8407ff555c960d9ee7c867b082fc6 Mon Sep 17 00:00:00 2001 From: 488_MP-4 <488_MP-4@iastate.edu> Date: Sun, 12 Nov 2023 23:02:03 +0100 Subject: [PATCH] More function signatures --- cflib_groundstation/LogfileHandler.py | 114 ++++++++---------- .../__pycache__/LogfileHandler.cpython-38.pyc | Bin 4849 -> 3148 bytes .../SetpointHandler.cpython-38.pyc | Bin 7436 -> 7436 bytes .../crazyflie_connection.cpython-38.pyc | Bin 8952 -> 9845 bytes .../groundstation_socket.cpython-38.pyc | Bin 4797 -> 4828 bytes .../__pycache__/uCartCommander.cpython-38.pyc | Bin 7993 -> 7993 bytes cflib_groundstation/crazyflie_connection.py | 97 ++++++++------- cflib_groundstation/groundstation_socket.py | 1 + cflib_groundstation/main.py | 8 +- 9 files changed, 114 insertions(+), 106 deletions(-) diff --git a/cflib_groundstation/LogfileHandler.py b/cflib_groundstation/LogfileHandler.py index 4dca8f924..59fea4953 100644 --- a/cflib_groundstation/LogfileHandler.py +++ b/cflib_groundstation/LogfileHandler.py @@ -41,69 +41,45 @@ class LogfileHandler: self.is_connected = False self.param_callback_count = 0 self.logging_configs = [] + self.data_log = "" - def add_log_config(self, name: str, period: int, variables: List[str]): - """ Add a logging config. Used from logging tab when refreshing - logging variables. Add callback to route logged data to logging - queue. """ - - print("Name: " + name + ", period: " + str(period) + ", variables: " - + str(variables)) - logging_group = LogConfig(name=name, period_in_ms=period) - - for variable in variables: - logging_group.add_variable(variable, 'float') - - self.logging_configs.append(logging_group) - self.logging_configs[-1].data_received_cb.add_callback( - self.logging_callback) - self.scf.cf.log.add_config(self.logging_configs[-1]) - - - def refresh_logging_configs(self): - return self.read_all_active_blocks() - - def load_logging_configs(self): - return self.read_all_active_blocks() - - def clear_logging_configs(self): - """ Stop logging and clear configuration. Used when refreshing - logging to stop anything that has configured to be logged from - logging. """ - - self.stop_logging() - self.logging_configs = [] - # done refreshing toc is a callback function that is triggered when - # refresh toc is done executing. - self.scf.cf.log.refresh_toc( - self.done_refreshing_toc, self.scf.cf.log._toc_cache) - # Blocks until toc is done refreshing. - while self.param_callback_count < 1: - time.sleep(0.01) - self.param_callback_count = 0 - - # grabs new toc values - self.scf.wait_for_params() - def resume_logging_configs(): - raise Exception - - def pause_logging_configs(): - raise Exception - - def enable_logging(self): - """ Begins logging all configured logging blocks. This is used from - the controls tab when hitting begin logging. """ - for i in range(0, len(self.logging_configs)): - self.logging_configs[i].start() - - def disable_logging(self): - """ Stops logging all configured logging blocks. This is used from - the controls tab when hitting pause logging. """ - for i in range(0, len(self.logging_configs)): - self.logging_configs[i].stop() - + def CopyTocToFile(self, toc :dict, isParams): + if isParams: + logType = "Param" + else: + logType = "Log" + + filename = os.getcwd() + filename += f"/logs/cflie1_{logType}_toc_{time.strftime('%Y_%m_%d_%H:%M:%S', time.localtime())}.txt" + # print(f"TOCtoFILE:{filename}") + + types = {'uint8_t' : 0x08, + 'uint16_t' : 0x09, + 'uint32_t' : 0x0A, + 'uint64_t' : 0x0B, + 'int8_t' : 0x00, + 'int16_t' : 0x01, + 'int32_t' : 0x02, + 'int64_t' : 0x03, + 'FP16' : 0x05, + 'float' : 0x06, + 'double' : 0x07} + + file = open(filename, "w") + file.write(f"{logType} ID Type Group Identifier Name\n") + file.close() + file = open(filename, "a") + for group in list(toc.keys()): + for name in list(toc[group].keys()): + file.write(f"{toc[group][name].ident} {types.get(toc[group][name].ctype)} {group} {name}\n") + #print(f" Identity: {toc[group][name].ident} Packet Type:{toc[group][name].pytype} CType:{toc[group][name].ctype} Group:{group} Name:{name}\n") + + + + file.close() + return filename def read_all_active_blocks(self): active_blocks = [] @@ -119,7 +95,6 @@ class LogfileHandler: i = 0 newLine = logBlockFile.readline().strip() while newLine != "END BLOCK": - print(newLine) if newLine == "" or newLine == "END BLOCK": print("New Line: " + newLine) raise Exception("loggingBlocks.txt is not formatted correctly") @@ -136,8 +111,23 @@ class LogfileHandler: config = LogConfig(data[1], data[2]) for i in range(3, len(data)): config.add_variable(data[i]) - config.create() active_blocks.append(config) return active_blocks + def create_log_data_file(self): + raise Exception + + def add_config_headers(self): + raise Exception + + def start_logging(self): + raise Exception + + def stop_logging(self): + raise Exception + + def write_data_point(self): + raise Exception + + diff --git a/cflib_groundstation/__pycache__/LogfileHandler.cpython-38.pyc b/cflib_groundstation/__pycache__/LogfileHandler.cpython-38.pyc index 7fcdd75366634ed8a67ceb0bc0249148df63257c..6467201807fee9556118b139b0fd672116df9b80 100644 GIT binary patch delta 1463 zcmZ8h&2QX96!+LO_N;fk*=+N*fXb#~5z8S_N*bz2ND(ce6{RXlKw>3ixt`gTiDPfZ zPSdQsT8Z??p^}enq}?MoJ|rX#J#j+fz=a;>KiC6Oxp3x<(?DBW^PAs1zj^P?dvE-A z>-VMV=Z<4*@T_cq#($jop_-u&3|MZ#NLB#2)<I0`=nQoXrZeM#*1?=G{1`F9%m=t* zGK*1=TCB9Awe6oQ{VA%nk;DlPyWeSIE}t5M5t2q4`@S-L{*-`JU|fTdJOjvdVKX!| zBFyxmk!oW!(S|s~%*c#K8pEkRHW&fK6K$e{#5^VMgN6!#m6*-Stil{tWizbCW?B7l zc}P+M`!Ae~^r4xVW3w<ccdAbi(qL^(G^7<O^CzH@(hQAD6YT_D*S`8<XsLB(HMIX^ zTSHn{DWn-~XkXh9#zIEM<ulDfR+*qeY86NU7e}X5xjYyje0%OT!;r3}+mhVzgtsq^ zTXApTtcGzfS@pYNz}MUkaUo~!V7B$8+uC<q%x&G+Y<;@f+8N-L^nN;}khG~v<5ZP! zS_TkEu>y3(RKll38v&Y%S^({`v<`zPz3QftDzdh5&fdFx&NkM8na{PXb0tLz9YqQi zynSbFLy~S7d!Wza!@D7u=xFeE^XBztv$=cR=P-?$AB*^~59}u6Q5tjuE}FN!eQrzS z4KT=?64`A>>Tx2?9#8!vCNRV*X_AU=8tikSjv{f~=aD2wB1pL;ei$cQ;xI^3iTC(% zB1xd^O9M>6=M=oROX7k$zgUF*9U3G>zLSmxsaDZR+6_V;K`fFe{X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eT1a(|i7Cc}P7-ooa5e}wK{5BE) zfWY?vG80vyDhQ{3?qaN2QQ5$2(EaZz_ovCot3xKWwR^ZZW)?B_s#9@D>dd05QQQIp zuN3nmHReon+kB+pkU+VD>x_S4i3oGkI{=z)={Ujgmhrm*j9Lr7y26&IHJ0=xgU+|A zzN|*eXqVB)i?VQZ`IxzC&35w|-E`>A;`=zA{eHrRNO*o$_x;0R5anM=zRz%Q`(hp9 ziSH7)Pk_Qy&?z7`2~dS9eoWv40zV<}a{|94@Hv6AtTC(KL<1kFr;1zb)GDuBUoM;Y zttjY}%ZjGCA;{QXjrW5vY7J!=rGkt;Eh8LxJV4o_gvuNkeb|v%b$WB}2sy}Xg=dS! zQ2wunpzB!n*4$`|uFJDOLPUvZY;`RWR4``?!)@Htx08M!cWnImv3em&{1itRmx6Mc zpxdLU0eCC(i@>X<7ZN)j_Hper;(^-gReH+GznGfmBho@ju1vK*{oo)ly24efT*Ukj DM(hO6 diff --git a/cflib_groundstation/__pycache__/SetpointHandler.cpython-38.pyc b/cflib_groundstation/__pycache__/SetpointHandler.cpython-38.pyc index 0c7e0a74ab5cc30a12251e4bb5914b570dbe5755..4b6fa575d603a6f5965726a792f3559d6bdcb65f 100644 GIT binary patch delta 19 YcmeCN>apSq<>lpK00JHBja*E!04JCOQ2+n{ delta 19 YcmeCN>apSq<>lpK0D>pF8@ZTd0V|>d`v3p{ diff --git a/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc b/cflib_groundstation/__pycache__/crazyflie_connection.cpython-38.pyc index c0374ef88a85fc8fd2568c1ec8d3a508f778406b..a880844f863cc0e4376eae434e19710590875b17 100644 GIT binary patch delta 4295 zcmb_f|8E>e72nz0+uPgwYWs5bIkvNL;v|<4lW%TX(wcmAn$)$^I8Doj^m2E*=UlvZ zd!F43*sOa3R|2X6iAIWq+6tTBA|XNLKY&UgRHP~rKOn?b2=N;~AOQs=1W54S?D=bo zgMhR5?aZ4uZ)V>6yf<(Edf_kQ$(IueRe;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dw629kH8~}IZ4FKq}qUas`LC^76kFJWbY!|!DyEA<$@fNFq5<I1W zy$k&X=2uudw=x$Jfx29^s_;($46{ytKhyaQ%zg3rXGmJJd1p?3bp^TK57A+GH<)U< pTB@v=a=9Ybd(tKY{e_ZCtB&;|#76SE`BZOb6yg#C@52=r`Y%170KfnM diff --git a/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc b/cflib_groundstation/__pycache__/groundstation_socket.cpython-38.pyc index c7682e1b85a3353b38ec590272b6af5937d17a5e..be803194c29d9124de995ab5d59fc3d0dbd15cd0 100644 GIT binary patch delta 110 zcmdn1dPkKvl$V!_0SKns2Bt3A$h(oBF=g_8{zQ%_i4^f*22F{{DgqT8FU5f>{4^yu z&lfOb6uBkj<L~a|<L~V4?C<OA=;spe=`z`#Pn0hLsA>uj7wZ5Cj!8mtlLdr0n3-4@ JC(8@X0{|m^8Sel9 delta 60 zcmcbkx>uDql$V!_0SKN8`lNPj<lV^6m@s)ie<DjTgQoao4S@<~KTV0vD+J6KCw~%@ PW7L`~D5N{tL1+#D^<xl? diff --git a/cflib_groundstation/__pycache__/uCartCommander.cpython-38.pyc b/cflib_groundstation/__pycache__/uCartCommander.cpython-38.pyc index 80519f2ef307568ffdfa9785fe9f2aa52894b146..85e268143825e20c74f5e47f55281d03cd536423 100644 GIT binary patch delta 332 zcmdmKx6_V0l$V!_0SI)g12=Ln;9`v0yoM`;l~H#xqkuG{-ey^W1SS|~@+=`!0Ry1g zB0~_N2qH{3-xr#}2vadhN@Vj2kx2+0;o`R3_8@f*Ai{C-eDOL7TM$zLM96~(B@p2R zBqkS%MsJ=V5sYM-1*7d|OQ|S?c^hQR8Qmry<Pe_xTV|Dk7D%fOh%g2bW+1`>MA!j| zTdZk0`H3Y(E+7GS5aBubs%#Xa?_>kH6dyg1fI5iK1`+xo!URY}aVO@Kc;x4#gj5!! n7MX)Y_}xN%eBy&c979~=Lm~rQi!4Ekok4^vi13*FKrRvh%yvjy delta 332 zcmdmKx6_V0l$V!_0SIc2I&I`$z{PlL^BS%YRz|(ai~`b(`kQ415}06|$+Lt^1q^{| zi;O^oB8V{Cd|zk=BTU64DUr=9L?$70gp1p9JAl+Vf(WO{^Tq2V>_AKf5FrmDlt6?t zkeFO38ohafL@<(R7L0bAEv2Fm=53HMXLO%@kVAO#Z<$pF+90jEAi@Mhn1cvQ5Md7_ zZn382<R_LCxq<{dK!n%itFlpyev=L4QhfA50_q?_2SgZv2vZ;t#hsW_;*p<|5>i=^ nT4Vtd;dcx5@re%(aSU;d4~YzLEwTbBb^#G?Ai{I<1Gz{5elAJR diff --git a/cflib_groundstation/crazyflie_connection.py b/cflib_groundstation/crazyflie_connection.py index 5c427193e..4e414f4ed 100644 --- a/cflib_groundstation/crazyflie_connection.py +++ b/cflib_groundstation/crazyflie_connection.py @@ -16,6 +16,7 @@ import os import cflib.crtp from cflib.crazyflie import Crazyflie from cflib.crazyflie.syncCrazyflie import SyncCrazyflie +from cflib.crazyflie.syncLogger import SyncLogger from queue import Queue #import groundstation_socket as gs import uCartCommander @@ -23,6 +24,7 @@ from groundstation_socket import MessageTypeID from SetpointHandler import SetpointHandler, FlightMode from cflib.crazyflie.log import LogConfig import numpy as np +from LogfileHandler import LogfileHandler class CrazyflieConnection: @@ -51,6 +53,7 @@ class CrazyflieConnection: self.logging_configs = [] self.setpoint_handler = SetpointHandler() + self.logfile_handler = LogfileHandler() # self.timer = QTimer() # self.timer.timeout.connect(self.update_plot) @@ -250,10 +253,11 @@ class CrazyflieConnection: id = command['data'][0] print(id) if id == 0: # logdata? - raise Exception # Not implemented + for config in self.logging_configs: + self.simple_log(self.scf, config) elif id == 1: # param toc params = self.get_param_toc() - filename = self.CopyTocToFile(params, True) + filename = self.logfile_handler.CopyTocToFile(params, True) data = bytearray() data += bytes(filename, 'utf-8') responsedata = { @@ -265,7 +269,7 @@ class CrazyflieConnection: outputQueue.put(responsedata) elif id == 2: # logging toc logs = self.get_logging_toc() - filename = self.CopyTocToFile(logs, False) + filename = self.logfile_handler.CopyTocToFile(logs, False) data = bytearray() data += bytes(filename, 'utf-8') responsedata = { @@ -281,43 +285,54 @@ class CrazyflieConnection: raise Exception # Not implemented else : raise Exception - def LogBlockCommand(): - #TODO - raise Exception + + def LogBlockCommand(self, command): + print("Log Block Command") + id = command['data'][0] + print(id) + if id == 0: + self.delete_log_blocks() + elif id == 1: + self.delete_log_blocks() + self.logging_configs = self.logfile_handler.read_all_active_blocks() + elif id == 2: + self.logging_configs = self.logfile_handler.read_all_active_blocks() + elif id == 3: + block_id = command['data'][1] + self.logging_configs.remove(self.logging_configs[block_id]) + elif id == 4: + self.enable_logging() + elif id == 5: + self.disable_logging() + + def simple_log(self, scf, logconf): + print("Logging...") + with SyncLogger(scf, logconf) as logger: + for log_entry in logger: + timestamp = log_entry[0] + data = log_entry[1] + logconf_name = log_entry[2] + + print('[%d][%s]: %s' % (timestamp, logconf_name, data)) + + break + + def enable_logging(self): + """ Begins logging all configured logging blocks. This is used from + the controls tab when hitting begin logging. """ + for i in range(0, len(self.logging_configs)): + self.logging_configs[i].start() + + def disable_logging(self): + """ Stops logging all configured logging blocks. This is used from + the controls tab when hitting pause logging. """ + for i in range(0, len(self.logging_configs)): + self.logging_configs[i].stop() + + def delete_log_blocks(self): + for block in self.logging_configs: + block.delete() + self.logging_configs.remove(block) + - def CopyTocToFile(self, toc :dict, isParams): - if isParams: - logType = "Param" - else: - logType = "Log" - - filename = os.getcwd() - filename += f"/logs/cflie1_{logType}_toc_{time.strftime('%Y_%m_%d_%H:%M:%S', time.localtime())}.txt" - # print(f"TOCtoFILE:{filename}") - - types = {'uint8_t' : 0x08, - 'uint16_t' : 0x09, - 'uint32_t' : 0x0A, - 'uint64_t' : 0x0B, - 'int8_t' : 0x00, - 'int16_t' : 0x01, - 'int32_t' : 0x02, - 'int64_t' : 0x03, - 'FP16' : 0x05, - 'float' : 0x06, - 'double' : 0x07} - - file = open(filename, "w") - file.write(f"{logType} ID Type Group Identifier Name\n") - file.close() - file = open(filename, "a") - for group in list(toc.keys()): - for name in list(toc[group].keys()): - file.write(f"{toc[group][name].ident} {types.get(toc[group][name].ctype)} {group} {name}\n") - #print(f" Identity: {toc[group][name].ident} Packet Type:{toc[group][name].pytype} CType:{toc[group][name].ctype} Group:{group} Name:{name}\n") - - - - file.close() - return filename diff --git a/cflib_groundstation/groundstation_socket.py b/cflib_groundstation/groundstation_socket.py index d003fb783..8e769525d 100644 --- a/cflib_groundstation/groundstation_socket.py +++ b/cflib_groundstation/groundstation_socket.py @@ -168,6 +168,7 @@ class MessageTypeID(Enum): #MAX_TYPE_ID = 21 GETLOGFILE_ID = 21 RESPLOGFILE_ID = 22 + LOGBLOCKCOMMAND_ID = 23 diff --git a/cflib_groundstation/main.py b/cflib_groundstation/main.py index 212ed6b46..7b12911f7 100644 --- a/cflib_groundstation/main.py +++ b/cflib_groundstation/main.py @@ -65,6 +65,8 @@ class main(): self.cfConnect.LogBlockCommand() elif msg_type == MessageTypeID.GETLOGFILE_ID.value: self.cfConnect.GetLogFile(command, self.outputQueue) + elif msg_type == MessageTypeID.LOGBLOCKCOMMAND_ID.value: + self.cfConnect.LogBlockCommand(command) @@ -76,8 +78,8 @@ class main(): if __name__ == '__main__': - lf = LogfileHandler() - lf.read_all_active_blocks() - #main().start() + #lf = LogfileHandler() + #lf.read_all_active_blocks() + main().start() \ No newline at end of file -- GitLab