Closed mmcnair91 closed 10 months ago
Safe Z was originally implemented to avoid hitting plants beneath the Z-axis. It is an interesting edge case to hear you need to avoid hitting something above the Z-axis!
It would probably be tricky for us to implement an Always Enforce Safe Z type setting, and such a setting would also have many unintended consequences/tradeoffs. For example, with such a setting enabled you would not be able to move in the X/Y plane near the soil surface for a rotary tool weeding operation. You also would not be able to pull a tool out of a slot, or put it back in!
However, I think there is a relatively straightforward workaround for you to consider, which is to modify YOUR COPY of the more advanced sequences in your account, rather than creating your own version from scratch. The advanced sequences (Soil Height Grid, Weed Detection Grid, Water All, etc) are all written in Lua and you can modify the code for your purposes. In the example below, I have just added , safe_z = true
to the movement call:
Edit: If you wanted to get more advanced/efficient, you could add a conditional in there as you did in your example, to only use Safe Z in the necessary areas.
Expected: Setting "Safe Height" under settings enforces that height for all commands and sequences
Actual: "Safe Height" is only enforced when specifically called upon in sequences
Steps to Reproduce: All default movement commands, default and featured sequences do not enforce "Safe Height" even if it is set
Having a toggle to automatically enforce "Safe Height" for all sequences would be useful for many different reasons. In our case, we have our farmbot setup in a greenhouse and there is a support beam between X=2100-2280 unless the Z height is -180 or lower. To bypass this we will have to write custom sequences for every possible command and cannot use any default commands or parts of the interface without risking a collision. Example: Moving from Home to pick up the watering toolhead requires me to make a custom sequence using something like this
move_absolute({z=safe_z(),
safe_z = true})mount_tool(safe_z = true, variable("Tool"))'When doing a soil height calibration grid we used the Lua interface to create this script which lowers the Z axis to the safe height when moving between points within a certain range on the X-axis:
`-- Define the grid parameters local grid_points = {x = 15, y = 5, z = 0} local spacing = {x = 175, y = 175, z = 0}
-- Move in a grid pattern and measure soil height at each point for x = 0, grid_points.x - 1 do --x= is starting cell point for y = 0, grid_points.y - 1 do -- y= is starting cell point -- Calculate the coordinates of the current point local point = { x = x spacing.x, y = y spacing.y, z = 0 }
end end `
This is great for this one specific sequence, but I'll have to create custom sequences for every command available in order to avoid the obstruction in our greenhouse which seems like a near impossible task.