Hi,
based on the sequence “Pick upSeed from Tray”, I extended the script to pic up the seed from the current cell and advance to the next cell, when the script is called next. So when I call this sequence with a plant group as an external parameter, The seeds will be picked up from each cell for the individual plant in the group. I use an environment variable to remember which cell is the next cell to pick up the seed.
The sequence itself uses an external variable to identify the seed tray to use.
I thought I share the sequence here:
- read the current cell from “seed_tray_act_cell”
- pick up the seed from that cell
- get the next cell
- store the name of the next cell in “seed_tray_act_cell”
tray = variable("Seed Tray")
cell_label = env("seed_tray_act_cell")
if cell_label == nil then
-- The variable doesn't exist, so set a default value
cell_label = "A1"
end
function get_next_cell(cell_id)
-- Extract the row letter and column number from the cell identifier
local row_letter = string.sub(cell_id, 1, 1)
local col_number = tonumber(string.sub(cell_id, 2))
-- Calculate the row and column of the next cell
local next_row_letter = row_letter
local next_col_number = col_number + 1
if next_col_number > 4 then -- Wrap around to the next row if necessary
next_col_number = 1
if row_letter == "D" then -- Wrap around to the first row if necessary
next_row_letter = "A"
else
next_row_letter = string.char(string.byte(row_letter) + 1) -- Increment the row letter
end
end
-- Construct the identifier of the next cell
local next_cell_id = next_row_letter .. string.format("%d", next_col_number)
return next_cell_id
end
cell = get_seed_tray_cell(tray, cell_label)
cell_depth = 7
vacuum_pump_pin = 9
-- Checks
if not verify_tool() then
return
end
-- Send message with cell info
local cell_coordinates = " (" .. cell.x .. ", " .. cell.y .. ", " .. cell.z - cell_depth .. ")"
send_message("info", "Picking up seed from cell " .. cell_label .. cell_coordinates, "toast")
-- Store next Cell Label
cell_label = get_next_cell(cell_label)
env("seed_tray_act_cell",cell_label)
-- Job
start_time = os.time() * 1000
function job(status, percent)
set_job_progress("Pick from Seed Tray", {
status = status,
percent = percent,
time = start_time
})
end
-- Safe Z move to above the cell
job("Moving to Seed Tray", 25)
move_absolute({
x = cell.x,
y = cell.y,
z = cell.z + 25,
safe_z = true
})
-- Pick up seed
job("Picking up seed", 75)
write_pin(vacuum_pump_pin, "digital", 1)
move_absolute(cell.x, cell.y, cell.z - cell_depth)
-- Retract Z
job("Retracting Z", 90)
move_absolute(cell.x, cell.y, cell.z + 25)
job("Complete", 100)