Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with running the code #2

Closed
xPew opened this issue Nov 22, 2021 · 26 comments
Closed

Issues with running the code #2

xPew opened this issue Nov 22, 2021 · 26 comments

Comments

@xPew
Copy link

xPew commented Nov 22, 2021

@dans98 I tried to set up gLapse, but without success. I can only follow instructions as a non coder, I need some help with troubleshooting…

So I followed the installation points precisely as described here in order. Even tried with a completely fresh raspbian image on a new SD card, but I het the following error
IMG_4556
:

What am I doing wrong? I modified the setting according to my IP and pw, otherwise I ran it with the stock settings. I have an updated RPi 4B with a cloned V2 Pi camera from this vendor: https://www.aliexpress.com/item/33053692639.html?spm=a2g0o.productlist.0.0.46ed659f9ySinD&algo_pvid=0ccf4d8e-71ba-461f-b951-ba3b7d8abbfe&algo_exp_id=0ccf4d8e-71ba-461f-b951-ba3b7d8abbfe-15&pdp_ext_f=%7B%22sku_id%22%3A%2267439351246%22%7D

Thank you for your help!

@xPew xPew changed the title Issues witt running the code Issues with running the code Nov 22, 2021
@dans98
Copy link
Owner

dans98 commented Nov 23, 2021

I've not personally ever seen that issue.

what os version are you running? are you running the 64 bit version, mmal isn't supported in the 64 bit version!
waveform80/picamera#672

running Bullseye looks to be a potential iss as well if you are using it.
https://forums.raspberrypi.com/viewtopic.php?t=319393

the best way to check if it's a hardware or underlying os issue, is to see if raspistill and raspivid work!
https://www.raspberrypi.com/documentation/accessories/camera.html#raspistill
https://www.raspberrypi.com/documentation/accessories/camera.html#raspivid

@xPew
Copy link
Author

xPew commented Nov 25, 2021

Thank you for your help @dans98 !
I downloaded the os from here: https://www.raspberrypi.com/software/operating-systems/

Raspberry Pi OS with desktop
Release date: October 30th 2021
Kernel version: 5.10

It should work, or can you link what you use? Before this timelapse code I tried duetlapse and ustreamer and they both could access the camera, and raspistill worked fine. That was on an another istall, here I used a brand new SD card. I am not sure what Bullseye is, but in that case I guess I dont need to worry about…

What can I do if my hardware seems ok?

@dans98
Copy link
Owner

dans98 commented Nov 29, 2021

Release date: October 30th 2021 Kernel version: 5.10

That's most likely the issue! 5.10 on 10/30/2021 is the first release of bullseye, and as i linked to previously it has issues.

You can see the releases here.
https://en.wikipedia.org/wiki/Raspberry_Pi_OS

Try one of the buster release and see if that fixes things!

@xPew
Copy link
Author

xPew commented Nov 29, 2021

Release date: October 30th 2021 Kernel version: 5.10

That's most likely the issue! 5.10 on 10/30/2021 is the first release of bullseye, and as i linked to previously it has issues.

You can see the releases here. https://en.wikipedia.org/wiki/Raspberry_Pi_OS

Try one of the buster release and see if that fixes things!

I will check it, thank you! Is this a Pi camera hardware/software limitation, or a current limitation with this code? Can you update this code (in the future, not asap :) ) or I will need to avoid updating the os after I vot this setup working? Sorry, I am not that familiar with these different releases, I just like to understand the root of this problem.

@dans98
Copy link
Owner

dans98 commented Nov 29, 2021

I will check it, thank you! Is this a Pi camera hardware/software limitation, or a current limitation with this code? Can you update this code (in the future, not asap :) ) or I will need to avoid updating the os after I vot this setup working? Sorry, I am not that familiar with these different releases, I just like to understand the root of this problem.

It's an issue with with pi os itself. The dev team changed something significant and didn't tell anyone. have a look at this.
https://forums.raspberrypi.com/viewtopic.php?t=323390

@dans98
Copy link
Owner

dans98 commented Nov 29, 2021

@xPew it looks like a fix has been implemented so that picamera will work in the future, but it will take some time for it to make it into an official release.

https://forums.raspberrypi.com/viewtopic.php?t=323390&start=25#p1942967

@xPew
Copy link
Author

xPew commented Nov 29, 2021

@dans98 I see. Until that I will try to set up and get familiar with gLapse on an older version. Thank you! :)
I will close this when I got that setup working, just to be able to ask if I got into any issue.

@xPew
Copy link
Author

