Giter Site home page Giter Site logo

pid-analyzer's Introduction

PID-Analyzer 0.52 changes:

  • Fixed the noise plot ranges for better visual comparability with option for custom or auto range
  • slight change to s/n in deconvolution: Gaussian instead of digital s/n

PID-Analyzer

This program reads Betaflight blackbox logs and calculates the PID step response. It is made as a tool for a more systematic approach to PID tuning.

The step response is a characteristic measure for PID performance and often referred to in tuning techniques. For more details read: https://en.wikipedia.org/wiki/PID_controller#Manual_tuning The program is Python based but utilizes Blackbox_decode.exe from blackbox_tools (https://github.com/cleanflight/blackbox-tools) to read logfiles.

As an example: This was the BF 3.15 stock tune (including D Setpoint weight) on my 2.5" CS110: stock tune

This a nice tune I came up with after some testing: good tune

You can even use angle mode, the result should be the same! The program calculates the system response from input (PID loop input = What the quad should do) and output (Gyro = The quad does). Mathematically this is called deconvolution, which is the invers to convolution: Input * Response = Output. A 0.5s long response is calculated from a 1.5s long windowed region of interest. The window is shifted roughly 0.2s to calculate each next response. From a mathematical point of view this is necessary, but makes each momentary response correspond to an interval of roughly +-0.75s.

Any external input (by forced movement like wind) will result in an incomplete system and thus in a corrupted response. Based on RC-input and quality the momentary response functions are weighted to reduces the impact of corruptions. Due to statistics, more data (longer logs) will further improve reliability of the result.

If D Setpoint Transition is set in Betaflight, your tune and thus the response will differ for high RC-inputs. This fact is respected by calculating separate responses for inputs above and below 500 deg/s. With just moderate input, you will get one result, if you also do flips there will be two.

Keep in mind that if you go crazy on the throttle it will cause more distortion. If throttle-PID-attenuation (TPA) is set in Betaflight there will be a different response caused by a dynamically lower P. This is the reason why the throttle and TPA threshold is additionally plotted.

The whole thing is still under development and results/input of different and more experienced pilots will be appreciated!

Requirements

To install required Python libraries, view the list of packages in requirements.txt or simply run:

sudo apt-get install python3-pip python3-tk
sudo pip3 install -r requirements.txt

How to use this program:

  1. Record your log. Logs of 20s seem to give sufficient statistics. If it's slightly windy, longer logs can still give reasonable results. You can record multiple logs in one session: Each entry will yield a seperate plot.
  2. Place your logfiles, blackbox_decode.exe (Windows download) and PID-Analyzer.exe (Windows download) in the same folder. You can also specify where to find these executables via command-line flags.
  3. Run PID-Analyzer.exe (this takes some seconds, it sets up a complete virtual python environment). Either interactively enter your .BBL files (drop one or more logs into cmd), or pass your .BBL file(s) via flags, like PID-Analyzer --log one.BBL --log two.BBL directly when run in cli mode.
  4. The logs are separated into temp files, read, analyzed and temp files deleted again.
  5. A plot window opens and a .png image is saved automatically in the folder correspoding to you entered name (default is \tmp).

The windows executable includes a virtual python environment and only requires you to drag and drop your Betaflight blackbox logfile into the cmd window.

In case of problems (if the cmd closes for example), please report including the log file.

Tested on Win7/10 and MacOS 10.10, with 3.15/3.2/3.3 logs.

Happy tuning,

Flo

pid-analyzer's People

Contributors

lostcontrol avatar markfickett avatar plasmatree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pid-analyzer's Issues

[Feature request] Allow selection of time interval per log to be analysed

Flo Hi,

Thanks for the amazing tool, your work is highly appreciated.
Wanted to check is possible to add option to select time interval for running analysis or providing skip X from beginning + skip Y from end to allow eliminate takeoff / landing + allow analyzing specific part of the log.

Thanks

Making a tutorial about Plastmatree

Sorry but this is the only way I can think of to contact you. I want to make an instructional video about Plastmatree. Can you please get in contact with me to discuss? Your insight would be very helpful.

Crash on mac os with message "string argument without an encoding"

I'm trying to run PID-Analyzer na on the latest MacOs (10.13.4), however, I'm getting following trace:

MartinH:PID-Analyzer haplm$ python3 PID-Analyzer.py --blackbox_decode ./blackbox_decode '-l /Users/haplm/Documents/BTFL_BLACKBOX_LOG_Tyrant_20180505_184347.BBL'
INFO 2018-05-06 16:47:42,793 PID-Analyzer.py:560: Decoding with '/Users/haplm/Development/PID-Analyzer/blackbox_decode'
INFO 2018-05-06 16:47:42,793 PID-Analyzer.py:562: PID-Analyzer 0.31
INFO 2018-05-06 16:47:42,793 PID-Analyzer.py:563: Hello Pilot!
Traceback (most recent call last):
  File "PID-Analyzer.py", line 567, in <module>
    run_analysis(clean_path(log_path), args.name, args.blackbox_decode)
  File "PID-Analyzer.py", line 524, in run_analysis
    test = BB_log(log_file_path, plot_name, blackbox_decode)
  File "PID-Analyzer.py", line 362, in __init__
    self.loglist = self.decode(log_file_path)
  File "PID-Analyzer.py", line 486, in decode
    first_newline_index = content.index(bytes('\n'))
TypeError: string argument without an encoding

blackbox_decode itself seems to be running fine:

MartinH:PID-Analyzer haplm$ ./blackbox_decode --simulate-current-meter /Users/haplm/Documents/BTFL_BLACKBOX_LOG_Tyrant_20180505_184347.BBL
Decoding log '/Users/haplm/Documents/BTFL_BLACKBOX_LOG_Tyrant_20180505_184347.BBL' to '/Users/haplm/Documents/BTFL_BLACKBOX_LOG_Tyrant_20180505_184347.01.csv'...

