Best way to obtain position data from octoprint

What is the problem?

i am trying to obtain the x y and z axis postions (cant be real time I know but from the gcode) from octoprint to compare it to my sensor positions

What did you already try to solve it?

i tried using the octoprint client but I can't find a way to set it up properly, using the api is not working either (in python but I know it's impossible to get the positions through there).

Have you tried running in safe mode?

yes

Did running in safe mode solve the problem?

no

Systeminfo Bundle

octoprint-systeminfo-20241015163315.zip (54.7 KB)

Additional information about your setup

running on raspberry pi 4

You are going to have problems. OctoPrint is for all printers and as such leaves the 'current' locations to the printer. My version of Marlin uses a 64 position queue for the planner. Most use 16 or 32. So OctoPrint is 16, 32 or even 64 points ahead of the 'current' printer position. You could use a M400 which tells the printer to empty the planner queue, do your comparisons/computations and then start sending again but that will cause stuttering.

I think M114 is probably the best option. There are some firmware options to allow M114 to be more or less accurate and there is also M154 to auto-report the position.

Tell us more about what you are trying to accomplish. What are "your sensors"?

I tried m114 but the api won't report back to python with the position data, I've tried doing the regular serial port but that causes issues trying to print. Right now my idea is to take the serial log from octoprint and make python code to put the transformed data into an excel sheet. My sensors are motion sensors that detect how far away the head is away from the 3d printed wall (one for each axis).