"""Grasp several objects in turn into one region, spreading the drop points.""" from .base import approach_and_grasp, place_at def solve(env, objects, target, arm="right", jaw="auto", spread=0.075, lift=0.16, on_top=False, max_gap=0.045): a = env.arms[arm] out = {} for i, name in enumerate(objects): pre = f"[{i+1}/{len(objects)}] " res, ext = approach_and_grasp(env, a, name, jaw=jaw, max_gap=max_gap, prefix=pre) if not res.ok: out[name] = {"grasped": False, "reason": res.reason} continue # spread the drops: the same point twice means the second lands on the first and rolls out dx = (i-(len(objects)-1)/2.0)*spread out[name] = {"grasped": True, "place_err": place_at(env, a, target, float(ext[2])/2.0, on_top=on_top, lift=lift, dx=dx, prefix=pre)} return out