Fix: Runaway in jog velocity mode#3820
Conversation
|
Yesterday, I did a whole day of milling with a lot of jogging between and no issues so far. |
|
Sorry to take so long to look at this. One thought that I have is whether potentially the velocity command should be set to zero in the case where the axis is on the limit. |
|
Rebased on 2.9 and pushed as 7242b3f |
|
Thanks for merging!
Reading the code, axis->teleop_tp.curr_vel is set to 0 in: I did not test that, but I don't see a reason how this could work any other way. |
I had forgotten to consider the side effects of the function call when I decided to move the lines to somewhere that felt more logical. As for your other question, yes, bug fixes go into 2.9 and then 2.9 is periodically merged upstream. |
While correcting issues in the xhc-whb04b-6 module (#3810), I found an issue in axis.c.
This can result in a crash, especially in Z axis if you have a tool in the spindle.
Steps to reproduce
I would expect the machine to move to x=-253.88
This happens on all axis and all limits. For simplicity, I just described X negative.
Analysis
The issue lies in https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/motion/axis.c
After homing, axis->pos_cmd is 0.0
G53 G0 X-254 moves the machine exactly to one of the limits.
Due to this, update_teleop_with_check returns true and axis->pos_cmd is not updated with the actual position:
https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/motion/axis.c#L677
When jogging in velocity mode, axis->pos_cmd is used to limit the next set-point:
https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/motion/axis.c#L421
Now with axis->pos_cmd == 0.0 while the machine is at -254, it moves with full speed to x=-0.914.
This issue exists on any axis when moving with gcode to one of the limits or your home position is at one of the limits and then manually jog in velocity mode to any direction.
I analyzed this with some printf debugging. See:
https://github.com/hdiethelm/linuxcnc-fork/tree/printf-debug
This was changed quite some time ago in:
784db03 control.c line 1312
Suggested fix
This fixes the above behavior. I will do some future testing next week in simulation and on my machine, but until now, I did not see any side effects.