Log 1 of 2Statistics
E frames       2    8.0 bytes avg       16 bytes total
Frames        0
Data rate: Unknown, no timing information available.

1 iterations are missing in total (0ms, 100.00%)

Decoding log '/Users/haplm/Documents/BTFL_BLACKBOX_LOG_Tyrant_20180505_184347.BBL' to '/Users/haplm/Documents/BTFL_BLACKBOX_LOG_Tyrant_20180505_184347.02.csv'...

Log 2 of 2, start 00:39.777, end 03:08.594, duration 02:28.816

Statistics
Looptime            128 avg            7.5 std dev (5.8%)
I frames    4504   51.6 bytes avg   232315 bytes total
P frames  571875   25.2 bytes avg 14407977 bytes total
E frames       7    5.4 bytes avg       38 bytes total
S frames      78    8.0 bytes avg      624 bytes total
Frames    576379   25.4 bytes avg 14640292 bytes total
Data rate 3873Hz  98420 bytes/s     984300 baud

3 frames failed to decode, rendering 116 loop iterations unreadable. 116 iterations are missing in total (14ms, 0.01%)
576494 loop iterations weren't logged because of your blackbox_rate settings (74407ms, 50.00%)

How to Use - MacOSX

HOW TO RUN PLASMATREE (MAC-OSX)

