As part of the load cell endstop work I want to grab the toolhead’s Z position and acceleration values over the course of the probing attempt.
The idea is that I want to trim the data to a set of values where the toolhead is at a constant velocity. The load cell produces dirty data as its accelerating. I want to figure out at what print time the Z axis finished accelerating so I can discard load cell samples that were subject to that acceleration.
I cant find anywhere in the existing code that does this kind of look back. My best guess is that I should use trapq_extract_old()
to grab the data I need when probing ends. It looks like the history expires after 30.0 seconds and I certainly don’t need all that data. It also appears that calling trapq_extract_old()
doesn’t actually change the contents of the history buffer so I shouldn’t break the motion_report
or anything else.
DumpTrapQ.extract_trapq()
does what I want, but I have to get the instance from inside motion_report
:
def get_trapq_history(printer, start_time):
return printer.lookup_object('motion_report') \
.trapqs['toolhead'] \
.extract_trapq(start_time, motion_report.NEVER_TIME)
Just wanted to check if this was OK, or if I should get the trapq from the toolhead object and re-implement this function?
Right - the trapq history is stored so that code can find the actual requested position at each point in time. There is similar history stored for all the moves on each stepper (to find the actual stepper position at each point in time).
If you just need that one function, it’s probably simpler to just copy that function.
-Kevin
1 Like
Thanks @koconnor, I’ll copy that function.
This works great! Extracting the moves from the probe start time yields 3 records:
Dumping trapq moves for Z probing:
move 0: print_time=73.751858 move_time=0.010000 start_velocity=0.000000 acceleration=500.000000 start_positionp=(200.000000,125.000000,3.571910)
move 1: print_time=73.761858 move_time=0.704382 start_velocity=5.000000 acceleration=0.000000 start_positionp=(200.000000,125.000000,3.546910)
move 2: print_time=74.466240 move_time=0.010000 start_velocity=5.000000 acceleration=-500.000000 start_positionp=(200.000000,125.000000,0.025000)
The second move is the constant velocity move, which is the start time I was after. The third move is the stop move that marks the end of the linear move, which is the end time I’m after.
I ended up using this in the implementation. I found that if I pulled the trapq and kept it around it would become corrupted:
['move 0: print_time=-171.051080 move_time=-169.514184 move_end=-340.565264 start_v=-167.936863 accel=-166.399936 start_position=(-164.863009,-163.326081,-161.789154) ar=(-160.252227,-158.715300,-157.178373)',
'move 1: print_time=-186.420034 move_time=-184.883138 move_end=-371.303172 start_v=-183.346243 accel=-181.809347 start_position=(-180.272452,-178.735557,-177.198661) ar=(-175.661766,-174.124870,-172.587975)',
'move 2: print_time=-201.788988 move_time=-200.252092 move_end=-402.041080 start_v=-198.715197 accel=-197.178301 start_position=(-195.641406,-194.104511,-192.567615) ar=(-191.030720,-189.493824,-187.956929)',
'move 3: print_time=-217.157942 move_time=-215.621046 move_end=-432.778988 start_v=-214.084151 accel=-212.547255 start_position=(-211.010360,-209.473465,-207.936569) ar=(-206.399674,-204.862778,-203.325883)',
'move 4: print_time=-232.496378 move_time=-230.959458 move_end=-463.455835 start_v=-229.422538 accel=-227.885619 start_position=(-226.348699,-224.811780,-223.305523) ar=(-221.768628,-220.231732,-218.694837)',
'move 5: print_time=-247.865573 move_time=-246.328654 move_end=-494.194227 start_v=-244.791734 accel=-243.254815 start_position=(-241.717895,-240.180975,-238.644056) ar=(-237.107136,-235.570217,-234.033297)']
Those numbers should not be negative
My best guess is the memory backing this gets freed in c and overwritten, then python starts reading garbage out of the same memory locations. If I use the data immediately and then discard it, everything is fine.
I want to pass the moves for the tap to the bad tap detection module. I think I can get that done with a copy.deepcopy
of the moves.