# Nudge Example

### **HMI Panel File**

<figure><img src="https://175138337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvxlh3prlGsBGF30oqbYW%2Fuploads%2FrnWEj7JJkQLtyuERpQzm%2Fimmagine.png?alt=media&#x26;token=b15363d2-1472-4332-9835-3ec135fbb8ee" alt=""><figcaption></figcaption></figure>

{% file src="<https://175138337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvxlh3prlGsBGF30oqbYW%2Fuploads%2FYuOeTlHErWoXp6OYm9p9%2Fnudge_hmi.hmi?alt=media&token=bb3f7b4c-ee01-476d-a05c-5382c233d197>" %}

### **Robot Program File**

```python
# Robot functions file
force_threshold = 50
force_z = 0
status = "WAITING NUDGE"

# nudge function
def wait_nudge():
    sleep(1)
    f = get_tcp_force()
    while norm(f[2]) < force_threshold:
        sleep(0.2)
        f = get_tcp_force()
    end
end

thread update_force():
    while True:
        force_z = get_tcp_force()[2]
        sync()
    end
end

run update_force()
```

<pre class="language-python"><code class="lang-python"># Robot task file
status = "WAITING NUDGE"
<strong>wait_nudge()
</strong>status = "NUDGE DETECTED!"

# counter
global i = 0
while i &#x3C; 3:
    # pick
    movej([1.56, -1.86, 2.29, -2.00, -1.57, -0.01], r=0.03)
    movel(p[0.107, -0.331, 0.100, 0.00, 3.14, -0.00])
    movel(p[0.107, -0.331, 0.25, 0.00, 3.14, -0.00], r=0.03)

    # place
    movej([1.56, -1.40, 1.87, -2.04, -1.57, -0.01], r=0.03)
    movel(p[0.107, -0.517, 0.100, -0.00, 3.14, 0.00])
    movel(p[0.107, -0.517, 0.2500, -0.00, 3.14, 0.00], r=0.03)

    i = i + 1
end
</code></pre>

{% file src="<https://175138337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvxlh3prlGsBGF30oqbYW%2Fuploads%2FV5KKjMeXOZ0iapMF9Pee%2Fnudge_task.urp?alt=media&token=da39c91a-1c17-4278-8463-21753b87cdeb>" %}
