Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature Request: "Safe Height" default toggle switch #2448

Closed
mmcnair91 opened this issue Nov 15, 2023 · 1 comment
Closed

New Feature Request: "Safe Height" default toggle switch #2448

mmcnair91 opened this issue Nov 15, 2023 · 1 comment

Comments

@mmcnair91
Copy link

mmcnair91 commented Nov 15, 2023

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
}

-- Check if the point is in the "Obstruction X" area
if point.x >= 2140 and point.x <= 2280 then
  -- Move to the "safe Z" height before moving into the area
  move_absolute({z = safe_z()})
end

-- Move to the current point
move_absolute({x = point.x, y = point.y})

--Move back to max Z
move_absolute({z =0})

-- Measure soil height at the current point
measure_soil_height()

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.

@roryaronson
Copy link
Member

roryaronson commented Nov 19, 2023

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:

Screenshot 2023-11-18 at 4 34 23 PM

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants