# Get 1st position in Direction

**URL:** <https://forum.universal-robots.com/t/get-1st-position-in-direction/38530>\
**Category:** Technical Questions\
**Created:** [February 12, 2025, 4:18pm UTC](https://forum.universal-robots.com/t/get-1st-position-in-direction/38530 "2025-02-12T16:18:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeeDee](https://avatars.discourse-cdn.com/v4/letter/g/90ced4/32.png) [@GeeDee](https://forum.universal-robots.com/u/GeeDee)\
**Post date:** [February 12, 2025, 4:18pm UTC](https://forum.universal-robots.com/t/get-1st-position-in-direction/38530/1 "2025-02-12T16:18:38Z")

</div>

Hello,

I have motions to drop parts to a location using Direction. I would like to keep track of the CurrentCount and stop the stacking when it reaches 10. How do I grab the info of when the TCP is on the very bottom currently dropping the 1st part? My concern is if something happen, I want to keep track of the currentcount so that the operator does not have to clear the surface if anything happens and if they restart the program.

Thank you for checking

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [February 12, 2025, 5:25pm UTC](https://forum.universal-robots.com/t/get-1st-position-in-direction/38530/2 "2025-02-12T17:25:45Z")

</div>

```auto
var_1=get_actual_tcp_pose()
tcp_z = var_1[2]
if (tcp_z < YOUR_VALUE)
{
  //TCP is identified as being "at the bottom" so do something
}

```

Here’s the pseudocode for reading TCP values. By extracting just the Z component, you can tell when the TCP is below a certain threshhold. That said, I’m not seeing why you can’t just make a variable and increment it after each cycle and just check if that var == 10, but you do you.

---

<div class="post-metadata">

**Author:** ![GeeDee](https://avatars.discourse-cdn.com/v4/letter/g/90ced4/32.png) [@GeeDee](https://forum.universal-robots.com/u/GeeDee)\
**Post date:** [February 12, 2025, 5:59pm UTC](https://forum.universal-robots.com/t/get-1st-position-in-direction/38530/3 "2025-02-12T17:59:10Z")

</div>

Thank you Eric. The reason I wanted to track when the TCP is on the very bottom is to make sure that I can reset a variable if for some reason the stack was moved even if the stack hasn’t reached 10 pcs. But if you’re able to come up with a much less complicated solution I’d like to see it. I am so new to this, my apologies  
Thank you so much.

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [February 12, 2025, 6:10pm UTC](https://forum.universal-robots.com/t/get-1st-position-in-direction/38530/4 "2025-02-12T18:10:39Z")

</div>

Nope that sounds like a perfectly good reason to do it this way. If a human can come in and “disrupt” normal flow, this is a great way to account for that. Alternatively you could not care about keeping a count at all, and just look at the TCP’s z coordinate to be at the 10-piece-height. So basically just “do work until the last drop point was THIS high.” Either way would work I imagine

---

<div class="post-metadata">

**Author:** ![efn](https://avatars.discourse-cdn.com/v4/letter/e/35a633/32.png) [@efn](https://forum.universal-robots.com/u/efn)\
**Post date:** [February 14, 2025, 8:34am UTC](https://forum.universal-robots.com/t/get-1st-position-in-direction/38530/5 "2025-02-14T08:34:25Z")

</div>

It sounds like you can just add another “Until” to your Direction with a Distance. 🙂 You can then add an Action to that Distance, where you can reset your counter.

---

<div class="post-metadata">

**Author:** ![GeeDee](https://avatars.discourse-cdn.com/v4/letter/g/90ced4/32.png) [@GeeDee](https://forum.universal-robots.com/u/GeeDee)\
**Post date:** [February 14, 2025, 12:58pm UTC](https://forum.universal-robots.com/t/get-1st-position-in-direction/38530/6 "2025-02-14T12:58:52Z")

</div>

Wow! Didn’t realize this. Thank you so much!