xPew commented Nov 30, 2021

@dans98 Still getting some error…
Used this release I found: https://downloads.raspberrypi.org/raspbian/images/raspbian-2020-02-14/
Followed everything in your readme, except the os update to latest.
Error:
B4040FBA-5EDD-4F77-ADBF-D60E4FD0C631

Any clue? :/

@dans98
Copy link
Owner

dans98 commented Nov 30, 2021

what does your setting.py look like?

@xPew
Copy link
Author

xPew commented Nov 30, 2021

what does your setting.py look like?

I only modified the IP and password of my printer. The rest is default.
As far as I can tell it succesfully connected to my printer, the error popped up exactly when I wanted to snap a photo.

@dans98
Copy link
Owner

dans98 commented Nov 30, 2021

The stock settings.py is set up for an hq camera module. Your are running the v2 camera module, so you probabbly need to change the below

initialCameraSettings = {
'sensor_mode' : 3,
'resolution' : '3840x2160',
'framerate' : 10
}

to something like this.

initialCameraSettings = {
'sensor_mode' : 2,
'resolution' : '3280x2464',
'framerate' : 10
}

You were asking for a resolution greater than what your sensor module can capture, so it was most likely try to scale the image after the fact and running the gpu out of ram.

on this page search for "sensor mode" and you will see the different modes available for the different sensors!
https://www.raspberrypi.com/documentation/accessories/camera.html#hardware-specification

you could allocate more memory to the gpu, but you won't gain anything. In general you never want to upscale the image.
https://www.raspberrypi.com/documentation/computers/config_txt.html#gpu_mem

@xPew
Copy link
Author

xPew commented Nov 30, 2021

Oh… Will try with the proper settings in the moorning! Thank you for your patience!

@xPew
Copy link
Author

xPew commented Nov 30, 2021

@dans98 Well half success.
First I tried the modifications that you suggested. 4k resolution woth mode 2. I still get the error. I even tried mode 3 (on the linked site mode 2 and 3 has the same resolution for wathever reason).
Error:
3A149D66-1430-439B-B27A-6D8810106F5D

So I switched to fullHD res and mode 1. With this config the script seems fine. I just get bad photos with the stock settings, see below:
982FBD65-59DB-4B46-ABA6-DC165CEB45E5
But I guess tune the different camera setting will improve the quality. The sensor is fine, I played around with DuetLapse and uStreamer in the past and it got a really nice and crisp image when tuned well.
Any suggestion what to modify first? And anyc,clue about te 4k incompatibility? I have a RPi4B 2GB ram version…

@xPew
Copy link
Author

xPew commented Nov 30, 2021

Also did some further testing with Bullseye. The script still dont work, as expected. Raspistill is gone, but libcamera is working properly, and produces a really nice image out of the box without any parameters given.

@dans98
Copy link
Owner

dans98 commented Nov 30, 2021

@dans98 Well half success. First I tried the modifications that you suggested. 4k resolution woth mode 2. I still get the error.

That's for sure the gpu running out of memory

So I switched to fullHD res and mode 1. With this config the script seems fine. I just get bad photos with the stock settings,

If you are just using what's currently in settings.py That probably won't work for you environment, as its locking stuff down to ensure consistent results over time.

Try this out.

swap what you have in settings currently with this. This will put the camera in full auto mode!

initialCameraSettings = {
'sensor_mode' : 2,
'resolution' : '3280x2464',
'framerate' : 10
}

cameraWarmupSettings = {
}

cameraSettings = {
}

cameraCaptureSettings = {
'format' : 'jpeg',
'quality' : 100,
}

and add this to the bottom of your /boot/config.txt to give the gpu more memory!

gpu_mem=256

I just took this with a raspberry pi zero W and a V2 camera module in my office, with the settings above! and manually triggered it in the DWC by sending

M291 p"gLapseInitialize" S2

and then

M291 P"gLapseCapture" S2

000001

but libcamera is working properly

Thas to be expected as libcamera uses all the new underlying architecture that they just released.

@xPew
Copy link
Author

xPew commented Dec 1, 2021

Meanwhile I was able to find the latest stable Buster release. I will use this until the mmal problems are resolved with Bullseye.
The full auto mode seems to produce an acceptable baseline. Nothing really fancy, as I saw this module is capable of, but from here I can play with the individual settings like on a phone, proper camera? Also I will need to manually adjust the focus as well, right?
If you mentioned the piw does it capable of running this script reliably for a long print? I am thinking about changing to a pi 2 w so it would be good to know.
Thank you for your kind troubleshooting and patience! I really like that its a minimalist setup, with a proper settings.txt and the rest is on the slicer settings... Thankfully now I can use this properly :)

