# Pick and Place Example

**HMI Panel File**

<figure><img src="/files/6I7nGuvkjDOXvimCRbwV" alt=""><figcaption></figcaption></figure>

{% file src="/files/1WyAXgZXQSEE1AcEWkeK" %}

**Robot Program File**

```python
# variables
global velocity = 200
global loop_forever = False
global repetitions = 2
global gripper_status = "ACTIVATED"
global counter = 0
global aborted = False
global completed = False
global status = "READY"

# positions (can be defined also as installation variables to store their value)
global pick_pose = p[0, 0, 0, 0, 0, 0]
global place_pose = p[0, 0, 0, 0, 0, 0]

# functions
def open_gripper():
    if gripper_status == "ACTIVATED":
        textmsg("open")
        #rq_open()
    end
end

def close_gripper():
    if gripper_status == "ACTIVATED":
        textmsg("close")
        #rq_close()
    end
end

def pick(pose):
    if not aborted:
        status = "PICKING"
        approach = pose_trans(pose, p[0, 0, -0.1, 0, 0, 0])
        movel(approach, a=0.1, v=velocity/1000)
        movel(pick_pose, a=0.1, v=velocity/1000)
        close_gripper()
        movel(approach, a=0.1, v=velocity/1000)
    end
end

def place(pose):
    if not aborted:
        status = "PLACING"
        approach = pose_trans(pose, p[0, 0, -0.1, 0, 0, 0])
        movel(approach, a=0.1, v=velocity/1000)
        movel(pick_pose, a=0.1, v=velocity/1000)
        open_gripper()
        movel(approach, a=0.1, v=velocity/1000)
    end
end

def start_task():
    global counter = 0
    global aborted = False
    global completed = False
    while (not aborted) and (loop_forever or counter < repetitions):
        pick(pick_pose)
        place(place_pose)
        pick(place_pose)
        place(pick_pose)
        counter = counter + 1
    end
    completed = True
    status = "READY"
end

def stop_task():
    global aborted = True
    status = "STOPPING..."
    while not completed:
        sleep(0.1)
    end
end
```

{% file src="/files/fgMjMPGTlyVEKzp37eeS" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.robpod.cloud/hmi-designer/working-examples/universal-robots/pick-and-place-example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
