dbaldwin / DroneBlocks-Tello-Camera-With-Python-OpenCV

Take photos and record videos with Tello's camera using a browser-based app and DroneBlocks
https://learn.droneblocks.io/p/opencv-python-and-droneblocks-for-tello-camera-control/
Apache License 2.0
21 stars 12 forks source link

Segmentation Fault when running a mission #5

Open jsolderitsch opened 4 years ago

jsolderitsch commented 4 years ago

I am running the mission that is shown in the new DroneBlocks course.

takeoff();
fly("forward", 20, "in");
video('start');
hover(5);
flip("forward");
flip("backward");
video('stop');
hover(5);
yaw("right", 90);
takePhoto();
yaw("left", 180);
takePhoto();
land();

The app.py program crashes with a segmentation fault after the two flip commands execute. Then the Tello lands on its own after a few seconds.

Running on a Mac (latest Catalina build 10.15.2). Python 3.7.5.

dbaldwin commented 4 years ago

Jim, I hope you're doing well. Good to hear from you. Is there any chance you can paste the error or a screenshot of the error so we can take a look? It sounds like there is an issue with stopping the video. Any further info would be helpful. Thanks.

jsolderitsch commented 4 years ago

Hi Dennis,

Here is the tail of the terminal where I was running this:

Mission is: takeoff|fly_forward,20,in|video,start|hover,5|flip_forward|flip_backward|video,stop|hover,5|yaw_right,90|photo|yaw_left,180|photo|land Commands are: ['takeoff', 'fly_forward,20,in', 'video,start', 'hover,5', 'flip_forward', 'flip_backward', 'video,stop', 'hover,5', 'yaw_right,90', 'photo', 'yaw_left,180', 'photo', 'land'] Sending command: b'takeoff' 127.0.0.1 - - [16/Dec/2019 00:07:37] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:38] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:38] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:39] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:39] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:40] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:40] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:41] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:41] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:42] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:42] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:43] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:43] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:44] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:44] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:45] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:45] "GET /status HTTP/1.1" 200 - finished executing command: takeoff with response: ok 127.0.0.1 - - [16/Dec/2019 00:07:46] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:46] "GET /status HTTP/1.1" 200 - Sending command: b'forward 50.8' 127.0.0.1 - - [16/Dec/2019 00:07:47] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:47] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:48] "GET /status HTTP/1.1" 200 - finished executing command: forward 50.8 with response: ok 127.0.0.1 - - [16/Dec/2019 00:07:48] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:49] "GET /status HTTP/1.1" 200 - Sending command: b'command' finished executing command: command with response: ok 127.0.0.1 - - [16/Dec/2019 00:07:49] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:50] "GET /status HTTP/1.1" 200 - Delaying for 5 seconds 127.0.0.1 - - [16/Dec/2019 00:07:50] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:51] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:51] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:52] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:52] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:53] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:53] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:54] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:54] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:55] "GET /status HTTP/1.1" 200 - Sending command: b'command' finished executing command: command with response: ok 127.0.0.1 - - [16/Dec/2019 00:07:55] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:56] "GET /status HTTP/1.1" 200 - Sending command: b'flip f' 127.0.0.1 - - [16/Dec/2019 00:07:56] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:57] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:57] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:58] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:58] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:59] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:07:59] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:00] "GET /status HTTP/1.1" 200 - finished executing command: flip f with response: ok 127.0.0.1 - - [16/Dec/2019 00:08:00] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:01] "GET /status HTTP/1.1" 200 - Sending command: b'flip b' 127.0.0.1 - - [16/Dec/2019 00:08:01] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:02] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:02] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:03] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:03] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:04] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:04] "GET /status HTTP/1.1" 200 - finished executing command: flip b with response: ok 127.0.0.1 - - [16/Dec/2019 00:08:05] "GET /status HTTP/1.1" 200 - 127.0.0.1 - - [16/Dec/2019 00:08:05] "GET /status HTTP/1.1" 200 - stop Segmentation fault: 11

