@Danal Love what you have done with DuetLapse, thanks for contributing it to the community. Overall works really well except for a couple of issues, some of which I know are on your radar such as error handling if you can't get a status update from the 3d printer (or if you are using a webcam error detecting) (as a side note, I have all hardlines between the printer and raspi 4 and computer running the camera and still randomly get errors).
The first issue I noticed was that the layer detection works by looking for z height changes. This is an issue for me as I do a vertical lift on retraction with the printhead. It should also resolve the issues people had with taking pictures during mesh bed scanning.
I added a function in the DuetWebAPI:
def getLayer(self):
URL=(f'{self._base_url}'+'/rr_status?type=3')
r = self.requests.get(URL)
j = self.json.loads(r.text)
s = j['currentLayer']
return (s)
The type3 return adds the current layer height information.
Then in the DuetLapse.py
# zn=printer.getCoords()['Z'] #replace with following line
zn=printer.getLayer()
along with updating the terminal printing in the oneInterval() function to
print('Capturing frame {0:5d} at X{1:4.2f} Y{2:4.2f} Z{3:4.2f} Layer {4:d}'.format(int(np.around(frame)),printer.getCoords()['X'],printer.getCoords()['Y'],printer.getCoords()['Z'],zn))
I figured out you might want to include it in your code. I can setup a pull request if you want.
Keep up the great work!
P.S. I am running RRF3.0, I don't know if the layer output is included in RRF2.
Also for everyone else looking to contribute or modify:
I assume Danal know where the documentation for the status returns are, but for others like me who didn't know where the documentation on the firmware status returns are located, https://reprap.org/wiki/RepRap_Firmware_Status_responses