@xPew
Copy link
Author

xPew commented Dec 1, 2021

Hopefully a last question... How can I set up this to work after startup?
I tried the mentioned method, but nothing seems to happen...
Used this script in rc.local: sudo python3 /home/pi/code/gLapse/main.py > /home/pi/code/gLapse/log.txt 2>&1 &
I changed the /home/pi/directory where I copied the folder.
If I start the script manually all works fine as mentioned above. If I reboot the pi (after I verified the rc.local was succesfullyy modified) it does nothing. I try to initialise and capture from DWC but I cant...
I found the log.txt and it say: HTTP 599: Unknown

by manually execute it: sudo /etc/rc.local it works
After this command no manual start op main.py needed, it can be initialized and captures can be taken from DWC

@dans98
Copy link
Owner

dans98 commented Dec 1, 2021

Nothing really fancy, as I saw this module is capable of, but from here I can play with the individual settings like on a phone, proper camera?

You have a ton of settings at your disposal, more like a fully fledged DSLR camera, than a phone!

Also I will need to manually adjust the focus as well, right?

That's correct!

If you mentioned the piw does it capable of running this script reliably for a long print?

Yea, a Zero W is more than capable of running indefinitely. The Zero 2 W is even more capable. Taking and saving the photos isn't very hard on the pi, what makes the pi work hard is connecting to the duet api several times a second!

Hopefully a last question... How can I set up this to work after startup?
Post a copy of your rc.local.

also what do you have for this setting?

raspi-config > System Options > Network at Boot

@xPew
Copy link
Author

xPew commented Dec 1, 2021

@dans98 I think it was turned off, but now I ticked the box to wait for network. But I get the same behavior, except the Pi boots up slower
The log.txt is generating with the proper timstamp upon every reboot, so its like half working…
The error code is the same MTTP 599: Unknown
Still upon manual sudo python3 main.py everything works :/

@dans98
Copy link
Owner

dans98 commented Dec 1, 2021

@xPew Is the printer powering on at the same time?

an http 599 response code is pretty rare, and is usually related to not being able to connect to the requested machine.

One thing you can do quickly is up the wait time in settings.py

wait - How many seconds after start-up should the application wait before trying to connect to the printer. This setting is useful if the Printer and Pi run off the same power supply, and the Pi starts up faster than the printer.

@xPew
Copy link
Author

xPew commented Dec 1, 2021

@dans98 For now while I test it the pi isn't connected to the printers power.
The printer is powered on, connected to my network. And parallel to that I power on the pi and while the printer stays on for the whole time I tried booting and rebooting the pi.
I saw the wait time but in this case it's useless right?

@dans98
Copy link
Owner

dans98 commented Dec 1, 2021

It might help.

also, can you post a copy of your rc.local?

@xPew
Copy link
Author

xPew commented Dec 1, 2021

@dans98 I commented out the IP display, not to cause any trouble, also I dont really need it.
The capital C in Code is intentional, thats how I named my folder. Also changed the gLapse-main to simply gLapse as you did.
image

The wierd thing that it should work. If I execute this exact code when its booted gLapse works well. But somehow its not executing or I dont really know...
I even found this guide: https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd
Followed the steps to enable it in case its not. It didnt helped. Maybe its for a different linux distro and its not compatible, but I didnt run into issues along the guide.

@xPew
Copy link
Author

xPew commented Dec 1, 2021

Oh. It seems that the wait time really did the trick... The Pi's connection before startup wasnt enough but an additional 15 sec wait time was so with gLapse.
All good for now. Thank you again. At least I've learned a lot about my Pi but for my best. I ended up switching from a desktop Pi to an SSH setup, and thats a huge step for me :D

If you be aware of the Bullseye fix, and happen to have time to adapt this code, let us know, until that I wont mess with the updates :)

@dans98
Copy link
Owner

dans98 commented Dec 2, 2021

If you be aware of the Bullseye fix, and happen to have time to adapt this code, let us know, until that I wont mess with the updates :)

I'll for sure update it once the fix they already have makes it to an official release!

@dans98
Copy link
Owner

dans98 commented Dec 10, 2021

@xPew check out the video in the bottom of this blog post, it looks like you might be able to run bullseye now.
https://www.raspberrypi.com/news/new-old-functionality-with-raspberry-pi-os-legacy/

@dans98 dans98 closed this as completed Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants