RoboticsHow-to

Camera locate as a true false part presence check

Wire the camera locate node as a true/false part presence check: reset a flag before each locate, set it inside, loop while True, park when the tray is empty.

LumaSpec Vision10 min read Share on LinkedIn

On this page 10 sections
  1. 01The locate node is the if statement
  2. 02What you need
  3. 03Build the loop, step by step
  4. 04Worked example: tray-emptying time for a 12-pocket tray at 60 s takt
  5. 05Verify the pattern on the bench
  6. 06Common mistakes
  7. 07When the locate says False and the pocket is full
  8. 08Do it without a locate node: a vision sensor on a bracket
  9. 09Run-through checklist
  10. 10Questions

You want the wrist camera to answer one question — is a part present, yes or no — and keep the pick cycle running while the answer is yes, then send the robot to its rest position. The camera locate node already makes that decision every time it runs: it executes the steps nested inside it only when it finds a part, and skips them when it finds none. This guide turns that behavior into loop control: a boolean flag written inside the locate, reset to False before every attempt, and a loop that continues while the flag is True. It is written for a UR5 on a CB3.1 controller with a wrist camera and a two-point gripper, and the same pattern works wherever the camera runs as a program node in the pendant tree.

The locate node is the if statement

A locate hands you two outputs, and a picking program normally consumes only the first. The first is the part pose, which flows into your approach and grip moves just as in moving the robot relative to a vision-detected part frame. The second is execution behavior: on a match the children run; on no match they are skipped and the program continues at the next step outside the node. That second output is a presence sensor you already own. The locate runs anyway in a picking cell, so a presence check costs no extra cycle time — you only need to make the skip visible, and a flag variable does that. The variable is yours to create: a boolean, written part_found here, with every assignment in exactly two places, the reset and the locate.

If the locate itself is still being tuned for rotation or grip points, set the locate model up to survive rotation first, because the flag is only as truthful as the matches behind it. The same flag also stops a conveyor when its infeed runs dry; that empty-belt variant with a part-detected flag is written up separately.

What you need

  • A UR5-class robot on a CB3.1 controller. Controller generations differ in which camera packages they accept, so confirm compatibility before building the cell.
  • The wrist camera installed as a program node, with its locate taught on the part as the mounted camera sees it.
  • Your gripper and pick sequence — a two-point gripper in this cell.
  • One boolean variable you create yourself.
  • A tray or bin whose empty state means the task is done.
  • If the camera or sensor runs a taught job, set it to auto-load at startup so the first cycle of a shift is not blind.

Build the loop, step by step

  1. Create the flag. Add a boolean variable, part_found, and set its value True once, before the loop. Treat the True as a seed only: the loop condition is read before each pass, and pass one needs something to pass on.
  2. Add the loop. Continue while part_found = True.
  3. Reset before the locate. First step inside the loop: set part_found = False. This is the initialization that matters, written afresh before every locate attempt.
  4. Add the locate. Insert the camera locate node next and teach it as usual — mounted pose, model, match score.
  5. Write the flag inside. First child inside the locate: set part_found = True.
  6. Keep every pick move inside. Approach, grip, lift, place all sit inside the locate, after the flag write, so a failed match can never reach a motion.
  7. Park after the loop. Move-to-rest is the first instruction after the loop. It runs only when the loop exits, and the loop exits only on a failed locate.
  8. Prove both ends. Empty tray first, at reduced speed with a hand near the emergency stop; then a counted run with a known number of parts.
part_found = True                # boolean; seed so the first pass runs
Loop while part_found = True:
    part_found = False           # reset: assume this pass finds nothing
    Camera locate:
        part_found = True        # written only when the locate matches
        Move to pick pose        # pose output of the locate
        Close gripper
        Lift and place
Move to rest                     # reached only after a failed locate

Trace it once on paper before you run it: the seeded True gets pass one, the reset makes the locate the only writer of True, and a failed match leaves False, so the condition fails and the program drops to the rest move. That drop is your no-part answer. For the full tray-emptying cycle — place positions, pick counters, several trays in a row — the batch-picking loop that locates until no parts are found builds directly on this pattern.

Worked example: tray-emptying time for a 12-pocket tray at 60 s takt

The inputs, with where each comes from:

  • 12 filled pockets — the tray loaded in front of the robot.
  • 1.2 s per locate attempt — stopwatch time on the cell (example values; measure your own).
  • 4.8 s per pick — approach, grip, lift, place, same stopwatch run.
  • 60 s per tray — the takt the cell must hold.

The rule in words: each filled pocket costs one locate plus one pick, and the tray costs one further locate — the failed attempt that ends the loop. No pick runs on that final pass.

t_tray = parts × (t_locate + t_pick) + t_locate
  • 1.2 + 4.8 = 6.0 s per filled pocket
  • 12 × 6.0 = 72.0 s of picking
  • 72.0 + 1.2 = 73.2 s per tray

Result: 73.2 s per tray, of which the presence check itself is the last 1.2 s, under 2 percent of the cycle.

Decision: 73.2 s misses a 60 s takt by 13.2 s, and the flag pattern is not the cause — it costs one locate, 1.2 s, per tray. The budget per pocket is (60 − 1.2) ÷ 12 = 4.9 s of locate plus pick. Trim the pick from 4.8 s to 3.6 s and the tray runs 12 × 4.8 + 1.2 = 58.8 s, under takt with 1.2 s spare. If the pick cannot get below 4.9 s, fix the pick sequence — approach height, place speed — not the presence check.