#Install:
Python 2.7(https://www.python.org/downloads/release/python-2715/
PIP: (https://pip.pypa.io/en/stable/installing/)
Homebrew + Git: (https://gist.github.com/derhuerst/1b15ff4652a867391f03…)
Xcode: (https://itunes.apple.com/us/app/xcode/id497799835)

#Open Terminal - Do:

git clone https://github.com/cleanflight/blackbox-tools.git

cd blackbox-tools

brew install cairo --without-x11 pkg-config

make

cd ..

git clone https://github.com/Plasmatree/PID-Analyzer.git

cd PID-Analyzer

pip install -r requirements.txt

#Normal Use in Terminal:

cd PID-Analyzer

python PID-Analyzer.py --blackbox_decode ../blackbox-tools/obj/blackbox_decode -l (path_to_the_file.BBL)

#path_to_the_file.BBL > Drag and drop log to TERMINAL window

#Hit enter and boom!

Credit: Martin Hapl

Just question

I am sorry for writing this in Issues, but i have no idea how to ask a question about this amazing Analyzer.
I just can't understand how to interpret plot "xxx step response (>500)".
What values are present in this plot and how they correlate with X axis and times on this axis.
Why sometimes it appears, and sometimes not.
I just can't get the point.
Thank you!
log00011tmp_0

Program crash on windows

Would like to give this program a spin :-)
But having an issue with the program crashing. Hope the attached info can help you track it down.

Running Windows 7 Enterprise SP1 64bit.

Anything else just shout and I'll see if I can help out.

image

c:\temp\blackbox>PID-Analyzer_0.31.exe
INFO 2018-05-09 09:18:38,266 PID-Analyzer.py:560: Decoding with 'c:\temp\black
box\Blackbox_decode.exe'
INFO 2018-05-09 09:18:38,266 PID-Analyzer.py:562: PID-Analyzer 0.31
INFO 2018-05-09 09:18:38,266 PID-Analyzer.py:563: Hello Pilot!
INFO 2018-05-09 09:18:38,266 PID-Analyzer.py:572: Interactive mode: Enter log fi
le, or type close when done.
Balckbox log file path (type or drop here): test
Optional plot name:
INFO 2018-05-09 09:19:27,496 PID-Analyzer.py:593: No valid input path!
INFO 2018-05-09 09:19:27,496 PID-Analyzer.py:572: Interactive mode: Enter log fi
le, or type close when done.
Balckbox log file path (type or drop here): C:\temp\blackbox\BTFL_BLACKBOX_LOG_2
0180425_072557.BBL
Optional plot name:test
WARNING 2018-05-09 09:19:34,811 PID-Analyzer.py:518: Ignoring BBL session 'C:\t
emp\blackbox\test\BTFL_BLACKBOX_LOG_20180425_072557_temp0.BBL', 61B < 500000B
.
Decoding log 'C:\temp\blackbox\test\BTFL_BLACKBOX_LOG_20180425_072557_temp1.BBL'
to 'C:\temp\blackbox\test\BTFL_BLACKBOX_LOG_20180425_072557_temp1.01.csv'...

Log 1 of 1, start 00:53.418, end 01:44.549, duration 00:51.130

Statistics
Looptime 511 avg 64.6 std dev (12.6%)
I frames 1537 41.6 bytes avg 63935 bytes total
P frames 96797 24.4 bytes avg 2361992 bytes total
E frames 2 9.0 bytes avg 18 bytes total
S frames 31 4.0 bytes avg 124 bytes total
Frames 98334 24.7 bytes avg 2425927 bytes total
Data rate 1923Hz 47507 bytes/s 475100 baud

1 frames failed to decode, rendering 15 loop iterations unreadable. 294927 itera
tions are missing in total (38345ms, 75.00%)

INFO 2018-05-09 09:19:36,582 PID-Analyzer.py:308: Reading log 0...
PID-Analyzer.py:364: DtypeWarning: Columns (31) have mixed types. Specify dtype
option on import or set low_memory=False.
INFO 2018-05-09 09:19:40,822 PID-Analyzer.py:328: Done!
INFO 2018-05-09 09:19:40,822 PID-Analyzer.py:200: Processing:
INFO 2018-05-09 09:19:40,822 PID-Analyzer.py:302: roll...
INFO 2018-05-09 09:19:41,681 PID-Analyzer.py:302: pitch...
INFO 2018-05-09 09:19:42,411 PID-Analyzer.py:302: yaw...

BTFL_BLACKBOX_LOG_20180425_072557.zip

Closes instantly

This worked not problem an hour ago but now when I try to open it closes instantly. I did the following in cmd and got the below error. Any ideas?

C:\Users\i\Desktop\Quad stuff\BlackBox Tools>PID-Analyzer_0.52.exe
Failed to write all bytes for Cython.Compiler.Code.pyd

The first time this happened restarting my computer fixed it. Now I've restarted 3 times but still this issue persists.

Logging Settings on FC unclear

Missing in the documentation What is the Debug setting needed on the FC, the output seems incorrect.

version

Betaflight / LUXF4OSD (LUX4) 3.4.0 Jul 2 2018 / 12:25:48 (463d7aa1c) MSP API: 1.39

set debug_mode = NOTCH

###ERROR### Invalid value
Allowed values: NONE, CYCLETIME, BATTERY, GYRO_FILTERED, ACCELEROMETER, PIDLOOP, GYRO_SCALED, RC_INTERPOLATION, ANGLERATE, ESC_SENSOR, SCHEDULER, STACK, ESC_SENSOR_RPM, ESC_SENSOR_TMP, ALTITUDE, FFT, FFT_TIME, FFT_FREQ, RX_FRSKY_SPI, GYRO_RAW, DUAL_GYRO, DUAL_GYRO_RAW, DUAL_GYRO_COMBINE, DUAL_GYRO_DIFF, MAX7456_SIGNAL, MAX7456_SPICLOCK, SBUS, FPORT, RANGEFINDER, RANGEFINDER_QUALITY, LIDAR_TF, CORE_TEMP, RUNAWAY_TAKEOFF, SDIO, CURRENT_SENSOR, USB, SMARTAUDIO, RTH, ITERM_RELAX, ACRO_TRAINER, RC_SMOOTHING, RX_SIGNAL_LOSS, RC_SMOOTHING_RATE

Compatibility with KISS

Hello @Plasmatree ,

I just discovered this tool and it looks very interesting so thank you very much for this!
I'm mainly using a KISS FC V2 ATM but I ran into a few issues.
Here is my log (100% log rate, no debug set):
GOPR0173.TXT

I get the following error message:

INFO 2018-04-30 20:33:14,848 PID-Analyzer.py:562: PID-Analyzer 0.31
INFO 2018-04-30 20:33:14,848 PID-Analyzer.py:563: Hello Pilot!
INFO 2018-04-30 20:33:14,848 PID-Analyzer.py:572: Interactive mode: Enter log file, or type close when done.
Balckbox log file path (type or drop here): LOG00015.TXT
Optional plot name:kisstest
WARNING 2018-04-30 20:33:23,625 PID-Analyzer.py:518: Ignoring BBL session '...\\test2\\LOG00015_temp0.TXT', 61B < 500000B.
Decoding log '...\LOG00015_temp1.TXT' to '...\test2\LOG00015_temp1.01.csv'...

Log 1 of 1, start 00:51.011, end 04:07.178, duration 03:16.166

Statistics
Looptime            999 avg           75.4 std dev (7.5%)
I frames    6085   36.9 bytes avg   224832 bytes total
P frames  187419   20.6 bytes avg  3854044 bytes total
E frames       2    9.0 bytes avg       18 bytes total
Frames    193504   21.1 bytes avg  4078876 bytes total
Data rate  986Hz  20943 bytes/s     209500 baud

92 frames failed to decode, rendering 1354 loop iterations unreadable. 2686 iterations are missing in total (2685ms, 1.37%)

INFO 2018-04-30 20:33:25,760 PID-Analyzer.py:308: Reading log 0...
INFO 2018-04-30 20:33:26,469 PID-Analyzer.py:328:       Done!
INFO 2018-04-30 20:33:26,470 PID-Analyzer.py:200: Processing:
Traceback (most recent call last):
  File "PID-Analyzer.py", line 591, in <module>
  File "PID-Analyzer.py", line 524, in run_analysis
  File "PID-Analyzer.py", line 364, in __init__
  File "PID-Analyzer.py", line 381, in _csv_iter
  File "PID-Analyzer.py", line 201, in __init__
  File "PID-Analyzer.py", line 339, in find_traces
ValueError: could not convert string to float:
Failed to execute script PID-Analyzer

the program can not run on window 10

image

there is somthing wrong when I click the PID-Analyzer_0.52.exe to run this program, maybe is the codec problem, but I do know how to fix it.
My system is win 10 1903

Heuristic PID Tuning [Feature Request]

This is a shot in the dark, but if possible, incorporating PID tuning heuristics such as the Cohen-Coon method would be an awesome addition. Trying to interpolate the graphs by eye may be challenging, so adding a heuristic mathematical formula may benefit some. Perhaps a "Suggested PID values" displayed below the users set PID values. I'm no programmer, so I don't exactly have the knowledge to incorporate this into Plasmatree. But I think it would be really helpful, especially to get a base reference to fine-tune from.

Are the new BF features going to function?

I was able to get things working in my mac. The tool is great! I have a question though? Recently there have been a few additions in BF that impact the PIDs. Is it fair to say the PID-Analyzer simulates the PID controller when tabulating the step function charts from the bb log data? Would the recent Iterm_rotation, Throttle_boost, and other changes be accounted for in the tool?

pid analyzer cmd dissapears

Help needed. Installed pid-analyzer as per Joshua bardwell video but cmd box only flashes on and off when I run PID-Analyzer_0.52.exe.
Nothing else happens
Running win 10 64 bit

Freeze dependency versions in requirements.txt

Please freeze requirements.txt with versions so that we can all work from the same versions as you!

Running into some issues getting this installed/having to faff around to get them to work properly.

Clipping logs

Can you add a clipping function? Say setting the amount in seconds that you want analysed? Would be great for logs where you crash or what to run a plasma log but want to do a full log. St the moment I'm flying my plasma run then flipping off the black box and finishing the pack. I run 20x20 FCs so only data flash 🤔

Cant't use on 500Hz

Hi,
I have PWM ESC so I can only 500Hz. All flights even 8 minutes long are "462848B < 500000B".
Logging with 1kHz makes an Exception.
Best Regards,
Radek

c:\Users\IT\Downloads\PID Analyzer>PID-Analyzer_0.52.exe -l C:\Users\IT\Documents\BTTR_BLACKBOX_LOG_iFlight_281_20180630_205838.BBL
INFO 2018-06-30 21:01:41,533 PID-Analyzer_0.52.py:982: Decoding with 'c:\Users\IT\Downloads\PID Analyzer\Blackbox_decode.exe'
INFO 2018-06-30 21:01:41,533 PID-Analyzer_0.52.py:984: PID-Analyzer 0.52
INFO 2018-06-30 21:01:41,533 PID-Analyzer_0.52.py:985: Hello Pilot!
WARNING 2018-06-30 21:01:41,562 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_205838_temp0.BBL', 61B < 500000B.
Decoding log 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_205838_temp1.BBL' to 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_205838_temp1.01.csv'...

Log 1 of 1, start 01:07.604, end 11:02.274, duration 09:54.669

Statistics
Looptime 2047 avg 7.3 std dev (0.4%)
I frames 1135 46.3 bytes avg 52557 bytes total
P frames 35159 29.7 bytes avg 1043498 bytes total
E frames 2 9.0 bytes avg 18 bytes total
S frames 10 7.2 bytes avg 72 bytes total
Frames 36294 30.2 bytes avg 1096055 bytes total
Data rate 61Hz 1847 bytes/s 18500 baud

2 frames failed to decode, rendering 3 loop iterations unreadable. 1 iterations are missing in total (2ms, 0.00%)
254058 loop iterations weren't logged because of your blackbox_rate settings (520333ms, 87.50%)

Decoding log 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_205838_temp2.BBL' to 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_205838_temp2.01.csv'...

Log 1 of 1, start 00:36.045, end 10:45.835, duration 10:09.790

Statistics
Looptime 2047 avg 7.2 std dev (0.4%)
I frames 1163 46.6 bytes avg 54187 bytes total
P frames 36038 29.6 bytes avg 1065853 bytes total
E frames 2 9.0 bytes avg 18 bytes total
S frames 10 7.2 bytes avg 72 bytes total
Frames 37201 30.1 bytes avg 1120040 bytes total
Data rate 61Hz 1841 bytes/s 18500 baud

2 frames failed to decode, rendering 14 loop iterations unreadable. 13 iterations are missing in total (26ms, 0.00%)
260491 loop iterations weren't logged because of your blackbox_rate settings (533564ms, 87.50%)

INFO 2018-06-30 21:01:43,894 PID-Analyzer_0.52.py:676: Reading: Log 0
INFO 2018-06-30 21:01:44,154 PID-Analyzer_0.52.py:356: Processing:
INFO 2018-06-30 21:01:44,154 PID-Analyzer_0.52.py:671: roll...
Traceback (most recent call last):
File "PID-Analyzer_0.52.py", line 989, in
File "PID-Analyzer_0.52.py", line 939, in run_analysis
File "PID-Analyzer_0.52.py", line 781, in init
File "PID-Analyzer_0.52.py", line 798, in _csv_iter
File "PID-Analyzer_0.52.py", line 358, in init
File "PID-Analyzer_0.52.py", line 672, in __analyze
File "PID-Analyzer_0.52.py", line 63, in init
File "PID-Analyzer_0.52.py", line 209, in winstacker
ValueError: setting an array element with a sequence.
Failed to execute script PID-Analyzer_0.52

c:\Users\IT\Downloads\PID Analyzer>C:\Users\IT\Documents\BTTR_BLACKBOX_LOG_iFlight_281_20180630_145404.BBL

c:\Users\IT\Downloads\PID Analyzer>PID-Analyzer_0.52.exe -l C:\Users\IT\Documents\BTTR_BLACKBOX_LOG_iFlight_281_20180630_145404.BBL
INFO 2018-06-30 21:02:54,144 PID-Analyzer_0.52.py:982: Decoding with 'c:\Users\IT\Downloads\PID Analyzer\Blackbox_decode.exe'
INFO 2018-06-30 21:02:54,144 PID-Analyzer_0.52.py:984: PID-Analyzer 0.52
INFO 2018-06-30 21:02:54,144 PID-Analyzer_0.52.py:985: Hello Pilot!
WARNING 2018-06-30 21:02:54,209 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_145404_temp0.BBL', 61B < 500000B.
WARNING 2018-06-30 21:02:54,209 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_145404_temp1.BBL', 462848B < 500000B.
WARNING 2018-06-30 21:02:54,209 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_145404_temp2.BBL', 421888B < 500000B.
WARNING 2018-06-30 21:02:54,209 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_145404_temp3.BBL', 372736B < 500000B.
WARNING 2018-06-30 21:02:54,213 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\IT\Documents\tmp\BTTR_BLACKBOX_LOG_iFlight_281_20180630_145404_temp4.BBL', 315904B < 500000B.
INFO 2018-06-30 21:02:54,213 PID-Analyzer_0.52.py:940: Analysis complete, showing plot. (Close plot to exit.)

c:\Users\IT\Downloads\PID Analyzer>

Unable to run on ubuntu server

Hi!

I'm developing a bot to run this PID-Analzyer (I've been using the bot on my w10 computer without no problems at all). Now, I want to run it on an Ubuntu server result of uname -a:

uname -a
Linux ubuntu 5.3.0-1008-raspi2 #9-Ubuntu SMP Fri Oct 18 13:26:35 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

I've followed the instructions on issue #44 and i'm facing some problems to run it. If I type:

python3 PID-Analyzer.py --blackbox_decode ./blackbox_decode -l /home/ubuntu/bots/plasmatreebot/downloadDir/539011/btfl_004.bbl

the output is:

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(PID-Analyzer.py:24039): Gdk-CRITICAL **: 15:10:16.449: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed

(PID-Analyzer.py:24039): Gdk-CRITICAL **: 15:10:16.458: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
INFO 2019-10-30 15:10:18,283 PID-Analyzer.py:982: Decoding with '/home/ubuntu/bots/plasmatreebot/plasmatreeUnix/PID-Analyzer-master/blackbox_decode'
INFO 2019-10-30 15:10:18,283 PID-Analyzer.py:984: PID-Analyzer 0.52
INFO 2019-10-30 15:10:18,283 PID-Analyzer.py:985: Hello Pilot!
WARNING 2019-10-30 15:10:18,616 PID-Analyzer.py:933: Ignoring BBL session '/home/ubuntu/bots/plasmatreebot/downloadDir/539011/tmp/btfl_004_temp0.bbl', 61B < 500000B.
Decoding log '/home/ubuntu/bots/plasmatreebot/downloadDir/539011/tmp/btfl_004_temp1.bbl' to '/home/ubuntu/bots/plasmatreebot/downloadDir/539011/tmp/btfl_004_temp1.01.csv'...

Log 1 of 1, start 00:41.348, end 02:02.831, duration 01:21.483

Statistics
Looptime            540 avg           69.7 std dev (12.9%)
I frames    2320   60.1 bytes avg   139353 bytes total
P frames  146077   30.4 bytes avg  4437172 bytes total
E frames       1    6.0 bytes avg        6 bytes total
S frames      11    4.4 bytes avg       48 bytes total
Frames    148397   30.8 bytes avg  4576525 bytes total
Data rate 1821Hz  56224 bytes/s     562300 baud

2 frames failed to decode, rendering 43 loop iterations unreadable. 445290 iterations are missing in total (61115ms, 75.00%)

INFO 2019-10-30 15:10:29,135 PID-Analyzer.py:676: Reading: Log 0
WARNING 2019-10-30 15:10:32,480 PID-Analyzer.py:715: No D[2] trace found!
INFO 2019-10-30 15:10:32,491 PID-Analyzer.py:356: Processing:
INFO 2019-10-30 15:10:32,501 PID-Analyzer.py:671: roll...   
INFO 2019-10-30 15:10:47,644 PID-Analyzer.py:671: pitch...   
Killed

as you can see, it says "Killed" after start analizing pitch ...

The log file i'm using is
btfl_004.zip

Can we please get a Mac version?

I can't seem to get the Mac to run it despite following the instructions. I'm not a power user. My Mac seems to have issues with homebrew which is a project within itself to fix.

Can't read logs with I/D set to zero

I'll be brief))
I started to tune quadcopter, set PIDs to 45/0/0 for both roll and pitch.
Now i faced this error - KeyError: 'axisD[0]'
Log attached.
Betaflight 3.3.2. It seems decoded csv (as bfl itself) does not contain fields for P,I,D if set them to zero.
LOG00018.zip

Noise plot frequency offset

image
On the above picture I have a static notch at 365Hz with cutoff at 300, yet the attenuated "line" shows at 320ish. (first plot zoomed in) The static notches are always off. In BB explorer they are at the correct frequency. Are all noise plots offset?

Can the executables be added as GitHub releases?

Rather than using dropbox, can the releases be distributed using the 'Releases' functionality on github? Seems like it would probably yield faster download times :)

Thank you for such an excellent analytical tool!

No result generated

Hi

i tried to .bbl files, but PT just wont generate a result. It works on .bfl files though
Dont know if its related...
PT shows this:
WARNING 2018-08-27 12:38:28,088 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\js\OneDrive\Quadcopter\PID Analyser\tmp\btfl_000_temp0.bbl', 61B < 500000B.
WARNING 2018-08-27 12:38:28,088 PID-Analyzer_0.52.py:933: Ignoring BBL session 'C:\Users\js\OneDrive\Quadcopter\PID Analyser\tmp\btfl_000_temp1.bbl', 497664B < 500000B.
INFO 2018-08-27 12:38:28,088 PID-Analyzer_0.52.py:940: Analysis complete, showing plot. (Close plot to exit.)
INFO 2018-08-27 12:38:28,089 PID-Analyzer_0.52.py:999: Interactive mode: Enter log file, or type close when done.

Attached the logfile
btfl_000.zip
(just Motor and logging Test (no props, armed, RC Input) , no flight)

Thanks
Jan
PS: Thank you so much for the effort put into this tool !

Higher version python cannot run ?

Hi, I use python3.11.0, and after several tried I found that mention if I need run under python3.5 or 3.6?
After that, I finish the environment configuration. However, the program stuck here all the time.
Snipaste_2022-12-27_00-00-19

Snipaste_2022-12-26_23-49-01

Unable to analyze file (Blackbox app read it)

Hi,
I have this output:
`vinz@xpvinz:~/bin/PID-Analyzer$ ./PID-Analyzer.py --blackbox_decode blackbox_decode -l BTFL_BLACKBOX_LOG_Diatone_20180805_121933.BBL -n test
INFO 2018-08-05 12:50:01,809 PID-Analyzer.py:982: Decoding with '/home/vinz/bin/PID-Analyzer/blackbox_decode'
INFO 2018-08-05 12:50:01,809 PID-Analyzer.py:984: PID-Analyzer 0.52
INFO 2018-08-05 12:50:01,809 PID-Analyzer.py:985: Hello Pilot!
WARNING 2018-08-05 12:50:01,824 PID-Analyzer.py:933: Ignoring BBL session '/home/vinz/bin/PID-Analyzer/test/BTFL_BLACKBOX_LOG_Diatone_20180805_121933_temp0.BBL', 61B < 500000B.
Decoding log '/home/vinz/bin/PID-Analyzer/test/BTFL_BLACKBOX_LOG_Diatone_20180805_121933_temp1.BBL' to '/home/vinz/bin/PID-Analyzer/test/BTFL_BLACKBOX_LOG_Diatone_20180805_121933_temp1.01.csv'...

Log 1 of 1, start 00:12.799, end 00:53.980, duration 00:41.181

Statistics
Looptime 508 avg 64.5 std dev (12.7%)
I frames 1246 39.2 bytes avg 48848 bytes total
P frames 78415 20.5 bytes avg 1610954 bytes total
E frames 2 9.0 bytes avg 18 bytes total
S frames 6 4.0 bytes avg 24 bytes total
Frames 79661 20.8 bytes avg 1659802 bytes total
Data rate 1934Hz 40394 bytes/s 404000 baud

1 frames failed to decode, rendering 44 loop iterations unreadable. 239084 iterations are missing in total (30889ms, 75.01%)

Decoding log '/home/vinz/bin/PID-Analyzer/test/BTFL_BLACKBOX_LOG_Diatone_20180805_121933_temp2.BBL' to '/home/vinz/bin/PID-Analyzer/test/BTFL_BLACKBOX_LOG_Diatone_20180805_121933_temp2.01.csv'...

Log 1 of 1, start 02:23.620, end 02:56.491, duration 00:32.871

Statistics
Looptime 509 avg 64.7 std dev (12.7%)
I frames 992 39.5 bytes avg 39170 bytes total
P frames 62462 20.6 bytes avg 1287746 bytes total
E frames 2 9.0 bytes avg 18 bytes total
S frames 5 4.0 bytes avg 20 bytes total
Frames 63454 20.9 bytes avg 1326916 bytes total
Data rate 1930Hz 40464 bytes/s 404700 baud

1 frames failed to decode, rendering 20 loop iterations unreadable. 190292 iterations are missing in total (24650ms, 74.99%)

INFO 2018-08-05 12:50:02,870 PID-Analyzer.py:676: Reading: Log 0
Traceback (most recent call last):
File "./PID-Analyzer.py", line 989, in
run_analysis(clean_path(log_path), args.name, args.blackbox_decode, args.show, args.noise_bounds)
File "./PID-Analyzer.py", line 939, in run_analysis
test = BB_log(log_file_path, plot_name, blackbox_decode, show, noise_bounds)
File "./PID-Analyzer.py", line 781, in init
self.figs = self._csv_iter(self.heads)
File "./PID-Analyzer.py", line 798, in _csv_iter
analysed = CSV_log(h['tempFile'][:-3]+'01.csv', self.name, h, self.noise_bounds)
File "./PID-Analyzer.py", line 354, in init
self.data = self.readcsv(self.file)
File "./PID-Analyzer.py", line 692, in readcsv
data = read_csv(fpath, header=0, skipinitialspace=1, usecols=lambda k: k in wanted, dtype=np.float64)
File "/usr/lib/python2.7/dist-packages/pandas/io/parsers.py", line 498, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/lib/python2.7/dist-packages/pandas/io/parsers.py", line 275, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/usr/lib/python2.7/dist-packages/pandas/io/parsers.py", line 590, in init
self._make_engine(self.engine)
File "/usr/lib/python2.7/dist-packages/pandas/io/parsers.py", line 731, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/usr/lib/python2.7/dist-packages/pandas/io/parsers.py", line 1103, in init
self._reader = _parser.TextReader(src, **kwds)
File "pandas/parser.pyx", line 412, in pandas.parser.TextReader.cinit (pandas/parser.c:3796)
TypeError: 'function' object is not iterable
`
Log contains 2 seessions: 1 in angle and 1 in acro, recorded at 2khz on Betaflight 3.4.1.

If I open the log with blackbox app I see the data and all it's ok.

BTFL_BLACKBOX_LOG_Diatone_20180805_121933.BBL.zip

Thank you for this interesting project and for your help!

cmd crashes

when i try with the "example_smooth_tune.BBL" example file (or any of my own BBL files)
the pid-analyzer crashes while trying to generate the first .png file

Reading log 0... Done!
Processing:
roll... Done!
pitch... Done!
yaw... Done!

following files get created in the directory

example_smooth_tune_temp1.BBL gets created (2mb)
example_smooth_tune_temp1.01.csv gets created (15mb)
example_smooth_tune_temp1.01.event gets created (154 bytes)
example_smooth_tune_0.png gets created .... with a filesize of 0

do i just need some sort of Plot/gnuplot for windows ? or do i have to ditch my windows 7 PC for a new one ...

ps: thanks for the nice work you done with this tool.

[Feature request]: add response time info

I don't know if it is feasible to add the time that the quad needs to arrive from 0 to 1 in the strength vs response time graphs, for both curves. More or less we can now the value, but to compare two graphs a precision number will be better. Maybe next to the graph and not inside?

Thanks for your great app!!!!

image

ValueError: could not convert string to float (on some INAV logs)

With some of INAV logs the analysis ends with "ValueError: could not convert string to float" error.
I observe this on all long logs. Really short ones seem to work fine (not sure if it is related).

I'm following this way of running the analyzer on mac: #15

$ python PID-Analyzer.py --blackbox_decode ../blackbox-tools/obj/blackbox_decode -l /Users/km/Desktop/LOG00090.TXT 
INFO 2018-06-17 11:55:02,194 PID-Analyzer.py:982: Decoding with '/Users/km/dev/pid-analyzer/blackbox-tools/obj/blackbox_decode'
INFO 2018-06-17 11:55:02,194 PID-Analyzer.py:984: PID-Analyzer 0.52
INFO 2018-06-17 11:55:02,194 PID-Analyzer.py:985: Hello Pilot!
WARNING 2018-06-17 11:55:02,218 PID-Analyzer.py:933: Ignoring BBL session '/Users/km/Desktop/tmp/LOG00090_temp0.TXT', 61B < 500000B.
Decoding log '/Users/km/Desktop/tmp/LOG00090_temp1.TXT' to '/Users/km/Desktop/tmp/LOG00090_temp1.01.csv'...

Log 1 of 1, start 00:45.453, end 03:26.180, duration 02:40.727

Statistics
Looptime            503 avg            7.3 std dev (1.5%)
I frames    9882   96.0 bytes avg   949046 bytes total
P frames  148152   49.0 bytes avg  7261372 bytes total
H frames      79   11.0 bytes avg      869 bytes total
G frames     867   17.5 bytes avg    15172 bytes total
E frames       1    6.0 bytes avg        6 bytes total
S frames     126    8.0 bytes avg     1008 bytes total
Frames    158034   52.0 bytes avg  8210418 bytes total
Data rate  983Hz  51242 bytes/s     512500 baud

17 frames failed to decode, rendering 128 loop iterations unreadable. 1371 iterations are missing in total (691ms, 0.43%)
159404 loop iterations weren't logged because of your blackbox_rate settings (80363ms, 50.00%)

INFO 2018-06-17 11:55:05,572 PID-Analyzer.py:676: Reading: Log 0
WARNING 2018-06-17 11:55:06,376 PID-Analyzer.py:702: No debug[0] trace found!
WARNING 2018-06-17 11:55:06,376 PID-Analyzer.py:702: No debug[1] trace found!
WARNING 2018-06-17 11:55:06,378 PID-Analyzer.py:702: No debug[2] trace found!
WARNING 2018-06-17 11:55:06,378 PID-Analyzer.py:715: No D[2] trace found!
INFO 2018-06-17 11:55:06,379 PID-Analyzer.py:356: Processing:
Traceback (most recent call last):
  File "PID-Analyzer.py", line 989, in <module>
    run_analysis(clean_path(log_path), args.name, args.blackbox_decode, args.show, args.noise_bounds)
  File "PID-Analyzer.py", line 939, in run_analysis
    test = BB_log(log_file_path, plot_name, blackbox_decode, show, noise_bounds)
  File "PID-Analyzer.py", line 781, in __init__
    self.figs = self._csv_iter(self.heads)
  File "PID-Analyzer.py", line 798, in _csv_iter
    analysed = CSV_log(h['tempFile'][:-3]+'01.csv', self.name, h, self.noise_bounds)
  File "PID-Analyzer.py", line 357, in __init__
    self.traces = self.find_traces(self.data)
  File "PID-Analyzer.py", line 761, in find_traces
    dic.update({'P':float((self.headdict[dic['name']+'PID']).split(',')[0])})
ValueError: could not convert string to float: 

Example problematic log:
LOG00090.TXT

Noisy band(s) - what gives?

Hey,

I wasn't sure where to post this on forums to get some feedback on a noisy frequency that is constant throughout the throttle range. Something motor related would IMO give noise at increasing frequency (as the throttle increase), but not here.

I've installed another FC with the same results (different model, different electrical source as well). I'll swap out ESC's and motors next but I thought I'd ask if this is something anyone has an explanation for.

thanks!
Cheers

image

provide cli only interface

Something that doesn't require X11 or WinGDIBlahFoo.

Then we can put it in docker and now from end users point of view, docker is the runtime not python. cross platform problem avoided.

Possible feature request

Hey,

First let me say thank you for this pretty awesome piece of software. I have been using for several months and I am glad to see it gaining interest lately.

I've personally been using the PID analyzer to analyze vibration more than PID tune and found that to some extend it was possible even though it wasn't really designed for it. The new filter/noise graphs are very helpful and pretty intuitive to analyze.

Back to the PID graphs, I like how you separated the slow and fast input on the bottom graphs, and I am wondering if something similar could be done (to this graph or new ones) in order to help tuning TPA. I know you recommend to turn off as many parameters as possible for the initial tune and I get that. But I am wondering if overlaying several gyro responses for different throttle value could help figuring out some of the vibrations caused at various throttle ranges.

I haven't looked at your code but I suppose it should be possible to input a throttle range in the command line such as: Min Throttle, Max Throttle. With default set to 1000 and 2000, that way someone who doesn't care about this could get the analysis done on the full range, and those who are trying to refine the tune around a specific throttle range could be able to set their min and max and get an analysis that is more focused around this range.

I definitely like the direction you're heading with the new Noise graphs. While I feel like PID tuning is probably easier now than before (thanks to Plasmatree and improvements of the firmware/PID loops, etc) some vibrations due resonance, or various mechanical problems can be tricky to solve, and good analysis tools can go a long way.

Cheers,

waterfall chart to show response?

I was interested to see how the response data would look in a waterfall type chart.
With the color mapping on the 2d chart, it is difficult for me to tell what the values are just by the color.
On the waterfall, I can't say it is much better with the 3d perspective, but the change in height stands out more to me.
Other problem with 3d waterfall (and viewing from fixed angle) is there will always be obstructed view of some of the data.

In the attachment, the bottom chart averages out close to 1.0, but can't tell the initial overshoot is increasing at higher throttle.
The second chart shows this with increasing light green and yellow at the bottom.
Is the waterfall (3rd chart) having the peaks stand out more?

Maybe if it was larger on another page and showing from 2 angles?
But if this chart is included it takes graphs longer to draw so should be optional.

I have some example code if it is of any use to include in some way.
But I am not a python developer so it would need some tuning.

Second attachment shows chart with X, Y (response time, throttle) swapped.

screen shot 2019-02-20 at 12 26 16 pm


screen shot 2019-02-20 at 12 26 41 pm

windows versions not run

I can not run any of the available windows versions on windows 10. The same error always comes out. A small blue screen that says "this application can not be run on the computer, check with the software editor"

Error run_analysis(clean_path(log_path), args.name, args.blackbox_decode)

Today i problem version 0.5 not runing on macbook ,
The old version 0.3 is work.

TRUNGs-MacBook-Pro:PID-Analyzer_old1 root# ./PID-Analyzer.py --blackbox_decode ./blackbox_decode -l /Volumes/DATA2/BetaFlight/PID-Analyzer_old1/BTFL_BLACKBOX_LOG_20180512_171144.BBL
INFO 2018-05-20 17:34:40,180 PID-Analyzer.py:926: Decoding with '/Volumes/DATA2/BetaFlight/PID-Analyzer_old1/blackbox_decode'
INFO 2018-05-20 17:34:40,180 PID-Analyzer.py:928: PID-Analyzer 0.50
INFO 2018-05-20 17:34:40,180 PID-Analyzer.py:929: Hello Pilot!
Traceback (most recent call last):
File "./PID-Analyzer.py", line 933, in
run_analysis(clean_path(log_path), args.name, args.blackbox_decode)
TypeError: run_analysis() takes exactly 4 arguments (3 given)
TRUNGs-MacBook-Pro:PID-Analyzer_old1 root#

ZeroDivisionError: integer division or modulo by zero

I use inav 2.6 for a flywing, it does not have Vertical tail,and i use analyzer,it has a error in the end.
log like this :

E:\plane\pid>PID-Analyzer_0.52.exe
INFO 2021-03-21 13:16:27,247 PID-Analyzer_0.52.py:982: Decoding with 'E:\plane\pid\Blackbox_decode.exe'
INFO 2021-03-21 13:16:27,247 PID-Analyzer_0.52.py:984: PID-Analyzer 0.52
INFO 2021-03-21 13:16:27,249 PID-Analyzer_0.52.py:985: Hello Pilot!
INFO 2021-03-21 13:16:27,250 PID-Analyzer_0.52.py:999: Interactive mode: Enter log file, or type close when done.
Blackbox log file path (type or drop here): E:\plane\LOGS\blackbox_log_2021-03-20_223928.TXT
Optional plot name:210321
Show plot window when done? [Y]/NY
Bounds on noise plot: [default/last] | copy and edit | "auto"
Current: [[1.0, 10.1], [1.0, 100.0], [1.0, 100.0], [0.0, 4.0]]

WARNING 2021-03-21 13:17:44,729 PID-Analyzer_0.52.py:933: Ignoring BBL session 'E:\plane\LOGS\210321\blackbox_log_2021-03-20_223928_temp0.TXT', 61B < 500000B.
Decoding log 'E:\plane\LOGS\210321\blackbox_log_2021-03-20_223928_temp1.TXT' to 'E:\plane\LOGS\210321\blackbox_log_2021-03-20_223928_temp1.01.csv'...

Log 1 of 1, start 06:23.683, end 09:57.071, duration 03:33.388

Statistics
Looptime 1002 avg 0.5 std dev (0.1%)
I frames 1651 111.5 bytes avg 184075 bytes total
H frames 78 11.0 bytes avg 858 bytes total
G frames 6422 27.1 bytes avg 174223 bytes total
E frames 1 7.0 bytes avg 7 bytes total
S frames 2176 43.7 bytes avg 94995 bytes total
Frames 1651 111.5 bytes avg 184075 bytes total
Data rate 7Hz 6458 bytes/s 64600 baud

112 frames failed to decode, rendering 8165 loop iterations unreadable. 12 iterations are missing in total (12ms, 0.01%)
211074 loop iterations weren't logged because of your blackbox_rate settings (211719ms, 99.22%)

INFO 2021-03-21 13:17:45,016 PID-Analyzer_0.52.py:676: Reading: Log 0
WARNING 2021-03-21 13:17:45,038 PID-Analyzer_0.52.py:702: No debug[0] trace found!
WARNING 2021-03-21 13:17:45,039 PID-Analyzer_0.52.py:702: No debug[1] trace found!
WARNING 2021-03-21 13:17:45,039 PID-Analyzer_0.52.py:702: No debug[2] trace found!
WARNING 2021-03-21 13:17:45,040 PID-Analyzer_0.52.py:715: No D[2] trace found!
INFO 2021-03-21 13:17:45,042 PID-Analyzer_0.52.py:356: Processing:
INFO 2021-03-21 13:17:45,042 PID-Analyzer_0.52.py:671: roll...
Traceback (most recent call last):
File "PID-Analyzer_0.52.py", line 1027, in
File "PID-Analyzer_0.52.py", line 939, in run_analysis
File "PID-Analyzer_0.52.py", line 781, in init
File "PID-Analyzer_0.52.py", line 798, in _csv_iter
File "PID-Analyzer_0.52.py", line 358, in init
File "PID-Analyzer_0.52.py", line 672, in __analyze
File "PID-Analyzer_0.52.py", line 63, in init
File "PID-Analyzer_0.52.py", line 202, in winstacker
ZeroDivisionError: integer division or modulo by zero
blackbox_log_2021-03-20_223928.TXT

Failed to execute script PID-Analyzer_0.52

blackbox_log_2021-03-20_223928.TXT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.