# Distance measurement and extracting data

**URL:** <https://tech-community.robotics.abb.com/t/distance-measurement-and-extracting-data/11790>\
**Category:** RAPID Programming\
**Tags:** data\
**Created:** [February 13, 2025, 10:04am UTC](https://tech-community.robotics.abb.com/t/distance-measurement-and-extracting-data/11790 "2025-02-13T10:04:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nihm20](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@nihm20](https://tech-community.robotics.abb.com/u/nihm20)\
**Post date:** [February 13, 2025, 10:04am UTC](https://tech-community.robotics.abb.com/t/distance-measurement-and-extracting-data/11790/1 "2025-02-13T10:04:56Z")

</div>

Hi, I’m new to programming in rapid. I have a question about distance measurement.

I have created targets for my robot, and then I want to record the position of the TCP after it has moved to each target. Here is a snippet of my code:

MoveL Target\_200,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
TCPPos1 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
dist2 := Distance(TCPPos1, measurementPoint);

MoveL Target\_210,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
TCPPos2 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
dist3 := Distance(TCPPos2, measurementPoint);

MoveL Target\_220,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
TCPPos3 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
dist3 := Distance(TCPPos2, measurementPoint);

MoveL Target\_230,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
TCPPos4 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
dist4 := Distance(TCPPos2, measurementPoint);

for dist1,..,4 I get the same distance as in the first one, even though I can see in the flexpendant that TCPPos1,…,4 are different, so it should be different distances as well.

Thas is my first concern. My second concern is if there is a way to extract the data TCPPo1,…,4 in any way from RobotStudio for analysing the data?

---

<div class="post-metadata">

**Author:** ![mandolas](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/mandolas/32/2496_2.png) [@mandolas](https://tech-community.robotics.abb.com/u/mandolas)\
**Post date:** [February 13, 2025, 11:00am UTC](https://tech-community.robotics.abb.com/t/distance-measurement-and-extracting-data/11790/2 "2025-02-13T11:00:55Z")

</div>

> [@nihm20](#):
>
> Hi, I’m new to programming in rapid. I have a question about distance measurement.
> 
> I have created targets for my robot, and then I want to record the position of the TCP after it has moved to each target. Here is a snippet of my code:
> 
> MoveL Target\_200,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
> TCPPos1 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
> dist2 := Distance(TCPPos1, measurementPoint);
> 
> MoveL Target\_210,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
> TCPPos2 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
> dist3 := Distance(TCPPos2, measurementPoint);
> 
> MoveL Target\_220,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
> TCPPos3 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
> dist3 := Distance(TCPPos2, measurementPoint);
> 
> MoveL Target\_230,v1000,fine,EndEffector3\WObj:=Workobject\_1;  
> TCPPos4 := CPos(\Tool := EndEffector3 \WObj := Workobject\_1);  
> dist4 := Distance(TCPPos2, measurementPoint);
> 
> for dist1,..,4 I get the same distance as in the first one, even though I can see in the flexpendant that TCPPos1,…,4 are different, so it should be different distances as well.
> 
> Thas is my first concern. My second concern is if there is a way to extract the data TCPPo1,…,4 in any way from RobotStudio for analysing the data?

Hi…  
There are some inconsistencies in your code…  
Having a look, that might be the problem.

??? dist3 := Distance(TCPPos2, measurementPoint) === dist4 := Distance(TCPPos2, measurementPoint);

Good Work.

---

<div class="post-metadata">

**Author:** ![nihm20](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@nihm20](https://tech-community.robotics.abb.com/u/nihm20)\
**Post date:** [February 13, 2025, 12:24pm UTC](https://tech-community.robotics.abb.com/t/distance-measurement-and-extracting-data/11790/3 "2025-02-13T12:24:59Z")

</div>

I realised this when working with the program, I think the syncronization messed up my code. Thank you for your answer.