Verify the pattern on the bench

  • Empty-tray dry run at reduced speed: exactly one pass — reset, one locate attempt, no motion, then rest. If it grips on an empty tray, the flag write sits outside the locate.
  • Counted run: load 5 parts, expect exactly 5 picks, then rest. Coming up short means a false negative mid-tray; the next section covers why.
  • Failure probe: flip one part upside down. A picking cell should park — if the model cannot match it, the gripper should not try. Better a rest move than a blind pick.
  • Check the path from loop exit to rest move: any instruction that slipped in between runs on every empty tray.

Common mistakes

  • No reset at the top of the pass. The flag keeps True from the last successful pick, so over an empty tray the loop repeats failed locates forever. The wrist looks busy while it re-photographs finished work.
  • Flag written outside the locate. Presence then reflects your code, not the camera, and the loop either never starts or never ends.
  • A pose read outside the locate. A failed match leaves the pose variable at its previous value, and a move built on it walks to the last good part. Keep approach and grip inside.
  • Taught on the wrong target. For picking, teach the part itself as the mounted camera sees it. Teaching the empty pocket answers a different question — teaching the cavity as the part fits slot-free checks, not picks.
  • Light drift between shifts. A false no-part parks the robot with work left in the tray; control the ambient light variation before blaming the flag.

When the locate says False and the pocket is full

Presence, as the locate reports it, is match success. A part upside down, awash in glare, or from a new batch in a slightly different color can read False while the pocket is full. For a picking cell that is usually the correct answer: if the model cannot match it, the gripper should not try. When occupancy alone matters, add a dumber backstop — a photoelectric sensor over the tray answers is-anything-there in milliseconds and ignores color changes. Use the locate for identity and pose, the sensor for occupancy, and treat disagreement between them as a fault worth an alarm. If matches are unreliable even before the loop exists, run the vision-locate feasibility checklist before you teach.

Do it without a locate node: a vision sensor on a bracket

When the locate node is not available — a camera without the feature, or a viewing point the wrist cannot reach — a small vision sensor does the same true/false job from a fixed bracket above the tray. It compares each image against its taught model and reports found or not found over Ethernet; the robot reads that line as an input at the top of every pass and drives the identical flag loop, so nothing in the steps above changes. Size the field first with the camera finder, which filters vision sensors and smart cameras by interface, resolution, sensor format and shutter.

Smart cameras & vision sensorsHikrobot MV-SCB007EC-12S-WBN SCB vision sensor, 1.6 MP, Color, 12 mm lens, Manual focusMV-SCB007EC-12S-WBN
Interface
Fast Ethernet
Resolution
Up to 3 MP
Sensor format
1/2.9"
Shutter
Global
$1,989.00 · quotedView and quote

The MV-SCB007EC-12S-WBN suits a tight bracket: 1.6 MP color on a 1/2.9-inch sensor, a 12 mm manual-focus lens, global shutter, Fast Ethernet.

Smart cameras & vision sensorsHikrobot MV-SCA002M-03S-WBN-SR SCA vision sensor, 0.3 MP, Mono, 3 mm lens, Focus distance 240 mmMV-SCA002M-03S-WBN-SR
Interface
Fast Ethernet
Resolution
Up to 3 MP
Sensor format
1/6"
Shutter
Global
$1,989.00 · quotedView and quote

The MV-SCA002M-03S-WBN-SR is the set-and-forget option: a 3 mm lens with a fixed 240 mm focus distance, mono, global shutter, and no focus to drift out over a season.

Run-through checklist

  • Flag created as a boolean, seeded True once before the loop, reset False at the top of every pass.
  • Flag write is the first child inside the locate; every pick motion stays inside with it.
  • Rest move is the first instruction after the loop, with nothing between.
  • Empty-tray run parks after exactly one attempt; counted run picks exactly the loaded count.
  • One forced false — a flipped part — parks the cell instead of triggering a blind pick.
  • Pass cap or cycle timer armed for the unattended case.

If you are speccing the camera side of a new cell, start the configurator at the camera step and work through lens and lighting with it; more robot-side material sits on the robotics topic page, and for help with a loop that will not close, contact us.

Questions

Does the locate still hand me the part pose when I use it as a true/false check?

Yes. The pose output and the true/false behavior come from the same node in the same pass: inside the locate you use the pose exactly as in a normal pick, and the flag write just sits above it. When no part is found the children never run, so no stale pose can ever reach a move.

How long does the loop run on an empty tray?

One pass. The seed True starts the loop, the reset writes False, the locate attempts once, finds nothing, and the condition fails on the way back. With the worked example's 1.2 s attempt, an empty tray costs about 1.2 s of locate plus the move to rest — never a pick.

The locate finds a part but the grip closes on nothing — is the flag still True?

Yes. The flag reports a camera match, not a held part. Count a part as picked only after a second confirmation: a force sensor that sees no reaction force when the gripper closes, or a gripper width or vacuum feedback signal. Without that second check, a missed grip silently short-changes your part count.

Can a standalone smart camera drive the same loop?

Yes. The sensor decides found or not found on board and reports it as a discrete output or over Ethernet; the robot reads that line as an input at the top of each pass and applies the identical flag logic. Keep the sensor's job loading automatically at startup so the first cycle of a shift is not a blind one.

Why seed the flag True before the loop when the tray might be empty?

The loop condition is read before the first pass, so a False seed would skip the locate entirely and park without ever looking. The seed only buys entry to pass one; the reset to False at the top of that pass erases it before the first locate, so an empty tray still produces zero picks.

Should the locate be taught on the part or on the pocket?

On the part when the question is what to pick: identity, pose and graspability in one match. Teach the empty cavity as the part only when the question is whether a slot is free, for example checking that a tray has room before placing. Teaching the pocket to pick from leads to grips on empty air.