Interestingly, I was able to get a successful mission execution immediately before this attempt. But that was the only time.

The video commands are not shown in this message sequence. Is there another log location to look for?

I did recently update to Catalina 10.5.2 that was released last week.

Running Python 3.7.5.

Here is my pip list:

jjsretina:DroneBlocks-Tello-Camera-With-Python-OpenCV jjs$ pip list Package Version


asgiref 3.2.3 av 6.2.0 Click 7.0 Django 3.0 Flask 1.1.1 image 1.5.27 itsdangerous 1.1.0 Jinja2 2.10.3 MarkupSafe 1.1.1 numpy 1.17.4 opencv-contrib-python 4.1.2.30 opencv-python 4.1.2.30 Pillow 6.2.1 pip 19.3.1 pygame 1.9.6 pytz 2019.3 setuptools 42.0.2 sqlparse 0.3.0 tellopy 0.6.0 Werkzeug 0.16.0 wheel 0.33.6

Hope this helps. I will try again with other missions.

I am doing well otherwise. Still looking for where I can use Tello's in my own courses in an effective way.

I use pyenv to manage my Python environment in case that matters.

Jim

On Dec 16, 2019, at 10:54 AM, Dennis Baldwin notifications@github.com<mailto:notifications@github.com> wrote:

Jim, I hope you're doing well. Good to hear from you. Is there any chance you can paste the error or a screenshot of the error so we can take a look? It sounds like there is an issue with stopping the video. Any further info would be helpful. Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdbaldwin%2FDroneBlocks-Tello-Camera-With-Python-OpenCV%2Fissues%2F5%3Femail_source%3Dnotifications%26email_token%3DAFQFQJDOCILM2GTM3YARE2TQY6QCJA5CNFSM4J3DP6W2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG7FCOA%23issuecomment-566120760&data=02%7C01%7Cjames.j.solderitsch%40villanova.edu%7Cb423199bf4b540f7ed6508d78240325f%7C765a8de5cf9444f09cafae5bf8cfa366%7C0%7C0%7C637121084548642057&sdata=g2ahL7vnNMQsFVjL7GnivLE2DEtys0VeQBQQT5wL920%3D&reserved=0, or unsubscribehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFQFQJH7JQ5YLNCA7MVKGMTQY6QCJANCNFSM4J3DP6WQ&data=02%7C01%7Cjames.j.solderitsch%40villanova.edu%7Cb423199bf4b540f7ed6508d78240325f%7C765a8de5cf9444f09cafae5bf8cfa366%7C0%7C0%7C637121084548642057&sdata=FdUiuQggnjQhng8TcXs%2Bs1PXwYyveFhU4pEhK2z9p4M%3D&reserved=0.

dbaldwin commented 4 years ago

Thanks for this info, Jim. We'll dive into it and see what we can find out. If you have some time after the Holidays let's get on the phone and discuss some ideas about getting this into your courses. Would be good to explore ideas.

jsolderitsch commented 4 years ago

I had some time to investigate this and I find that in the file mission.py found in the lib folder, if I comment out the print("stop") statement (line108) then the segmentation fault does not happen.

I see that if the video action is "start", there was no print statement; but if the action is "stop", there was a Python print statement that was there. Removing it by commenting it out seems to stop the segmentation fault from happening for me.

The only other place in the command processing code where I saw an embedded print statement was for the "hover" command. And there, I see a sleep statement as well.

So I suspect some timing issues around I/O to the console are lurking.

dbaldwin commented 4 years ago

Thanks for your diligence in helping troubleshoot this issue. For now I've removed that line and committed the code. We'll continue to test and see if we can reproduce.

jsolderitsch commented 4 years ago

It's odd that I am the only one reporting this. I am using a late 2019 Macbook Pro with 64GBs of RAM and maybe things are running faster for me than for others so that the timing issue is not reproducible for older hardware. But the error no longer happens for me with the print statement deleted.