vscode-ev3dev-browser icon indicating copy to clipboard operation
vscode-ev3dev-browser copied to clipboard

Data visualization

Open dlech opened this issue 6 years ago • 8 comments

@ndward wrote:

I just received this related message from a teacher requesting help:

I am a teacher in France, and I have been programming the Lego EV3 with Matlab Simulink for several years. I want to switch to text programming with students on this medium. With the robot, we are working on trying to realize SLAM. For that, I would like to draw a matrix. Matplotlib is not installed on ev3dev. I tried to install it but without success. And even if I could install it, I'm not sure if I can send the terminal back to the PC with "file = sys.stderr". I did not try with the graphic library Pillow, because I do not think this is the most suitable way. For your information, I work with VS Code. My students worked with the Anaconda Spyder suite and I would have liked to use the same environment, but I followed your valuable advice.

dlech avatar Dec 07 '18 17:12 dlech

@marchanderic44 wrote:

Thank you. To complete, I can write in text files (the position of the robot for example). But, how plot this position in real time? with Matplotlib for example or with which tool?

dlech avatar Dec 07 '18 17:12 dlech

Idea:

It looks like it is possible to run Jupyter notebooks in VS Code.

It also looks like it is possible to do real-time plots with matplotlib.

Putting this together, I think one could write some code that runs in a Jupyter notebook in VS Code (on the computer) that A) listens for data from the EV3 over a network connection (UDP packets would be a good way to do this) and B) plots the data received using matplotlib. A separate program would run on the EV3 that collects data and sends it over a network connection to the listening program on the computer.

dlech avatar Dec 07 '18 17:12 dlech

Hy Dlech, It's seem great with matplotlib. But how transfert data from legoEV3 to PC in real time? I can creat a file.txt from position of legoEV3 (for example). When the script is finish, I transfert the file with WINscp (because I use PC and not linux). And after, I can read the file with matplotlib. So, with your link, we can display with matplotlib in real time. But I am not competent to transfert in real time data from legoEV3 to PC in real time. Is not it more complicated with jupyter rather than a threat script in legoEV3?

marchanderic44 avatar Dec 11 '18 10:12 marchanderic44

Jupyter just seems like a nice way to display the plots in VS code instead of in a separate window. But it is not necessary.

Did you look into using network sockets to transfer the data like I suggested? Here is some detailed information: https://docs.python.org/3/howto/sockets.html

dlech avatar Dec 11 '18 22:12 dlech

I did not know, I will try. Thanks

marchanderic44 avatar Dec 12 '18 15:12 marchanderic44

Thank you for your help. I succeeded. Here are the scripts for people interested. ev3.py is the scrit for the ev3: the position of the wheel left and right are sent to the client which is the program on my PC, named graph.py. This last program takes the value of the position of the right wheels and the gauges in the graph x, y via matplotlib in real time. NB: the values ​​of x and y do not correspond to the position of the robot, it is just to test the posibility to make a display of values ​​in real time. real_time.zip

marchanderic44 avatar Dec 14 '18 17:12 marchanderic44

Recommend closing this issue.

bpmerkel avatar Sep 08 '19 20:09 bpmerkel

I succeeded as well. Run the script on the ev3 first, then within vscode. Write the ip address of the ev3 in the input, then the program will graph the live data from the IR sensor within matplotlib on the PC. Thanks so much for the help! ... I used EV3 Micro-Python from Lego Education ir_grapher.zip

pythoncader avatar Aug 01 '20 22:08 pythoncader