DuetLapse3
-
If all y'all could try this on SBC please
In particular verify that a message appears in DWC "Test of SBC"
-
@stuartofmt
Good newsDetermine API Version localhost Testing: rr_model at address localhost localhost http://localhost/rr_model?key=boards localhost localhost Testing: /machine/system at address localhost localhost http://localhost/machine/status localhost localhost API model is: SBC Version is: 3 localhost Status is :idle localhost Send Gcode result: None localhost Layer: None localhost Get Position X and Y: 160 130
bad news, no popup
-
Yikes on the lack of gcode being sent ... Unfortunately the API endpoint reports success - when clearly that is not the case ...
This one last bit is turning out to be frustrating ....
The code for sending the gcode (thanks for the reference) is very simple. It works perfectly for rr_model (just uses a http get) but does not seem to want to play for /machine/gcode (which according to the doc requires a post).
I've added a second slightly different syntax. I found two slightly different versions (one in DuetUI and the second in Danals DuetAPI). They are nearly identical, one has the url as .../machine/code and the other as /machine/code/ ...
If you would not mind running it .....
-
@stuartofmt
no popup there eitherlocalhost Determine API Version localhost Testing: rr_model at address localhost localhost http://localhost/rr_model?key=boards localhost localhost Testing: /machine/system at address localhost localhost http://localhost/machine/status localhost localhost API model is: SBC Version is: 3 localhost Status is :idle localhost URL was: http://localhost/machine/code localhost Send Gcode result: None localhost Layer: None localhost Get Position X and Y: 160 130 localhost URL was: http://localhost/machine/code/ localhost Send Gcode result: None
-
I'll go back to the DWC threads and see if there are some ideas I can try.
The good news is I've made the baseline code considerable more robust and have improved the handling of pauses (if used). But none of the pause improvements matter without the ability to send gcodes
-
@stuartofmt
https://github.com/Kriechi/Cura-DuetRRFPlugin/blob/master/DuetRRFOutputDevice.pyMaybe this is helpful
-
@stuartofmt only for history
pi@duet3:~ $ ./1610998509032-sbctest.py -duet 192.168.140.126 192.168.140.126 Determine API Version 192.168.140.126 Testing: rr_model at address 192.168.140.126 192.168.140.126 http://192.168.140.126/rr_model?key=boards 192.168.140.126 192.168.140.126 Testing: /machine/system at address 192.168.140.126 192.168.140.126 http://192.168.140.126/machine/status 192.168.140.126 192.168.140.126 API model is: SBC Version is: 3 192.168.140.126 Status is :processing 192.168.140.126 URL was: http://192.168.140.126/machine/code 192.168.140.126 Send Gcode result: None 192.168.140.126 Layer: 3 192.168.140.126 Get Position X and Y: 96.787 119.675 192.168.140.126 URL was: http://192.168.140.126/machine/code/ 192.168.140.126 Send Gcode result: None
no DWC message either
-
@stuartofmt I changed this line
logger.info('Send Gcode result: '+str(sendDuetGcode2(apiModel, 'M117 Test of SBC')))
to
logger.info('Send Gcode result: '+str(sendDuetGcode2(apiModel, 'M117 "Test of SBC"')))
aand
-
@PCR said in DuetLapse3:
logger.info('Send Gcode result: '+str(sendDuetGcode2(apiModel, 'M117 "Test of SBC"')))
aand ![a02d93f9-98a1-4404-bb9a-c67b729cac68-grafik.png](/assets/uploads/files/1611049373109-a02d93f9-98a1-4404-bb9a-c67b729cac68-grafik.png)
Brilliant!.
Last night (in my slumbers) I wonderer if the data=command in the push code needed to be encoded because of the spaces in M117 etc. In the various example code it seems only single gcodes have been passed and likely why those examples worked. Dueui was a bit different but that was javascript and I'm even more unfamiliar with that than I am with Python .....
DuetLapse3 in its current form only needs to send single gcodes. So - as it stands we have a fully working DuetLapse3. The choice of M117 ... for testing turned out to be both good and bad.What I will do today is try and crack the encoding needs so that it does not break in the future. I've set up a simple webserver and can debug the incoming and see what happens. I have not yet updated the github but either way will do so later today
-
Version 3.0.4 released in github. All functionality should now work with SBC.
The issues with SBC gcode appear to be due to differences in the way DWS was handling the test case.
-
Version 3.1.1 released on github. This is pretty significant - the details are documented but here us a summary.
###Version 3.1.0###
[1] Added support for Windows
[2] Added automatic detection of operating system (Linux or Windows)
[3] Added integrated http listener for basic browser based control
[4] Changed file naming convention to make filenames unique if multiple instances of DuetLapse3 are running.An Integrated http listener is available for basic control of DuetLapse3 (not the attached printer).
The http listener is activated by specifying a port number using the -port option.
In conjunction with the -host option it provides the following functionality from a browser (or curl or other method of performing a http get).http://<ip-address><port>/?command=<valid command>
*Valid commands are:
start - Starts DuetLapse3 recording if the -stopcmd option was used or after a stop command
standby - Stops (but does not terminate) DuetLapse3 recording and discards any images capture. Waits for a start command.
status - returns brief information about the running state of DuetLapse3
pause - causes DuetLapse3 to temporarily stop capturing images
continue - causes DuetLapse3 to resume capturing images
snapshot - causes DuetLapse3 to make an interim video and then continue
restart - causes DuetLapse3 to stop capturing images, create a video and then restart with a new capture set
terminate - causes DuetLapse3 to stop capturing images, create a video and then terminate the program. This is the same as CTRL+C or SIGINT.Note that depending on your system - it may take several minutes for the http listener to completely shutdown following a terminate request.*
Note that the http listener will stop responding if DuetLapse3 is run from a command console that is then closed. This will happen even if started in background. To avoid this - use nohup (linux).
Windows does not have an (easy) equivalent to nohup so you would need to leave the command console open. An alternative if you are on Win10 is to use Windows Subsystem for Linux (WSL) and run DuetLapse as a linux application inside WSL.
If running in nohup mode CTRL+C cannot be used so you need to send the terminate command (?command=terminate) from the http listenerMade an accommodation (in 3.1.1) for ffmpeg < 4.2 by using a simpler syntax if -extratime is not used.
-
Take a look at the post above. It does not provide a plugin but the http listener makes it easier to control remotely. It looks like the plugins require javascript and frankly - that's not something I want to get into.
Someone else (with the skills) could create a simple plugin that calls appropriate urls and provide control that way.
I will create a helper script that proved a separate http listener to remotely start DuetLapse3 - but that's a few days away. -
@stuartofmt Thanks Stuart; I did try installing the 3.04 earlier this weekend following each step but got stuck at ffmpeg install; doesn't return anything when checking version.
I guess I'm still way to beginner at linux terminal. I'll try again with the new version
-
@fractalengineer said in DuetLapse3:
@stuartofmt Thanks Stuart; I did try installing the 3.04 earlier this weekend following each step but got stuck at ffmpeg install; doesn't return anything when checking version.
I guess I'm still way to beginner at linux terminal. I'll try again with the new version
Don't worry - we will get you going.
I'm assuming you are using a raspberry pi ?The latest version should work with the version of ffmpeg that installs by default with the pi. The only downside is not being able to use the -extratime option.
I'd recommend you reinstall the default ffmpeg and take it from there.
It sounds like you tried to follow my instructions and the installation of the latest ffmpeg failed somehow? If that is correct then lets try to clean it up and get you back to the default. Try the following in order (I just did this on my pi)cd ~ sudo apt remove ffmpeg
I'm guessing this will say ffmpeg is not installed.
Next:
sudo find / -name ffmpeg
This will may give some output for example:)
find: ‘/run/user/1000/gvfs’: Permission denied
/usr/local/bin/ffmpeg
/usr/local/share/ffmpeg
/usr/local/share/doc/ffmpegfor each of the files / directories - we'll first delete everything for EXAMPLE
sudo rm -rf /usr/local/bin/ffmpeg sudo rm -rf /usr/local/share/ffmpeg sudo rm -rf /usr/local/share/doc/ffmpeg
Next make sure everything is at the latest release level
sudo apt update sudo apt upgrade
I just did this on my pi - it was quite the upgrade and took quite a while so be patient.
Finally, install the standard ffmpeg
sudo apt install ffmpeg
after that and assuming no errors
ffmpeg -version
should return a bunch of information.
Then reboot for luck
-
@stuartofmt aww mate you're a saint; didn't expect such a detailed help.
I went through those steps and when doing the
find
it didn't return anything; so I guess it didn't build properly in the first place (I used the cmake last time)Seems like everything is installed now; just got to figure out the usage exactly
Thanks!
-
Hi,
@stuartofmt I have a Problem with layer capturing if i use this nothing will be captured i use the following command to start it
python3 DuetLapse3.py -port 8181 -duet 192.168.188.36 -detect layer -camera1 stream -weburl1 http://192.168.188.34:8081/
This result in
192.168.188.36 ################### Options selected for this run ##################### 192.168.188.36 #Environment Settings: 192.168.188.36 # printer = 192.168.188.36 192.168.188.36 # basedir = /home/pi/DuetLapse 192.168.188.36 # poll = 5 192.168.188.36 # logtype = both 192.168.188.36 # verbose = False 192.168.188.36 # os = Linux 192.168.188.36 # host = 0.0.0.0 192.168.188.36 # port = 8181 192.168.188.36 # pid = 7902 192.168.188.36 #Execution Setings: 192.168.188.36 # dontwait = False 192.168.188.36 # seconds = 0 192.168.188.36 # detect = layer 192.168.188.36 # pause = no 192.168.188.36 # standby = False 192.168.188.36 #Camera1 Settings: 192.168.188.36 # camera1 = stream 192.168.188.36 # weburl1 = http://192.168.188.34:8081/ 192.168.188.36 # Video Settings: 192.168.188.36 # extratime = 0 192.168.188.36 ################################################################### 192.168.188.36 192.168.188.36 192.168.188.36 192.168.188.36 ############################################################### 192.168.188.36 Connected to printer at 192.168.188.36 using version 3.2 and API access using rr_model 192.168.188.36 ############################################################### 192.168.188.36 192.168.188.36 192.168.188.36 ########################################################## 192.168.188.36 ***** Started http listener ***** 192.168.188.36 ########################################################## 192.168.188.36 192.168.188.36 192.168.188.36 ########################################################## 192.168.188.36 Will start capturing images on first layer change 192.168.188.36 ########################################################## 192.168.188.36 192.168.188.36 192.168.188.36 ########################################################## 192.168.188.36 Video will be created when printing ends. 192.168.188.36 Or, press Ctrl+C one time to stop capture and create video. 192.168.188.36 ########################################################## 192.168.188.36 192.168.188.36 ****** Printer State changed to waiting ***** 192.168.188.36 ****** Printer State changed to printing ***** 192.168.188.36 ****** Printer State changed to completed ***** 192.168.188.36 End of Print Job - Post Processing 192.168.188.36 ++++++ Entering restart state ++++++ 192.168.188.36 192.168.188.36 Camera1: Cannot create video with only 0 frames 192.168.188.36 ****** Printer State changed to waiting *****
If i use the Time capturing option it works as it should
/DuetLapse $ python3 DuetLapse3.py -port 8181 -duet 192.168.188.36 -seconds 20 -detect none -camera1 stream -weburl1 http://192.168.188.34:8081/ .. .. .. 192.168.188.36 ########################################################## 192.168.188.36 Video will be created when printing ends. 192.168.188.36 Or, press Ctrl+C one time to stop capture and create video. 192.168.188.36 ########################################################## 192.168.188.36 192.168.188.36 ****** Printer State changed to waiting ***** 192.168.188.36 ****** Printer State changed to printing ***** 192.168.188.36 ****** Printer State changed to startnow ***** 192.168.188.36 Camera1: capturing frame 0 at layer 72 after 20.0 seconds 192.168.188.36 ****** Printer State changed to printing ***** 192.168.188.36 Camera1: capturing frame 1 at layer 73 after 20.0 seconds 192.168.188.36 Camera1: capturing frame 2 at layer 74 after 20.0 seconds 192.168.188.36 Camera1: capturing frame 3 at layer 75 after 20.0 seconds 192.168.188.36 Camera1: capturing frame 4 at layer 76 after 20.0 seconds 192.168.188.36 Camera1: capturing frame 5 at layer 78 after 20.0 seconds 192.168.188.36 Camera1: capturing frame 6 at layer 79 after 20.0 seconds 192.168.188.36 Camera1: capturing frame 7 at layer 80 after 20.0 seconds ^C192.168.188.36 !!!!!! Stopped by SIGINT - Post Processing !!!!!! 192.168.188.36 192.168.188.36 Camera1: Cannot create video with only 8 frames 192.168.188.36 Waiting for http listener to shutdown. 192.168.188.36 Program Terminated
The printer is on the latest stable:
RepRapFirmware for Duet 2 WiFi/Ethernet version 3.2 running on Duet WiFi 1.02 or later + DueX5
Can you please tell me what i did wrong?
-
my knowledge of python is not really available but when i look at this code:
#update the layer counter global zo1, zo2 zn = getDuetLayer(apiModel) if (cameraname == 'Camera1'): zo1 = zn else: zo2 = zn if ('layer' in detect): if ((not zn == zo1 and cameraname == 'Camera1') or (not zn == zo2 and cameraname == 'Camera2')): # Layer changed, take a picture. checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' after layer change') onePhoto(cameraname, camera, weburl, camparam) elif ('pause' in detect and printerState == 'paused'): checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' at pause in print gcode') onePhoto(cameraname, camera, weburl, camparam)
So this script can't access to the take picture routine because zo1 and zn is always the same
I have now altered the code to:
#update the layer counter global zo1, zo2 zn = getDuetLayer(apiModel) # if (cameraname == 'Camera1'): # zo1 = zn # else: # zo2 = zn if ('layer' in detect): if ((not zn == zo1 and cameraname == 'Camera1') or (not zn == zo2 and cameraname == 'Camera2')): # Layer changed, take a picture. checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' after layer change') onePhoto(cameraname, camera, weburl, camparam) elif ('pause' in detect and printerState == 'paused'): checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' at pause in print gcode') onePhoto(cameraname, camera, weburl, camparam) # global zo1, zo2 # zn = getDuetLayer(apiModel) if (cameraname == 'Camera1'): zo1 = zn else: zo2 = zn
And for now it works (but i don't know if i have now added a new failure)
-
Hi Sam - sorry you are having problems. The changes you made to the code will most definitely cause problems That piece of code keeps track of layer changes.
Having said that it was my error ...
But first - I see you have started DuetLapse with:
python3 DuetLapse3.py -port 8181 -duet 192.168.188.36 -detect layer -camera1 stream -weburl1 http://192.168.188.34:8081/
You have BOTH your web camera (-weburl1) AND DuetLapse3 on the same port number. This is a no-no. They need to be different. In the next release (I am testing now) - I check to see if the port is already in use and if it is, prevent DuetLapse3 from starting. So please change the -port so that it is on a different and unused port number.
Second - on the layer change - yikes! This is definitely wrong and thanks for pointing it out. I must have copy/pasted that portion into the wrong place when I did some 'tidy up' . I will fix that today. If you want to fix it yourself - move the assignment so that it looks like this:
#update the layer counter global zo1, zo2 zn = getDuetLayer(apiModel) if ('layer' in detect): if ((not zn == zo1 and cameraname == 'Camera1') or (not zn == zo2 and cameraname == 'Camera2')): # Layer changed, take a picture. checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' after layer change') onePhoto(cameraname, camera, weburl, camparam) elif ('pause' in detect and duetStatus == 'paused'): checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' at pause in print gcode') onePhoto(cameraname, camera, weburl, camparam) if (cameraname == 'Camera1'): zo1 = zn else: zo2 = zn
In any case, the change to -seconds 20 -detect none is working as it should but that is bypassing the layer check so the change you made has no effect.
-
Thank you for your assistance!
My start command is correct duetlapse runs on 8181 and the cam on 8081
to your code change the only change i can see is that you have removed the comments is this right ?
-
@SIam said in DuetLapse3:
Thank you for your assistance!
My start command is correct duetlapse runs on 8181 and the cam on 8081
to your code change the only change i can see is that you have removed the comments is this right ?
Sorry - I misread the port numbers , you are of course correct.
As to the question on the code change - no.
This portion of code
if (cameraname == 'Camera1'): zo1 = zn else: zo2 = zn
needs to be after this portion (not before - which was the problem )
if ('layer' in detect): if ((not zn == zo1 and cameraname == 'Camera1') or (not zn == zo2 and cameraname == 'Camera2')): # Layer changed, take a picture. checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' after layer change') onePhoto(cameraname, camera, weburl, camparam) elif ('pause' in detect and duetStatus == 'paused'): checkForPause() logger.info(cameraname+': capturing frame '+str(frame)+' at layer '+str(zn)+' at pause in print gcode') onePhoto(cameraname, camera, weburl, camparam)
NOTE THAT THE INDENTING HAS TO BE EXACTLY THE SAME - Python is very particular in that regard - so be careful as you edit