I’m developing an extras module trying to align the data being pulled from a custom sensor with the printer’s live position data.
I found this, but is this still the best method for getting as close as possible to real position? What’s the recommended approach to get the same “near real time” position info for the xyz coords?
Hi @abcsu25 ,
Since you’re writing an extra and have direct access to Klipper’s internals, you could do something like this:
toolhead = printer.lookup_object('toolhead')
toolhead.get_status()['position'] # or toolhead.commanded_pos
Also, when writing your extra I would recommend taking a look at this guide I wrote for an overview on how to develop Klippy extras.
Hey @3dcoded,
In the documentation it says toolhead has the coords including requested moves.
I’m looking for how I can get the un-affected coords with time.
Thanks!
Oh. If you want the live coords (the small ones in the brackets in this Mainsail screenshot), you can use motion_report
motion_report = printer.lookup_object('motion_report')
reactor = printer.get_reactor()
eventtime = reactor.monotonic()
pos = motion_report.get_status(eventtime)['live_position']
You can also set eventtime to a time in the past to get the previous position.
I ended up graphing the motion report, the stepper position, and the toolhead position. I got a difference in ~2 seconds. I’m looking for theories on which is “most” correct.