QUB-ASL / bzzz

Quadcopter with ESP32 and RaspberryPi
MIT License
7 stars 1 forks source link

Refactoring Python code (main.py and more) #179

Open alphaville opened 8 months ago

alphaville commented 8 months ago

Describe the solution you'd like

I think our Python code needs some refactoring. Here are some observations from my side:

In get_radio_data_parse_and_send_to_ESP

1.we need to get rid of fake_data and force_send_fake_data

  1. In the same function, return_channel_data should be removed

In main.py

  1. When it comes to printing, we have things like the flag enable_printing_cache_to_screen and print_debug; instead we should be using a logger
  2. Things like rad2deg and euler_angles should be moved to a different file; if we need operations with quaternions and/or angles, we should create a class, or a file with functions.
  3. It feels that the logging system we have is overly complicated: we log the data in 11 different variables and then we pack them in a data frame in a way that is difficult to decipher. We need to see whether we can reuse our DataLogger.
  4. This part where we check the number of consecutive outliers is probably not necessary now because we've implemented filters
  5. Lengthy part of code like this should be organised in functions

See also

jamie-54 commented 8 months ago

Should we try and fix this issue before #109 #118 and #159 or at the same time? I've added some documentation to start to address #118 and made a PR #180 If we are going to refactor the python code it might be worth merging what is done so far in PR #180

alphaville commented 8 months ago

@jamie-54 I suspect this issue may have to be addressed via multiple PRs. We can discuss at our meeting at 16:15 today.